composer.phar 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099
  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+€��Lñ‡`+€��É‹Ýg¤������+���src/Composer/Autoload/ClassMapGenerator.phpÔ��Lñ‡`Ô��ñ§¤���������src/Composer/Cache.phpJ��Lñ‡`J��ˆ¿/‰¤������%���src/Composer/Command/AboutCommand.phpØ��Lñ‡`Ø��ö÷;‡¤������'���src/Composer/Command/ArchiveCommand.phpÀ��Lñ‡`À��Á’ =¤������$���src/Composer/Command/BaseCommand.phpE��Lñ‡`E��Õ7z·¤������.���src/Composer/Command/BaseDependencyCommand.phpS��Lñ‡`S��ªƒ"Ť������1���src/Composer/Command/CheckPlatformReqsCommand.php¹��Lñ‡`¹��hV—¯¤������*���src/Composer/Command/ClearCacheCommand.phpó��Lñ‡`ó��ˆ(*Ô¤������&���src/Composer/Command/ConfigCommand.phpûW��Lñ‡`ûW���©»!¤������-���src/Composer/Command/CreateProjectCommand.php¤B��Lñ‡`¤B��3t*%¤������'���src/Composer/Command/DependsCommand.phpñ��Lñ‡`ñ��kU‹{¤������(���src/Composer/Command/DiagnoseCommand.phpWJ��Lñ‡`WJ��Ã
  25. œ¤������,���src/Composer/Command/DumpAutoloadCommand.php±��Lñ‡`±��a#®¤������$���src/Composer/Command/ExecCommand.phpœ��Lñ‡`œ��
  26. ;…)¤������$���src/Composer/Command/FundCommand.php3 ��Lñ‡`3 ��.½¤������&���src/Composer/Command/GlobalCommand.phpÅ ��Lñ‡`Å ��©O:ü¤������$���src/Composer/Command/HomeCommand.php��Lñ‡`��p—Τ������$���src/Composer/Command/InitCommand.phpœ[��Lñ‡`œ[��xf“e¤������'���src/Composer/Command/InstallCommand.phpP��Lñ‡`P��µœ¤������(���src/Composer/Command/LicensesCommand.phpZ��Lñ‡`Z��OT@0¤������(���src/Composer/Command/OutdatedCommand.php� ��Lñ‡`� ��7~½=¤������)���src/Composer/Command/ProhibitsCommand.php��Lñ‡`��_¤éS¤������&���src/Composer/Command/RemoveCommand.php´)��Lñ‡`´)��Y;”¤������'���src/Composer/Command/RequireCommand.php 7��Lñ‡` 7��Í·Ǥ������)���src/Composer/Command/RunScriptCommand.phpF��Lñ‡`F��8{O{¤������+���src/Composer/Command/ScriptAliasCommand.php¯��Lñ‡`¯��?=Ѥ������&���src/Composer/Command/SearchCommand.phpT ��Lñ‡`T ��ZÕ±¤������*���src/Composer/Command/SelfUpdateCommand.phpE��Lñ‡`E��2ièϤ������$���src/Composer/Command/ShowCommand.php~‹��Lñ‡`~‹��Óå.¤������&���src/Composer/Command/StatusCommand.phpë��Lñ‡`ë��£c}¤������(���src/Composer/Command/SuggestsCommand.php˜ ��Lñ‡`˜ ��=c{à¤������&���src/Composer/Command/UpdateCommand.php3��Lñ‡`3���æÀ¤������(���src/Composer/Command/ValidateCommand.phpG��Lñ‡`G��§ a¤���������src/Composer/Composer.php ��Lñ‡` �� ŒŽ„¤���������src/Composer/Config.php&��Lñ‡`&��‡™ro¤������-���src/Composer/Config/ConfigSourceInterface.php��Lñ‡`���û¤������(���src/Composer/Config/JsonConfigSource.phpi��Lñ‡`i��9jQ*¤������$���src/Composer/Console/Application.php <��Lñ‡` <��šÖH¨¤������*���src/Composer/Console/GithubActionError.phph��Lñ‡`h��œQÆt¤������,���src/Composer/Console/HtmlOutputFormatter.php0��Lñ‡`0��^КҤ������-���src/Composer/DependencyResolver/Decisions.phpº��Lñ‡`º��:ÎK¤������1���src/Composer/DependencyResolver/DefaultPolicy.phpñ��Lñ‡`ñ��róM¦¤������/���src/Composer/DependencyResolver/GenericRule.php¡��Lñ‡`¡��v'ù
  27. ¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.phpQ��Lñ‡`Q��í6Ĥ������3���src/Composer/DependencyResolver/LockTransaction.phpà
  28. ��Lñ‡`à
  29. ��ì�`k¤������5���src/Composer/DependencyResolver/MultiConflictRule.php,��Lñ‡`,��ðá¬$¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.php·��Lñ‡`·��#Ò­’¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.phpß��Lñ‡`ß��=Ù÷À¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.phpå��Lñ‡`å��‡°¸/¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÚ���Lñ‡`Ú���Qâè¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.php��Lñ‡`��mÑa¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpŸ��Lñ‡`Ÿ��o ±(¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpG��Lñ‡`G��–ˆ
  30. ¤������3���src/Composer/DependencyResolver/PolicyInterface.php7��Lñ‡`7��ŽþR¤������(���src/Composer/DependencyResolver/Pool.phpO��Lñ‡`O���(ž ¤������/���src/Composer/DependencyResolver/PoolBuilder.php:1��Lñ‡`:1��Û Ü ¤������+���src/Composer/DependencyResolver/Problem.phpð8��Lñ‡`ð8��+œ‹¤������+���src/Composer/DependencyResolver/Request.phpë��Lñ‡`ë��qid¤������(���src/Composer/DependencyResolver/Rule.phpJ'��Lñ‡`J'��gë2¤������1���src/Composer/DependencyResolver/Rule2Literals.php��Lñ‡`��^ Wá¤������+���src/Composer/DependencyResolver/RuleSet.phpr ��Lñ‡`r ��bZ¬”¤������4���src/Composer/DependencyResolver/RuleSetGenerator.php¤��Lñ‡`¤��Å�ÓÚ¤������3���src/Composer/DependencyResolver/RuleSetIterator.php ��Lñ‡` ��…gØ,¤������2���src/Composer/DependencyResolver/RuleWatchChain.phpi��Lñ‡`i��hïš,¤������2���src/Composer/DependencyResolver/RuleWatchGraph.php8 ��Lñ‡`8 ��8ӎȤ������1���src/Composer/DependencyResolver/RuleWatchNode.php2��Lñ‡`2��ü;㔤������*���src/Composer/DependencyResolver/Solver.php8��Lñ‡`8��žN�’¤������6���src/Composer/DependencyResolver/SolverBugException.php™��Lñ‡`™��Xg6¤������;���src/Composer/DependencyResolver/SolverProblemsException.php ��Lñ‡` ��ºì C¤������/���src/Composer/DependencyResolver/Transaction.php°��Lñ‡`°��-­ïߤ������-���src/Composer/Downloader/ArchiveDownloader.php��Lñ‡`��nÑΉ¤������1���src/Composer/Downloader/ChangeReportInterface.phpÌ���Lñ‡`Ì���¯à¨¿¤������+���src/Composer/Downloader/DownloadManager.php4��Lñ‡`4��]n(v¤������/���src/Composer/Downloader/DownloaderInterface.php��Lñ‡`��<ê ¤������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ���Lñ‡`Ñ���&Áœ¿¤������*���src/Composer/Downloader/FileDownloader.php,��Lñ‡`,��Ñòš»¤������/���src/Composer/Downloader/FilesystemException.php
  31. ��Lñ‡`
  32. ��.-‹¤������,���src/Composer/Downloader/FossilDownloader.phpÜ ��Lñ‡`Ü ��fÙ–ì¤������)���src/Composer/Downloader/GitDownloader.php›>��Lñ‡`›>��/@ýå¤������*���src/Composer/Downloader/GzipDownloader.phpÅ��Lñ‡`Å��¡Q[…¤������(���src/Composer/Downloader/HgDownloader.php§ ��Lñ‡`§ ��þ]÷"¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phps���Lñ‡`s���Ù¢ ñ¤������*���src/Composer/Downloader/PathDownloader.phpg��Lñ‡`g��èŽÖð¤������.���src/Composer/Downloader/PerforceDownloader.php ��Lñ‡` ��=Ëw(¤������*���src/Composer/Downloader/PharDownloader.php'��Lñ‡`'��i(¶¤������)���src/Composer/Downloader/RarDownloader.phpû��Lñ‡`û��—gU¤������)���src/Composer/Downloader/SvnDownloader.php"��Lñ‡`"��2¨.¤������)���src/Composer/Downloader/TarDownloader.php%��Lñ‡`%��7³Øm¤������.���src/Composer/Downloader/TransportException.php��Lñ‡`��¥¬ï‰¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ���Lñ‡`Ô���`§ôö¤������)���src/Composer/Downloader/VcsDownloader.php7��Lñ‡`7��³ÌûY¤������(���src/Composer/Downloader/XzDownloader.php3��Lñ‡`3��4ÍYä������)���src/Composer/Downloader/ZipDownloader.phpî��Lñ‡`î��Eý½¤������&���src/Composer/EventDispatcher/Event.php ��Lñ‡` ��±™jï¤������0���src/Composer/EventDispatcher/EventDispatcher.php{0��Lñ‡`{0��‘G¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©���Lñ‡`©���h·0¤������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv���Lñ‡`v���wZ8S¤������9���src/Composer/Exception/IrrecoverableDownloadException.phpv���Lñ‡`v���DM½y¤������)���src/Composer/Exception/NoSslException.phph���Lñ‡`h���ˆdñÓ¤���������src/Composer/Factory.phpÔB��Lñ‡`ÔB��ÑZµ¤���������src/Composer/IO/BaseIO.php ��Lñ‡` ��Ƈa¤���������src/Composer/IO/BufferIO.php¶��Lñ‡`¶��ȼ†¦¤���������src/Composer/IO/ConsoleIO.php¬��Lñ‡`¬��¡ã;N¤���������src/Composer/IO/IOInterface.phpØ��Lñ‡`Ø��Fò°ð¤���������src/Composer/IO/NullIO.phpÀ��Lñ‡`À��F`sʤ������"���src/Composer/InstalledVersions.phpþ��Lñ‡`þ��ʇ�:¤���������src/Composer/Installer.php_x��Lñ‡`_x��à:Ûؤ������*���src/Composer/Installer/BinaryInstaller.php3��Lñ‡`3��šÁ¤������2���src/Composer/Installer/BinaryPresenceInterface.phpË���Lñ‡`Ë���À5š¨¤������.���src/Composer/Installer/InstallationManager.phps3��Lñ‡`s3��<û=)¤������)���src/Composer/Installer/InstallerEvent.phpå��Lñ‡`å��ÎE N¤������*���src/Composer/Installer/InstallerEvents.php…���Lñ‡`…���nÜ<Á¤������-���src/Composer/Installer/InstallerInterface.phpI��Lñ‡`I��µªØ\¤������+���src/Composer/Installer/LibraryInstaller.phpk��Lñ‡`k��¸/ý—¤������/���src/Composer/Installer/MetapackageInstaller.phpÍ��Lñ‡`Í��·p(ù¤������(���src/Composer/Installer/NoopInstaller.php]��Lñ‡`]��Û‰öÓ¤������'���src/Composer/Installer/PackageEvent.php–��Lñ‡`–��=¯³X¤������(���src/Composer/Installer/PackageEvents.php¸��Lñ‡`¸��dbØs¤������*���src/Composer/Installer/PluginInstaller.phpå
  33. ��Lñ‡`å
  34. ��ÿ|gp¤������+���src/Composer/Installer/ProjectInstaller.phpf��Lñ‡`f��ÙÇ“B¤������4���src/Composer/Installer/SuggestedPackagesReporter.php��Lñ‡`��îÐD¤���������src/Composer/Json/JsonFile.php©��Lñ‡`©��AÚ>¤������#���src/Composer/Json/JsonFormatter.phpS��Lñ‡`S��†e¤������%���src/Composer/Json/JsonManipulator.php¸7��Lñ‡`¸7��hy¤������-���src/Composer/Json/JsonValidationException.php\��Lñ‡`\��.Xóܤ������%���src/Composer/Package/AliasPackage.phpè��Lñ‡`è��lÞ½­¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php ��Lñ‡` ��yY+¦¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpæ��Lñ‡`æ��U`Ƥ������0���src/Composer/Package/Archiver/ArchiveManager.php^��Lñ‡`^��?b"7¤������3���src/Composer/Package/Archiver/ArchiverInterface.php��Lñ‡`��ñ´> ¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php~��Lñ‡`~��!Ê p¤������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php��Lñ‡`��‹SZ0¤������2���src/Composer/Package/Archiver/GitExcludeFilter.phpr��Lñ‡`r��3‘Mh¤������1���src/Composer/Package/Archiver/HgExcludeFilter.php
  35. ��Lñ‡`
  36. ��&ðm(¤������.���src/Composer/Package/Archiver/PharArchiver.php8��Lñ‡`8��Fx'M¤������-���src/Composer/Package/Archiver/ZipArchiver.php¤��Lñ‡`¤��!Yò�¤������$���src/Composer/Package/BasePackage.php��Lñ‡`�� `¼ ¤������*���src/Composer/Package/Comparer/Comparer.php©��Lñ‡`©��þí%†¤������(���src/Composer/Package/CompletePackage.php§��Lñ‡`§�� h“¤������1���src/Composer/Package/CompletePackageInterface.php��Lñ‡`��2%ž¤������+���src/Composer/Package/Dumper/ArrayDumper.php ��Lñ‡` ��Ã@Q¤���������src/Composer/Package/Link.phpÝ��Lñ‡`Ý��ÃðÿФ������+���src/Composer/Package/Loader/ArrayLoader.phpñ'��Lñ‡`ñ'��¹•# ¤������7���src/Composer/Package/Loader/InvalidPackageException.phpE��Lñ‡`E��xb¾¤������*���src/Composer/Package/Loader/JsonLoader.php°��Lñ‡`°��Vœ\‹¤������/���src/Composer/Package/Loader/LoaderInterface.php²���Lñ‡`²���¦}úΤ������1���src/Composer/Package/Loader/RootPackageLoader.phpñ��Lñ‡`ñ��9JÛ¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.phpžA��Lñ‡`žA�� _‚ï¤���������src/Composer/Package/Locker.php!%��Lñ‡`!%��ÑÞ¤������ ���src/Composer/Package/Package.php��Lñ‡`��åwQ0¤������)���src/Composer/Package/PackageInterface.php� ��Lñ‡`� ��H^K_¤������)���src/Composer/Package/RootAliasPackage.phpH ��Lñ‡`H ��ëie`¤������$���src/Composer/Package/RootPackage.phpI��Lñ‡`I��q]V¤������-���src/Composer/Package/RootPackageInterface.php¹��Lñ‡`¹��"maV¤������0���src/Composer/Package/Version/StabilityFilter.phpé��Lñ‡`é��Äi— ¤������/���src/Composer/Package/Version/VersionGuesser.php§$��Lñ‡`§$��É"=å¤������.���src/Composer/Package/Version/VersionParser.php��Lñ‡`�� ·s)¤������0���src/Composer/Package/Version/VersionSelector.php‹��Lñ‡`‹��Ó‘úo¤������&���src/Composer/Platform/HhvmDetector.phpñ��Lñ‡`ñ��”\龤������!���src/Composer/Platform/Runtime.phpA��Lñ‡`A��ò¥|¤������!���src/Composer/Platform/Version.php”��Lñ‡`”��÷ða©¤������-���src/Composer/Plugin/Capability/Capability.phpW���Lñ‡`W���æ_¨1¤������2���src/Composer/Plugin/Capability/CommandProvider.php—���Lñ‡`—���ûOâ>¤���������src/Composer/Plugin/Capable.php���Lñ‡`���Æq+¤������$���src/Composer/Plugin/CommandEvent.phpâ��Lñ‡`â��³ÆÇW¤������$���src/Composer/Plugin/PluginEvents.phpe��Lñ‡`e��*U~r¤������'���src/Composer/Plugin/PluginInterface.phpŽ��Lñ‡`Ž���4%~¤������%���src/Composer/Plugin/PluginManager.phpª0��Lñ‡`ª0��gêç]¤������-���src/Composer/Plugin/PostFileDownloadEvent.phpá��Lñ‡`á��M+æ¤������*���src/Composer/Plugin/PreCommandRunEvent.phpõ��Lñ‡`õ��:ðd¤������,���src/Composer/Plugin/PreFileDownloadEvent.phpO��Lñ‡`O��¾­wÀ¤������*���src/Composer/Plugin/PrePoolCreateEvent.phpA��Lñ‡`A��x¼”y¤������4���src/Composer/Question/StrictConfirmationQuestion.php��Lñ‡`��'.³è¤������+���src/Composer/Repository/ArrayRepository.phpæ��Lñ‡`æ��­J—¤������.���src/Composer/Repository/ArtifactRepository.phpó ��Lñ‡`ó ��æ¦í‚¤������.���src/Composer/Repository/ComposerRepository.php=‹��Lñ‡`=‹��…Öd¤������/���src/Composer/Repository/CompositeRepository.phpO ��Lñ‡`O ��¤¾ŸŽ¤������;���src/Composer/Repository/ConfigurableRepositoryInterface.php…���Lñ‡`…���±Ÿ_¤������0���src/Composer/Repository/FilesystemRepository.php_��Lñ‡`_��-ä������,���src/Composer/Repository/FilterRepository.php��Lñ‡`��×y¯¢¤������4���src/Composer/Repository/InstalledArrayRepository.php1��Lñ‡`1��]«×¤������9���src/Composer/Repository/InstalledFilesystemRepository.php1��Lñ‡`1��y&êͤ������/���src/Composer/Repository/InstalledRepository.php¸��Lñ‡`¸��Ëõ¤������8���src/Composer/Repository/InstalledRepositoryInterface.php¥���Lñ‡`¥���Ã%¤������6���src/Composer/Repository/InvalidRepositoryException.phpn���Lñ‡`n���à“똤������/���src/Composer/Repository/LockArrayRepository.php¤���Lñ‡`¤���E™†S¤������-���src/Composer/Repository/PackageRepository.phpÑ��Lñ‡`Ñ��«‰´¤������*���src/Composer/Repository/PathRepository.php(��Lñ‡`(��b2L¤������*���src/Composer/Repository/PearRepository.phpæ���Lñ‡`æ���¤5‘¤������.���src/Composer/Repository/PlatformRepository.phpÂH��Lñ‡`ÂH��õ*!¤������-���src/Composer/Repository/RepositoryFactory.php¥��Lñ‡`¥��»í�N¤������/���src/Composer/Repository/RepositoryInterface.php;��Lñ‡`;�� _‹¤������-���src/Composer/Repository/RepositoryManager.php ��Lñ‡` ��´=x¤������7���src/Composer/Repository/RepositorySecurityException.phpo���Lñ‡`o���pÕ«ª¤������)���src/Composer/Repository/RepositorySet.php¶��Lñ‡`¶��\Oo¤������1���src/Composer/Repository/RootPackageRepository.php@��Lñ‡`@��X¦Ž¤������/���src/Composer/Repository/Vcs/BitbucketDriver.php… ��Lñ‡`… ��Ôðpñ¤������,���src/Composer/Repository/Vcs/FossilDriver.phpn��Lñ‡`n��äyQ ¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpè��Lñ‡`è��8$ë¤������)���src/Composer/Repository/Vcs/GitDriver.phpƒ��Lñ‡`ƒ��M¤~¡¤������,���src/Composer/Repository/Vcs/GitHubDriver.phpï4��Lñ‡`ï4���äw¤������,���src/Composer/Repository/Vcs/GitLabDriver.php +��Lñ‡` +��úIÞ?¤������1���src/Composer/Repository/Vcs/HgBitbucketDriver.phpâ��Lñ‡`â��¾Â`Y¤������(���src/Composer/Repository/Vcs/HgDriver.php��Lñ‡`��Ü„\¤������.���src/Composer/Repository/Vcs/PerforceDriver.php¾ ��Lñ‡`¾ ��ˆáÀ¤������)���src/Composer/Repository/Vcs/SvnDriver.php•��Lñ‡`•��íÕOõ¤������)���src/Composer/Repository/Vcs/VcsDriver.phpd
  37. ��Lñ‡`d
  38. ��=1\Ǥ������2���src/Composer/Repository/Vcs/VcsDriverInterface.php÷��Lñ‡`÷��ÇX[‰¤������)���src/Composer/Repository/VcsRepository.php^2��Lñ‡`^2��¤:®²¤������1���src/Composer/Repository/VersionCacheInterface.php”���Lñ‡`”���A?Rï¤������3���src/Composer/Repository/WritableArrayRepository.phpO��Lñ‡`O��‰Ýê¤������7���src/Composer/Repository/WritableRepositoryInterface.phpS��Lñ‡`S��5CgÓ¤���������src/Composer/Script/Event.phpš��Lñ‡`š��Óô©¤������$���src/Composer/Script/ScriptEvents.phpÜ��Lñ‡`Ü��ÆíÁ¤������ ���src/Composer/SelfUpdate/Keys.phpœ��Lñ‡`œ��zeƒŽ¤������$���src/Composer/SelfUpdate/Versions.php6��Lñ‡`6��0鮤������ ���src/Composer/Util/AuthHelper.php��Lñ‡`��„‰ó]¤���������src/Composer/Util/Bitbucket.phpØ��Lñ‡`Ø��¬5èõ¤������$���src/Composer/Util/ComposerMirror.php±��Lñ‡`±��­½øؤ������%���src/Composer/Util/ConfigValidator.php1��Lñ‡`1��È ¤������"���src/Composer/Util/ErrorHandler.phpº��Lñ‡`º��ª¤������ ���src/Composer/Util/Filesystem.php•3��Lñ‡`•3��Ó,å¤���������src/Composer/Util/Git.phpÃ0��Lñ‡`Ã0�� »oZ¤���������src/Composer/Util/GitHub.phpU ��Lñ‡`U ��½Qjø¤���������src/Composer/Util/GitLab.phpq��Lñ‡`q��$͆¤���������src/Composer/Util/Hg.phpô��Lñ‡`ô��æégŽ¤������)���src/Composer/Util/Http/CurlDownloader.phpG?��Lñ‡`G?��¸Šù�¤������'���src/Composer/Util/Http/CurlResponse.php]��Lñ‡`]��Dæñ@¤������&���src/Composer/Util/Http/ProxyHelper.php9
  39. ��Lñ‡`9
  40. ��´·]¤������'���src/Composer/Util/Http/ProxyManager.phpŠ
  41. ��Lñ‡`Š
  42. �� â¤������'���src/Composer/Util/Http/RequestProxy.php��Lñ‡`��üA8¤������#���src/Composer/Util/Http/Response.php!��Lñ‡`!��ö˜„Ò¤������$���src/Composer/Util/HttpDownloader.phpé%��Lñ‡`é%��h Rè¤���������src/Composer/Util/IniHelper.phph��Lñ‡`h��;FP¤���������src/Composer/Util/Loop.php˜��Lñ‡`˜��IyþŒ¤������&���src/Composer/Util/MetadataMinifier.php*��Lñ‡`*��hÛ/~¤������$���src/Composer/Util/NoProxyPattern.phpt��Lñ‡`t��¨­6¯¤������#���src/Composer/Util/PackageSorter.phpø��Lñ‡`ø��Oê♤���������src/Composer/Util/Perforce.php\2��Lñ‡`\2��.ÞÑõ¤���������src/Composer/Util/Platform.php�
  43. ��Lñ‡`�
  44. ��c¤������%���src/Composer/Util/ProcessExecutor.phpˆ��Lñ‡`ˆ��k¶1¤������&���src/Composer/Util/RemoteFilesystem.phprM��Lñ‡`rM��É—n‘¤���������src/Composer/Util/Silencer.phpè��Lñ‡`è��¿5ѳ¤������*���src/Composer/Util/StreamContextFactory.php¨��Lñ‡`¨��lçë¤���������src/Composer/Util/Svn.php$��Lñ‡`$��0’Hì¤������ ���src/Composer/Util/SyncHelper.phpE��Lñ‡`E��åá‰Ç¤���������src/Composer/Util/Tar.phpb��Lñ‡`b��å]–¤���������src/Composer/Util/TlsHelper.phpH
  45. ��Lñ‡`H
  46. ��ÌÚ¤���������src/Composer/Util/Url.php ��Lñ‡` ��qX¤���������src/Composer/Util/Zip.php&��Lñ‡`&��Ì>vT¤���������src/bootstrap.php¹��Lñ‡`¹��I}œ¤������%���src/Composer/Autoload/ClassLoader.php8��Lñ‡`8��l=ú-¤������#���res/composer-repository-schema.jsonñ��Lñ‡`ñ��|0à„¤���������res/composer-schema.jsonÿª��Lñ‡`ÿª��Ûp…¤���������vendor/autoload.php‚���Lñ‡`‚���),�>¤���������vendor/composer/ClassLoader.phpó��Lñ‡`ó��3ç7¤������%���vendor/composer/InstalledVersions.php ��Lñ‡` ��Ä´ð¤������%���vendor/composer/autoload_classmap.phpµ���Lñ‡`µ���x’ý»¤������"���vendor/composer/autoload_files.phpŒ��Lñ‡`Œ��� ¤������'���vendor/composer/autoload_namespaces.php¢���Lñ‡`¢����R7c¤������!���vendor/composer/autoload_psr4.phpP��Lñ‡`P��à¢åU¤������!���vendor/composer/autoload_real.phpc��Lñ‡`c��c"¢k¤������#���vendor/composer/autoload_static.phpG ��Lñ‡`G ��¡Öͤ������!���vendor/composer/ca-bundle/LICENSE��Lñ‡`��G _¤������(���vendor/composer/ca-bundle/res/cacert.pemê`�Lñ‡`ê`�­3 ¤������*���vendor/composer/ca-bundle/src/CaBundle.phpg��Lñ‡`g��Axð�¤���������vendor/composer/installed.php. ��Lñ‡`. ��0
  47. µ¤������)���vendor/composer/metadata-minifier/LICENSE��Lñ‡`��½£ëǤ������:���vendor/composer/metadata-minifier/src/MetadataMinifier.phpÐ��Lñ‡`Ð��Â0&À¤���������vendor/composer/semver/LICENSE��Lñ‡`��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��Lñ‡`��^ÝŠ’¤������/���vendor/composer/semver/src/CompilingMatcher.phpo��Lñ‡`o��Æ7L§¤������/���vendor/composer/semver/src/Constraint/Bound.phpq��Lñ‡`q�� �]¤������4���vendor/composer/semver/src/Constraint/Constraint.phpb��Lñ‡`b��¡ó�w¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php˜��Lñ‡`˜��œ?[¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php§��Lñ‡`§��ÃÛé¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÁ��Lñ‡`Á��ê´ �¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.php ��Lñ‡` ��’Q\ä������'���vendor/composer/semver/src/Interval.phpæ��Lñ‡`æ��=[i¤������(���vendor/composer/semver/src/Intervals.phpÓ+��Lñ‡`Ó+��7ؤ������%���vendor/composer/semver/src/Semver.phpù��Lñ‡`ù��á-i¤������,���vendor/composer/semver/src/VersionParser.php—+��Lñ‡`—+��=
  48. �‚¤������%���vendor/composer/spdx-licenses/LICENSE��Lñ‡`��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��Lñ‡`¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.jsonu°��Lñ‡`u°��›ý…T¤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.phpH��Lñ‡`H��͉T¤������&���vendor/composer/xdebug-handler/LICENSE+��Lñ‡`+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php´��Lñ‡`´��*D’�¤������.���vendor/composer/xdebug-handler/src/Process.phpk ��Lñ‡`k ��ŽUÿߤ������-���vendor/composer/xdebug-handler/src/Status.php
  49. ��Lñ‡`
  50. ��$Ÿv-¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.php‡%��Lñ‡`‡%��¾L3¤������(���vendor/justinrainbow/json-schema/LICENSE"��Lñ‡`"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��Lñ‡`¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpƒ
  51. ��Lñ‡`ƒ
  52. ��ž¸=š¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php§ ��Lñ‡`§ ��›Vؤ������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��Lñ‡`¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php\��Lñ‡`\��_}ý¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpà ��Lñ‡`à ��ë’_”¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps��Lñ‡`s��d Þ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpƒ ��Lñ‡`ƒ ��e� ¨¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php·��Lñ‡`·��%l¬ö¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php& ��Lñ‡`& ��78÷¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.phpz��Lñ‡`z��ùfÅ~¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��Lñ‡`a�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��Lñ‡`—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��Lñ‡`‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php��Lñ‡`��ª%}¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php,"��Lñ‡`,"��‰-¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��Lñ‡`è��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���Lñ‡`I���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���Lñ‡`•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���Lñ‡`l���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���Lñ‡`l���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���Lñ‡`u���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���Lñ‡`w���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��Lñ‡`Þ��\¸
  53. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���Lñ‡`o���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���Lñ‡`…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���Lñ‡`€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���Lñ‡`j���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���Lñ‡`f���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��Lñ‡`þ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��Lñ‡` ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php“ ��Lñ‡`“ ��&zß^¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��Lñ‡`��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���Lñ‡`á���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php£��Lñ‡`£��Ç’ô¦¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php ��Lñ‡` ��£Á¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��Lñ‡`,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���Lñ‡`®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��Lñ‡` ��æP¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php@��Lñ‡`@��5Î3¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���Lñ‡`ƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���Lñ‡`…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phps��Lñ‡`s��ßÁ‘#¤���������vendor/psr/log/LICENSE?��Lñ‡`?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��Lñ‡`;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���Lñ‡``��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���Lñ‡`û���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���Lñ‡`|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���Lñ‡`§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��Lñ‡`È��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��Lñ‡`k��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ���Lñ‡`Ÿ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���Lñ‡`p���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��Lñ‡` ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��Lñ‡`<��þ(åI¤���������vendor/react/promise/LICENSE'��Lñ‡`'��¶-º„¤������F���vendor/react/promise/src/React/Promise/CancellablePromiseInterface.php����Lñ‡`���� ƒ<�¤������3���vendor/react/promise/src/React/Promise/Deferred.phpð ��Lñ‡`ð ��o(ퟤ������:���vendor/react/promise/src/React/Promise/DeferredPromise.phpÇ��Lñ‡`Ç��º`W¤������;���vendor/react/promise/src/React/Promise/DeferredResolver.phpÃ��Lñ‡`Ã��7Ëu¤������;���vendor/react/promise/src/React/Promise/FulfilledPromise.phpÍ��Lñ‡`Í��´–U¤������6���vendor/react/promise/src/React/Promise/LazyPromise.php��Lñ‡`��Š»¤������2���vendor/react/promise/src/React/Promise/Promise.php��Lñ‡`��º6Jµ¤������;���vendor/react/promise/src/React/Promise/PromiseInterface.phpŸ���Lñ‡`Ÿ��� ½¨n¤������<���vendor/react/promise/src/React/Promise/PromisorInterface.php\���Lñ‡`\���Wèêà¤������:���vendor/react/promise/src/React/Promise/RejectedPromise.php¾��Lñ‡`¾��fC¿¤������<���vendor/react/promise/src/React/Promise/ResolverInterface.php¼���Lñ‡`¼���û �O¤������/���vendor/react/promise/src/React/Promise/Util.phpè���Lñ‡`è���Ëý$:¤������/���vendor/react/promise/src/React/Promise/When.phpÇ��Lñ‡`Ç��¤o¤������4���vendor/react/promise/src/React/Promise/functions.phpÐ ��Lñ‡`Ð ��!³O¤������<���vendor/react/promise/src/React/Promise/functions_include.php\���Lñ‡`\���1…‰^¤���������vendor/seld/jsonlint/LICENSE$��Lñ‡`$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.phpk��Lñ‡`k��Zù¶Ã¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php62��Lñ‡`62��28ˤ������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php#��Lñ‡`#��Úá@,¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php%��Lñ‡`%��`a„|¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���Lñ‡`>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��Lñ‡`$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpÍ��Lñ‡`Í��H:›¤������)���vendor/seld/phar-utils/src/Timestamps.phpœ ��Lñ‡`œ ��kL€¤������&���vendor/symfony/console/Application.php+X��Lñ‡`+X��«­yX¤������*���vendor/symfony/console/Command/Command.phpä"��Lñ‡`ä"���¤Ê¤������.���vendor/symfony/console/Command/HelpCommand.phpØ��Lñ‡`Ø��¦Ú-:¤������.���vendor/symfony/console/Command/ListCommand.phpZ��Lñ‡`Z��»w`¤������(���vendor/symfony/console/ConsoleEvents.phpé���Lñ‡`é���RÛÔe¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÏ��Lñ‡`Ï��<ŽUî¤������0���vendor/symfony/console/Descriptor/Descriptor.php���Lñ‡`���¿N•¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü���Lñ‡`ü���±Qµ¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ��Lñ‡`Ü ��*û�ɤ������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶��Lñ‡`¶��·Ô;ݤ������4���vendor/symfony/console/Descriptor/TextDescriptor.php·��Lñ‡`·��c“q€¤������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��Lñ‡`��b{<¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°��Lñ‡`°��!�Ȥ������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ��Lñ‡`Å��ÒxÛ\¤������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php��Lñ‡`��á2é¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz��Lñ‡`z��³,îL¤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ��Lñ‡`Ô��È÷ L¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpf���Lñ‡`f���¡ABª¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���Lñ‡`¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���Lñ‡`¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���Lñ‡`’���ÍO\e¤������5���vendor/symfony/console/Exception/RuntimeException.php–���Lñ‡`–���Ùí,6¤������4���vendor/symfony/console/Formatter/OutputFormatter.php3��Lñ‡`3��àפ������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ��Lñ‡`Œ��òññÀ¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF��Lñ‡`F��𦴤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„��Lñ‡`„��÷½G¤������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@��Lñ‡`@��G¨ýU¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy��Lñ‡`y��Ì8ÆФ������2���vendor/symfony/console/Helper/DescriptorHelper.phpw��Lñ‡`w��|¦C¤������.���vendor/symfony/console/Helper/DialogHelper.phpð��Lñ‡`ð��ÔÈ7¤������1���vendor/symfony/console/Helper/FormatterHelper.phpd��Lñ‡`d��§×,¸¤������(���vendor/symfony/console/Helper/Helper.php©��Lñ‡`©��Õ'ƒ±¤������1���vendor/symfony/console/Helper/HelperInterface.phpå���Lñ‡`å���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpÊ��Lñ‡`Ê��áÏW"¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��Lñ‡`c��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ��Lñ‡`Ó ��©w‚R¤������-���vendor/symfony/console/Helper/ProgressBar.phpc%��Lñ‡`c%��C&w¤������0���vendor/symfony/console/Helper/ProgressHelper.phpY��Lñ‡`Y��R!�/¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpM��Lñ‡`M��ü�‡¤������0���vendor/symfony/console/Helper/QuestionHelper.php[��Lñ‡`[��¯6}ñ¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php•
  54. ��Lñ‡`•
  55. ���]~R¤������'���vendor/symfony/console/Helper/Table.php¼*��Lñ‡`¼*��fêý!¤������+���vendor/symfony/console/Helper/TableCell.php€��Lñ‡`€��‹ƒ[¤������-���vendor/symfony/console/Helper/TableHelper.php ��Lñ‡` ��›uô™¤������0���vendor/symfony/console/Helper/TableSeparator.phpÊ���Lñ‡`Ê���az¤������,���vendor/symfony/console/Helper/TableStyle.php
  56. ��Lñ‡`
  57. ��_ÍI"¤������*���vendor/symfony/console/Input/ArgvInput.php��Lñ‡`��ªèB-¤������+���vendor/symfony/console/Input/ArrayInput.php) ��Lñ‡`) ��¥ÑC¤������&���vendor/symfony/console/Input/Input.php£ ��Lñ‡`£ ��f¡?¤������.���vendor/symfony/console/Input/InputArgument.php��Lñ‡`��D £¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���Lñ‡`˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php†��Lñ‡`†��¤U)¤¤������/���vendor/symfony/console/Input/InputInterface.php£��Lñ‡`£��ÆBŒ'¤������,���vendor/symfony/console/Input/InputOption.php ��Lñ‡` ��\¢Ü=¤������,���vendor/symfony/console/Input/StringInput.php™��Lñ‡`™��{Šœþ¤���������vendor/symfony/console/LICENSE+��Lñ‡`+��²‹ g¤������/���vendor/symfony/console/Logger/ConsoleLogger.php- ��Lñ‡`- ��ghT›¤������0���vendor/symfony/console/Output/BufferedOutput.php_��Lñ‡`_��‹ >P¤������/���vendor/symfony/console/Output/ConsoleOutput.php±��Lñ‡`±��nì!f¤������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà���Lñ‡`à���‡†Æʤ������,���vendor/symfony/console/Output/NullOutput.phpÉ��Lñ‡`É��™0ïf¤������(���vendor/symfony/console/Output/Output.php˜ ��Lñ‡`˜ ��0p¤������1���vendor/symfony/console/Output/OutputInterface.php��Lñ‡`���ì&¤������.���vendor/symfony/console/Output/StreamOutput.php›��Lñ‡`›��.¡îî¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpv
  58. ��Lñ‡`v
  59. ��‹²WP¤������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè��Lñ‡`è��/Ô�¤������,���vendor/symfony/console/Question/Question.phpÎ ��Lñ‡`Î ��lF¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��Lñ‡`�$��•�¥v¤������ ���vendor/symfony/console/Shell.phpã��Lñ‡`ã��‰ÁŽå¤������,���vendor/symfony/console/Style/OutputStyle.php\��Lñ‡`\��wפ¤������/���vendor/symfony/console/Style/StyleInterface.phpÏ��Lñ‡`Ï��&nÅѤ������-���vendor/symfony/console/Style/SymfonyStyle.phpÛ��Lñ‡`Û��§ðcä¤������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ��Lñ‡`Ï��sž9i¤������/���vendor/symfony/console/Tester/CommandTester.php¨��Lñ‡`¨��<œ•¤������(���vendor/symfony/debug/BufferingLogger.phpt��Lñ‡`t��=�hܤ���������vendor/symfony/debug/Debug.php+��Lñ‡`+��.À=©¤������)���vendor/symfony/debug/DebugClassLoader.php°��Lñ‡`°��^æ*ñ¤������%���vendor/symfony/debug/ErrorHandler.phpýG��Lñ‡`ýG��¿zL¤������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–��Lñ‡`–��i‰æô¤������8���vendor/symfony/debug/Exception/ContextErrorException.php˜��Lñ‡`˜��-
  60. d2¤������1���vendor/symfony/debug/Exception/DummyException.php��Lñ‡`��®+Ãê¤������6���vendor/symfony/debug/Exception/FatalErrorException.php ��Lñ‡` ��4ç$¤¤������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW��Lñ‡`W��?àèK¤������3���vendor/symfony/debug/Exception/FlattenException.php»��Lñ‡`»��+a&¤������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~���Lñ‡`~���ë¨oâ¤������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš��Lñ‡`š���ñJÀ¤������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜��Lñ‡`˜��nöêؤ������)���vendor/symfony/debug/ExceptionHandler.php$3��Lñ‡`$3��Eë×£¤������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php5��Lñ‡`5��ŠÁ*V¤������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php��Lñ‡`��ĹBV¤������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx��Lñ‡`x��~ò"¤������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpN��Lñ‡`N��'€³ˆ¤���������vendor/symfony/debug/LICENSE+��Lñ‡`+��²‹ g¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi���Lñ‡`i���$ ÿ›¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼��Lñ‡`¼��pí\¶¤������3���vendor/symfony/filesystem/Exception/IOException.php‡��Lñ‡`‡��€ü#Ѥ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���Lñ‡`¦���jÙwM¤������(���vendor/symfony/filesystem/Filesystem.phpM4��Lñ‡`M4��ãz_¤������!���vendor/symfony/filesystem/LICENSE+��Lñ‡`+��²‹ g¤������)���vendor/symfony/filesystem/LockHandler.phpò��Lñ‡`ò��~3ŸZ¤������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ��Lñ‡`\ ��hˆB¤������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.phpƒ��Lñ‡`ƒ��kM Þ¤������2���vendor/symfony/finder/Adapter/AdapterInterface.php›��Lñ‡`›��Mþ¤������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php2��Lñ‡`2��ƒ€D)¤������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php��Lñ‡`��¦äàO¤������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô��Lñ‡`ô��Þdè;¤������/���vendor/symfony/finder/Comparator/Comparator.php���Lñ‡`���¾üœµ¤������3���vendor/symfony/finder/Comparator/DateComparator.php#��Lñ‡`#��°Τ������5���vendor/symfony/finder/Comparator/NumberComparator.php{��Lñ‡`{��€ÚùY¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���Lñ‡`„���½¾sœ¤������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬��Lñ‡`¬��wR¤������6���vendor/symfony/finder/Exception/ExceptionInterface.php„���Lñ‡`„���Gz-¤������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)��Lñ‡`)��x§e¤������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº��Lñ‡`º��˜þ˜¤������/���vendor/symfony/finder/Expression/Expression.php��Lñ‡`��i¥:Ť������)���vendor/symfony/finder/Expression/Glob.phpf��Lñ‡`f��DÞcj¤������*���vendor/symfony/finder/Expression/Regex.php��Lñ‡`��§;M)¤������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ��Lñ‡`Í��\p4†¤������ ���vendor/symfony/finder/Finder.phpc.��Lñ‡`c.��:ˆ5g¤���������vendor/symfony/finder/Glob.phpL��Lñ‡`L��jÍ9פ������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]��Lñ‡`]��ÎoÅƤ������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx��Lñ‡`x��ôP¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî��Lñ‡`î��üÍ�q¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí��Lñ‡`í��nõH¤������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#��Lñ‡`#��G?T½¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ��Lñ‡`Z��(&ø¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5��Lñ‡`5��ší¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr��Lñ‡`r��tu¤������1���vendor/symfony/finder/Iterator/FilterIterator.phpÂ��Lñ‡`Â���㯤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php*��Lñ‡`*��Œž�¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ��Lñ‡`Ð��‚c¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ��Lñ‡` ��O}Cä¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe��Lñ‡`e��Ÿ’áé¤������3���vendor/symfony/finder/Iterator/SortableIterator.php+��Lñ‡`+��õÝË ¤���������vendor/symfony/finder/LICENSE+��Lñ‡`+��²‹ g¤������'���vendor/symfony/finder/Shell/Command.php> ��Lñ‡`> ��_~u ¤������%���vendor/symfony/finder/Shell/Shell.phpq��Lñ‡`q��·ÓŠ0¤������%���vendor/symfony/finder/SplFileInfo.php��Lñ‡`��þ�íù¤������'���vendor/symfony/polyfill-ctype/Ctype.phpH ��Lñ‡`H ��³�Õݤ������%���vendor/symfony/polyfill-ctype/LICENSE+��Lñ‡`+��…»E:¤������+���vendor/symfony/polyfill-ctype/bootstrap.phpú��Lñ‡`ú��|p:¤������(���vendor/symfony/polyfill-mbstring/LICENSE+��Lñ‡`+��øÛ{¤������-���vendor/symfony/polyfill-mbstring/Mbstring.php~G��Lñ‡`~G��úì¡T¤������D���vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8Ë��Lñ‡`Ë��Ú�.‚¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷T��Lñ‡`÷T��ß2ª?¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��Lñ‡`ã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpîU��Lñ‡`îU��`þ8Q¤������.���vendor/symfony/polyfill-mbstring/bootstrap.php��Lñ‡`��þJ¾¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpf���Lñ‡`f���]ö>T¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���Lñ‡`¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���Lñ‡`”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��Lñ‡`x��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php��Lñ‡`��﫤������5���vendor/symfony/process/Exception/RuntimeException.php˜���Lñ‡`˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.phpœ��Lñ‡`œ��çÁ̤���������vendor/symfony/process/LICENSE+��Lñ‡`+��²‹ g¤������.���vendor/symfony/process/PhpExecutableFinder.phpÍ��Lñ‡`Í��í0ã¤������%���vendor/symfony/process/PhpProcess.phpù��Lñ‡`ù��c¶ßĤ������.���vendor/symfony/process/Pipes/AbstractPipes.php¸��Lñ‡`¸��xÓ,§¤������/���vendor/symfony/process/Pipes/PipesInterface.phpD��Lñ‡`D��vØ������*���vendor/symfony/process/Pipes/UnixPipes.php7��Lñ‡`7��bÜp„¤������-���vendor/symfony/process/Pipes/WindowsPipes.phpi ��Lñ‡`i ��Ó
  61.  Ä¤������"���vendor/symfony/process/Process.php R��Lñ‡` R��×Ó¥¹¤������)���vendor/symfony/process/ProcessBuilder.phpá
  62. ��Lñ‡`á
  63. ��ñ6I•¤������'���vendor/symfony/process/ProcessUtils.phpJ��Lñ‡`J��{ñC¤������ ���bin/composer8��Lñ‡`8��³âéñ¤���������LICENSE.��Lñ‡`.�� Õ¤������<?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->updateDependencies($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 updateDependencies($output)
  4601. {
  4602. try {
  4603. $updateCommand = $this->getApplication()->find('update');
  4604. $this->getApplication()->resetComposer();
  4605. $updateCommand->run(new ArrayInput(array()), $output);
  4606. } catch (\Exception $e) {
  4607. $this->getIO()->writeError('Could not update dependencies. Run `composer update` to see more information.');
  4608. }
  4609. }
  4610. private function hasDependencies($options)
  4611. {
  4612. $requires = (array) $options['require'];
  4613. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  4614. return !empty($requires) || !empty($devRequires);
  4615. }
  4616. }
  4617. <?php
  4618. namespace Composer\Command;
  4619. use Composer\Installer;
  4620. use Composer\Plugin\CommandEvent;
  4621. use Composer\Plugin\PluginEvents;
  4622. use Composer\Util\HttpDownloader;
  4623. use Symfony\Component\Console\Input\InputInterface;
  4624. use Symfony\Component\Console\Input\InputOption;
  4625. use Symfony\Component\Console\Input\InputArgument;
  4626. use Symfony\Component\Console\Output\OutputInterface;
  4627. class InstallCommand extends BaseCommand
  4628. {
  4629. protected function configure()
  4630. {
  4631. $this
  4632. ->setName('install')
  4633. ->setAliases(array('i'))
  4634. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  4635. ->setDefinition(array(
  4636. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4637. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  4638. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4639. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4640. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  4641. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4642. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  4643. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4644. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4645. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  4646. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  4647. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4648. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4649. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4650. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4651. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4652. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4653. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  4654. ))
  4655. ->setHelp(
  4656. <<<EOT
  4657. The <info>install</info> command reads the composer.lock file from
  4658. the current directory, processes it, and downloads and installs all the
  4659. libraries and dependencies outlined in that file. If the file does not
  4660. exist it will look for composer.json and do the same.
  4661. <info>php composer.phar install</info>
  4662. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  4663. EOT
  4664. )
  4665. ;
  4666. }
  4667. protected function execute(InputInterface $input, OutputInterface $output)
  4668. {
  4669. $io = $this->getIO();
  4670. if ($input->getOption('dev')) {
  4671. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  4672. }
  4673. if ($input->getOption('no-suggest')) {
  4674. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  4675. }
  4676. if ($args = $input->getArgument('packages')) {
  4677. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  4678. return 1;
  4679. }
  4680. if ($input->getOption('no-install')) {
  4681. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  4682. return 1;
  4683. }
  4684. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4685. if ((!$composer->getLocker() || !$composer->getLocker()->isLocked()) && !HttpDownloader::isCurlEnabled()) {
  4686. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  4687. }
  4688. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  4689. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4690. $install = Installer::create($io, $composer);
  4691. $config = $composer->getConfig();
  4692. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  4693. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  4694. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4695. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  4696. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  4697. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4698. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  4699. $install
  4700. ->setDryRun($input->getOption('dry-run'))
  4701. ->setVerbose($input->getOption('verbose'))
  4702. ->setPreferSource($preferSource)
  4703. ->setPreferDist($preferDist)
  4704. ->setDevMode(!$input->getOption('no-dev'))
  4705. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  4706. ->setRunScripts(!$input->getOption('no-scripts'))
  4707. ->setOptimizeAutoloader($optimize)
  4708. ->setClassMapAuthoritative($authoritative)
  4709. ->setApcuAutoloader($apcu, $apcuPrefix)
  4710. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  4711. ;
  4712. if ($input->getOption('no-plugins')) {
  4713. $install->disablePlugins();
  4714. }
  4715. return $install->run();
  4716. }
  4717. }
  4718. <?php
  4719. namespace Composer\Command;
  4720. use Composer\Json\JsonFile;
  4721. use Composer\Plugin\CommandEvent;
  4722. use Composer\Plugin\PluginEvents;
  4723. use Composer\Package\PackageInterface;
  4724. use Composer\Repository\RepositoryInterface;
  4725. use Symfony\Component\Console\Helper\Table;
  4726. use Symfony\Component\Console\Input\InputInterface;
  4727. use Symfony\Component\Console\Input\InputOption;
  4728. use Symfony\Component\Console\Output\OutputInterface;
  4729. use Symfony\Component\Console\Style\SymfonyStyle;
  4730. class LicensesCommand extends BaseCommand
  4731. {
  4732. protected function configure()
  4733. {
  4734. $this
  4735. ->setName('licenses')
  4736. ->setDescription('Shows information about licenses of dependencies.')
  4737. ->setDefinition(array(
  4738. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  4739. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4740. ))
  4741. ->setHelp(
  4742. <<<EOT
  4743. The license command displays detailed information about the licenses of
  4744. the installed dependencies.
  4745. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  4746. EOT
  4747. )
  4748. ;
  4749. }
  4750. protected function execute(InputInterface $input, OutputInterface $output)
  4751. {
  4752. $composer = $this->getComposer();
  4753. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  4754. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4755. $root = $composer->getPackage();
  4756. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4757. if ($input->getOption('no-dev')) {
  4758. $packages = $this->filterRequiredPackages($repo, $root);
  4759. } else {
  4760. $packages = $this->appendPackages($repo->getPackages(), array());
  4761. }
  4762. ksort($packages);
  4763. $io = $this->getIO();
  4764. switch ($format = $input->getOption('format')) {
  4765. case 'text':
  4766. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  4767. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  4768. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  4769. $io->write('Dependencies:');
  4770. $io->write('');
  4771. $table = new Table($output);
  4772. $table->setStyle('compact');
  4773. $tableStyle = $table->getStyle();
  4774. if (method_exists($tableStyle, 'setVerticalBorderChars')) {
  4775. $tableStyle->setVerticalBorderChars('');
  4776. } else {
  4777. $tableStyle->setVerticalBorderChar('');
  4778. }
  4779. $tableStyle->setCellRowContentFormat('%s ');
  4780. $table->setHeaders(array('Name', 'Version', 'License'));
  4781. foreach ($packages as $package) {
  4782. $table->addRow(array(
  4783. $package->getPrettyName(),
  4784. $package->getFullPrettyVersion(),
  4785. implode(', ', $package->getLicense()) ?: 'none',
  4786. ));
  4787. }
  4788. $table->render();
  4789. break;
  4790. case 'json':
  4791. $dependencies = array();
  4792. foreach ($packages as $package) {
  4793. $dependencies[$package->getPrettyName()] = array(
  4794. 'version' => $package->getFullPrettyVersion(),
  4795. 'license' => $package->getLicense(),
  4796. );
  4797. }
  4798. $io->write(JsonFile::encode(array(
  4799. 'name' => $root->getPrettyName(),
  4800. 'version' => $root->getFullPrettyVersion(),
  4801. 'license' => $root->getLicense(),
  4802. 'dependencies' => $dependencies,
  4803. )));
  4804. break;
  4805. case 'summary':
  4806. $usedLicenses = array();
  4807. foreach ($packages as $package) {
  4808. $license = $package->getLicense();
  4809. $licenseName = $license[0];
  4810. if (!isset($usedLicenses[$licenseName])) {
  4811. $usedLicenses[$licenseName] = 0;
  4812. }
  4813. $usedLicenses[$licenseName]++;
  4814. }
  4815. arsort($usedLicenses, SORT_NUMERIC);
  4816. $rows = array();
  4817. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  4818. $rows[] = array($usedLicense, $numberOfDependencies);
  4819. }
  4820. $symfonyIo = new SymfonyStyle($input, $output);
  4821. $symfonyIo->table(
  4822. array('License', 'Number of dependencies'),
  4823. $rows
  4824. );
  4825. break;
  4826. default:
  4827. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4828. }
  4829. return 0;
  4830. }
  4831. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  4832. {
  4833. $requires = array_keys($package->getRequires());
  4834. $packageListNames = array_keys($bucket);
  4835. $packages = array_filter(
  4836. $repo->getPackages(),
  4837. function ($package) use ($requires, $packageListNames) {
  4838. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  4839. }
  4840. );
  4841. $bucket = $this->appendPackages($packages, $bucket);
  4842. foreach ($packages as $package) {
  4843. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  4844. }
  4845. return $bucket;
  4846. }
  4847. public function appendPackages(array $packages, array $bucket)
  4848. {
  4849. foreach ($packages as $package) {
  4850. $bucket[$package->getName()] = $package;
  4851. }
  4852. return $bucket;
  4853. }
  4854. }
  4855. <?php
  4856. namespace Composer\Command;
  4857. use Symfony\Component\Console\Input\InputInterface;
  4858. use Symfony\Component\Console\Input\InputArgument;
  4859. use Symfony\Component\Console\Input\ArrayInput;
  4860. use Symfony\Component\Console\Input\InputOption;
  4861. use Symfony\Component\Console\Output\OutputInterface;
  4862. class OutdatedCommand extends ShowCommand
  4863. {
  4864. protected function configure()
  4865. {
  4866. $this
  4867. ->setName('outdated')
  4868. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  4869. ->setDefinition(array(
  4870. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  4871. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  4872. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  4873. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  4874. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  4875. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  4876. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  4877. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4878. 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.'),
  4879. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4880. ))
  4881. ->setHelp(
  4882. <<<EOT
  4883. The outdated command is just a proxy for `composer show -l`
  4884. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  4885. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  4886. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  4887. compatibility breaks according to semver, so upgrade when you can but it
  4888. may involve work.
  4889. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  4890. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  4891. EOT
  4892. )
  4893. ;
  4894. }
  4895. protected function execute(InputInterface $input, OutputInterface $output)
  4896. {
  4897. $args = array(
  4898. 'command' => 'show',
  4899. '--latest' => true,
  4900. );
  4901. if (!$input->getOption('all')) {
  4902. $args['--outdated'] = true;
  4903. }
  4904. if ($input->getOption('direct')) {
  4905. $args['--direct'] = true;
  4906. }
  4907. if ($input->getArgument('package')) {
  4908. $args['package'] = $input->getArgument('package');
  4909. }
  4910. if ($input->getOption('strict')) {
  4911. $args['--strict'] = true;
  4912. }
  4913. if ($input->getOption('minor-only')) {
  4914. $args['--minor-only'] = true;
  4915. }
  4916. if ($input->getOption('locked')) {
  4917. $args['--locked'] = true;
  4918. }
  4919. if ($input->getOption('no-dev')) {
  4920. $args['--no-dev'] = true;
  4921. }
  4922. $args['--format'] = $input->getOption('format');
  4923. $args['--ignore'] = $input->getOption('ignore');
  4924. $input = new ArrayInput($args);
  4925. return $this->getApplication()->run($input, $output);
  4926. }
  4927. public function isProxyCommand()
  4928. {
  4929. return true;
  4930. }
  4931. }
  4932. <?php
  4933. namespace Composer\Command;
  4934. use Symfony\Component\Console\Input\InputInterface;
  4935. use Symfony\Component\Console\Output\OutputInterface;
  4936. class ProhibitsCommand extends BaseDependencyCommand
  4937. {
  4938. protected function configure()
  4939. {
  4940. parent::configure();
  4941. $this
  4942. ->setName('prohibits')
  4943. ->setAliases(array('why-not'))
  4944. ->setDescription('Shows which packages prevent the given package from being installed.')
  4945. ->setHelp(
  4946. <<<EOT
  4947. Displays detailed information about why a package cannot be installed.
  4948. <info>php composer.phar prohibits composer/composer</info>
  4949. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  4950. EOT
  4951. )
  4952. ;
  4953. }
  4954. protected function execute(InputInterface $input, OutputInterface $output)
  4955. {
  4956. return parent::doExecute($input, $output, true);
  4957. }
  4958. }
  4959. <?php
  4960. namespace Composer\Command;
  4961. use Composer\Config\JsonConfigSource;
  4962. use Composer\DependencyResolver\Request;
  4963. use Composer\Installer;
  4964. use Composer\Plugin\CommandEvent;
  4965. use Composer\Plugin\PluginEvents;
  4966. use Composer\Json\JsonFile;
  4967. use Composer\Factory;
  4968. use Symfony\Component\Console\Input\InputInterface;
  4969. use Symfony\Component\Console\Input\InputOption;
  4970. use Symfony\Component\Console\Input\InputArgument;
  4971. use Symfony\Component\Console\Output\OutputInterface;
  4972. use Composer\Package\BasePackage;
  4973. class RemoveCommand extends BaseCommand
  4974. {
  4975. protected function configure()
  4976. {
  4977. $this
  4978. ->setName('remove')
  4979. ->setDescription('Removes a package from the require or require-dev.')
  4980. ->setDefinition(array(
  4981. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  4982. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  4983. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4984. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4985. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  4986. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  4987. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4988. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  4989. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  4990. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  4991. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  4992. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  4993. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  4994. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4995. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4996. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4997. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4998. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4999. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5000. ))
  5001. ->setHelp(
  5002. <<<EOT
  5003. The <info>remove</info> command removes a package from the current
  5004. list of installed packages
  5005. <info>php composer.phar remove</info>
  5006. Read more at https://getcomposer.org/doc/03-cli.md#remove
  5007. EOT
  5008. )
  5009. ;
  5010. }
  5011. protected function interact(InputInterface $input, OutputInterface $output)
  5012. {
  5013. if ($input->getOption('unused')) {
  5014. $composer = $this->getComposer();
  5015. $locker = $composer->getLocker();
  5016. if (!$locker->isLocked()) {
  5017. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  5018. }
  5019. $lockedPackages = $locker->getLockedRepository()->getPackages();
  5020. $required = array();
  5021. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  5022. $required[$link->getTarget()] = true;
  5023. }
  5024. do {
  5025. $found = false;
  5026. foreach ($lockedPackages as $index => $package) {
  5027. foreach ($package->getNames() as $name) {
  5028. if (isset($required[$name])) {
  5029. foreach ($package->getRequires() as $link) {
  5030. $required[$link->getTarget()] = true;
  5031. }
  5032. $found = true;
  5033. unset($lockedPackages[$index]);
  5034. break;
  5035. }
  5036. }
  5037. }
  5038. } while ($found);
  5039. $unused = array();
  5040. foreach ($lockedPackages as $package) {
  5041. $unused[] = $package->getName();
  5042. }
  5043. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  5044. if (!$input->getArgument('packages')) {
  5045. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  5046. $this->setCode(function () {
  5047. return 0;
  5048. });
  5049. }
  5050. }
  5051. }
  5052. protected function execute(InputInterface $input, OutputInterface $output)
  5053. {
  5054. $packages = $input->getArgument('packages');
  5055. $packages = array_map('strtolower', $packages);
  5056. $file = Factory::getComposerFile();
  5057. $jsonFile = new JsonFile($file);
  5058. $composer = $jsonFile->read();
  5059. $composerBackup = file_get_contents($jsonFile->getPath());
  5060. $json = new JsonConfigSource($jsonFile);
  5061. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5062. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5063. $io = $this->getIO();
  5064. if ($input->getOption('update-with-dependencies')) {
  5065. $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>');
  5066. }
  5067. foreach (array('require', 'require-dev') as $linkType) {
  5068. if (isset($composer[$linkType])) {
  5069. foreach ($composer[$linkType] as $name => $version) {
  5070. $composer[$linkType][strtolower($name)] = $name;
  5071. }
  5072. }
  5073. }
  5074. $dryRun = $input->getOption('dry-run');
  5075. $toRemove = array();
  5076. foreach ($packages as $package) {
  5077. if (isset($composer[$type][$package])) {
  5078. if ($dryRun) {
  5079. $toRemove[$type][] = $composer[$type][$package];
  5080. } else {
  5081. $json->removeLink($type, $composer[$type][$package]);
  5082. }
  5083. } elseif (isset($composer[$altType][$package])) {
  5084. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5085. if ($io->isInteractive()) {
  5086. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5087. if ($dryRun) {
  5088. $toRemove[$altType][] = $composer[$altType][$package];
  5089. } else {
  5090. $json->removeLink($altType, $composer[$altType][$package]);
  5091. }
  5092. }
  5093. }
  5094. } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  5095. foreach ($matches as $matchedPackage) {
  5096. if ($dryRun) {
  5097. $toRemove[$type][] = $matchedPackage;
  5098. } else {
  5099. $json->removeLink($type, $matchedPackage);
  5100. }
  5101. }
  5102. } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  5103. foreach ($matches as $matchedPackage) {
  5104. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5105. if ($io->isInteractive()) {
  5106. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5107. if ($dryRun) {
  5108. $toRemove[$altType][] = $matchedPackage;
  5109. } else {
  5110. $json->removeLink($altType, $matchedPackage);
  5111. }
  5112. }
  5113. }
  5114. }
  5115. } else {
  5116. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5117. }
  5118. }
  5119. $io->writeError('<info>'.$file.' has been updated</info>');
  5120. if ($input->getOption('no-update')) {
  5121. return 0;
  5122. }
  5123. $this->resetComposer();
  5124. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5125. if ($dryRun) {
  5126. $rootPackage = $composer->getPackage();
  5127. $links = array(
  5128. 'require' => $rootPackage->getRequires(),
  5129. 'require-dev' => $rootPackage->getDevRequires(),
  5130. );
  5131. foreach ($toRemove as $type => $names) {
  5132. foreach ($names as $name) {
  5133. unset($links[$type][$name]);
  5134. }
  5135. }
  5136. $rootPackage->setRequires($links['require']);
  5137. $rootPackage->setDevRequires($links['require-dev']);
  5138. }
  5139. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5140. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5141. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5142. $install = Installer::create($io, $composer);
  5143. $updateDevMode = !$input->getOption('update-no-dev');
  5144. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5145. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5146. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5147. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5148. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5149. $flags = '';
  5150. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5151. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5152. $flags .= ' --with-all-dependencies';
  5153. } elseif ($input->getOption('no-update-with-dependencies')) {
  5154. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5155. $flags .= ' --with-dependencies';
  5156. }
  5157. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5158. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5159. $install
  5160. ->setVerbose($input->getOption('verbose'))
  5161. ->setDevMode($updateDevMode)
  5162. ->setOptimizeAutoloader($optimize)
  5163. ->setClassMapAuthoritative($authoritative)
  5164. ->setApcuAutoloader($apcu, $apcuPrefix)
  5165. ->setUpdate(true)
  5166. ->setInstall(!$input->getOption('no-install'))
  5167. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5168. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5169. ->setRunScripts(!$input->getOption('no-scripts'))
  5170. ->setDryRun($dryRun)
  5171. ;
  5172. if ($composer->getLocker()->isLocked()) {
  5173. $install->setUpdateAllowList($packages);
  5174. }
  5175. $status = $install->run();
  5176. if ($status !== 0) {
  5177. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5178. file_put_contents($jsonFile->getPath(), $composerBackup);
  5179. }
  5180. if (!$dryRun) {
  5181. foreach ($packages as $package) {
  5182. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5183. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5184. return 2;
  5185. }
  5186. }
  5187. }
  5188. return $status;
  5189. }
  5190. }
  5191. <?php
  5192. namespace Composer\Command;
  5193. use Composer\DependencyResolver\Request;
  5194. use Symfony\Component\Console\Input\InputInterface;
  5195. use Symfony\Component\Console\Input\InputArgument;
  5196. use Symfony\Component\Console\Input\InputOption;
  5197. use Symfony\Component\Console\Output\OutputInterface;
  5198. use Composer\Factory;
  5199. use Composer\Installer;
  5200. use Composer\Json\JsonFile;
  5201. use Composer\Json\JsonManipulator;
  5202. use Composer\Package\Version\VersionParser;
  5203. use Composer\Package\Loader\ArrayLoader;
  5204. use Composer\Package\BasePackage;
  5205. use Composer\Plugin\CommandEvent;
  5206. use Composer\Plugin\PluginEvents;
  5207. use Composer\Repository\CompositeRepository;
  5208. use Composer\Repository\PlatformRepository;
  5209. use Composer\IO\IOInterface;
  5210. use Composer\Util\Silencer;
  5211. class RequireCommand extends InitCommand
  5212. {
  5213. private $newlyCreated;
  5214. private $firstRequire;
  5215. private $json;
  5216. private $file;
  5217. private $composerBackup;
  5218. private $lock;
  5219. private $lockBackup;
  5220. protected function configure()
  5221. {
  5222. $this
  5223. ->setName('require')
  5224. ->setDescription('Adds required packages to your composer.json and installs them.')
  5225. ->setDefinition(array(
  5226. 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"'),
  5227. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5228. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5229. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5230. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  5231. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5232. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5233. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5234. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5235. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5236. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5237. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5238. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5239. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5240. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5241. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5242. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5243. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5244. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5245. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5246. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5247. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5248. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5249. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5250. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5251. ))
  5252. ->setHelp(
  5253. <<<EOT
  5254. The require command adds required packages to your composer.json and installs them.
  5255. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5256. matches to require.
  5257. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5258. If you do not want to install the new dependencies immediately you can call it with --no-update
  5259. Read more at https://getcomposer.org/doc/03-cli.md#require
  5260. EOT
  5261. )
  5262. ;
  5263. }
  5264. protected function execute(InputInterface $input, OutputInterface $output)
  5265. {
  5266. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  5267. pcntl_async_signals(true);
  5268. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  5269. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  5270. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  5271. }
  5272. $this->file = Factory::getComposerFile();
  5273. $io = $this->getIO();
  5274. if ($input->getOption('no-suggest')) {
  5275. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5276. }
  5277. $this->newlyCreated = !file_exists($this->file);
  5278. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  5279. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  5280. return 1;
  5281. }
  5282. if (!is_readable($this->file) && false === Silencer::call('file_get_contents', $this->file)) {
  5283. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  5284. return 1;
  5285. }
  5286. if (filesize($this->file) === 0) {
  5287. file_put_contents($this->file, "{\n}\n");
  5288. }
  5289. $this->json = new JsonFile($this->file);
  5290. $this->lock = Factory::getLockFile($this->file);
  5291. $this->composerBackup = file_get_contents($this->json->getPath());
  5292. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  5293. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  5294. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  5295. return 1;
  5296. }
  5297. if ($input->getOption('fixed') === true) {
  5298. $config = $this->json->read();
  5299. $packageType = empty($config['type']) ? 'library' : $config['type'];
  5300. if ($packageType !== 'project') {
  5301. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  5302. if (empty($config['type'])) {
  5303. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  5304. }
  5305. return 1;
  5306. }
  5307. }
  5308. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5309. $repos = $composer->getRepositoryManager()->getRepositories();
  5310. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5311. $this->repos = new CompositeRepository(array_merge(
  5312. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  5313. $repos
  5314. ));
  5315. if ($composer->getPackage()->getPreferStable()) {
  5316. $preferredStability = 'stable';
  5317. } else {
  5318. $preferredStability = $composer->getPackage()->getMinimumStability();
  5319. }
  5320. try {
  5321. $requirements = $this->determineRequirements(
  5322. $input,
  5323. $output,
  5324. $input->getArgument('packages'),
  5325. $platformRepo,
  5326. $preferredStability,
  5327. !$input->getOption('no-update'),
  5328. $input->getOption('fixed')
  5329. );
  5330. } catch (\Exception $e) {
  5331. if ($this->newlyCreated) {
  5332. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  5333. }
  5334. throw $e;
  5335. }
  5336. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  5337. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  5338. $requirements = $this->formatRequirements($requirements);
  5339. $versionParser = new VersionParser();
  5340. foreach ($requirements as $package => $constraint) {
  5341. if (strtolower($package) === $composer->getPackage()->getName()) {
  5342. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  5343. return 1;
  5344. }
  5345. $versionParser->parseConstraints($constraint);
  5346. }
  5347. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  5348. $this->firstRequire = $this->newlyCreated;
  5349. if (!$this->firstRequire) {
  5350. $composerDefinition = $this->json->read();
  5351. if (empty($composerDefinition['require']) && empty($composerDefinition['require-dev'])) {
  5352. $this->firstRequire = true;
  5353. }
  5354. }
  5355. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  5356. $composerDefinition = $this->json->read();
  5357. foreach ($requirements as $package => $version) {
  5358. $composerDefinition[$requireKey][$package] = $version;
  5359. unset($composerDefinition[$removeKey][$package]);
  5360. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  5361. unset($composerDefinition[$removeKey]);
  5362. }
  5363. }
  5364. $this->json->write($composerDefinition);
  5365. }
  5366. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  5367. if ($input->getOption('no-update')) {
  5368. return 0;
  5369. }
  5370. try {
  5371. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  5372. } catch (\Exception $e) {
  5373. $this->revertComposerFile(false);
  5374. throw $e;
  5375. }
  5376. }
  5377. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
  5378. {
  5379. $this->resetComposer();
  5380. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5381. if ($input->getOption('dry-run')) {
  5382. $rootPackage = $composer->getPackage();
  5383. $links = array(
  5384. 'require' => $rootPackage->getRequires(),
  5385. 'require-dev' => $rootPackage->getDevRequires(),
  5386. );
  5387. $loader = new ArrayLoader();
  5388. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['description'], $requirements);
  5389. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  5390. foreach ($requirements as $package => $constraint) {
  5391. unset($links[$removeKey][$package]);
  5392. }
  5393. $rootPackage->setRequires($links['require']);
  5394. $rootPackage->setDevRequires($links['require-dev']);
  5395. }
  5396. $updateDevMode = !$input->getOption('update-no-dev');
  5397. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5398. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5399. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5400. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5401. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5402. $flags = '';
  5403. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5404. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5405. $flags .= ' --with-all-dependencies';
  5406. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  5407. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5408. $flags .= ' --with-dependencies';
  5409. }
  5410. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  5411. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  5412. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5413. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5414. $install = Installer::create($io, $composer);
  5415. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5416. $install
  5417. ->setDryRun($input->getOption('dry-run'))
  5418. ->setVerbose($input->getOption('verbose'))
  5419. ->setPreferSource($input->getOption('prefer-source'))
  5420. ->setPreferDist($input->getOption('prefer-dist'))
  5421. ->setDevMode($updateDevMode)
  5422. ->setRunScripts(!$input->getOption('no-scripts'))
  5423. ->setOptimizeAutoloader($optimize)
  5424. ->setClassMapAuthoritative($authoritative)
  5425. ->setApcuAutoloader($apcu, $apcuPrefix)
  5426. ->setUpdate(true)
  5427. ->setInstall(!$input->getOption('no-install'))
  5428. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5429. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5430. ->setPreferStable($input->getOption('prefer-stable'))
  5431. ->setPreferLowest($input->getOption('prefer-lowest'))
  5432. ;
  5433. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  5434. $install->setUpdateAllowList(array_keys($requirements));
  5435. }
  5436. $status = $install->run();
  5437. if ($status !== 0) {
  5438. $this->revertComposerFile(false);
  5439. }
  5440. return $status;
  5441. }
  5442. private function updateFileCleanly($json, array $new, $requireKey, $removeKey, $sortPackages)
  5443. {
  5444. $contents = file_get_contents($json->getPath());
  5445. $manipulator = new JsonManipulator($contents);
  5446. foreach ($new as $package => $constraint) {
  5447. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  5448. return false;
  5449. }
  5450. if (!$manipulator->removeSubNode($removeKey, $package)) {
  5451. return false;
  5452. }
  5453. }
  5454. $manipulator->removeMainKeyIfEmpty($removeKey);
  5455. file_put_contents($json->getPath(), $manipulator->getContents());
  5456. return true;
  5457. }
  5458. protected function interact(InputInterface $input, OutputInterface $output)
  5459. {
  5460. return;
  5461. }
  5462. public function revertComposerFile($hardExit = true)
  5463. {
  5464. $io = $this->getIO();
  5465. if ($this->newlyCreated) {
  5466. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  5467. unlink($this->json->getPath());
  5468. if (file_exists($this->lock)) {
  5469. unlink($this->lock);
  5470. }
  5471. } else {
  5472. $msg = ' to its ';
  5473. if ($this->lockBackup) {
  5474. $msg = ' and '.$this->lock.' to their ';
  5475. }
  5476. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  5477. file_put_contents($this->json->getPath(), $this->composerBackup);
  5478. if ($this->lockBackup) {
  5479. file_put_contents($this->lock, $this->lockBackup);
  5480. }
  5481. }
  5482. if ($hardExit) {
  5483. exit(1);
  5484. }
  5485. }
  5486. }
  5487. <?php
  5488. namespace Composer\Command;
  5489. use Composer\Script\Event as ScriptEvent;
  5490. use Composer\Script\ScriptEvents;
  5491. use Composer\Util\ProcessExecutor;
  5492. use Symfony\Component\Console\Input\InputInterface;
  5493. use Symfony\Component\Console\Input\InputOption;
  5494. use Symfony\Component\Console\Input\InputArgument;
  5495. use Symfony\Component\Console\Output\OutputInterface;
  5496. class RunScriptCommand extends BaseCommand
  5497. {
  5498. protected $scriptEvents = array(
  5499. ScriptEvents::PRE_INSTALL_CMD,
  5500. ScriptEvents::POST_INSTALL_CMD,
  5501. ScriptEvents::PRE_UPDATE_CMD,
  5502. ScriptEvents::POST_UPDATE_CMD,
  5503. ScriptEvents::PRE_STATUS_CMD,
  5504. ScriptEvents::POST_STATUS_CMD,
  5505. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  5506. ScriptEvents::POST_CREATE_PROJECT_CMD,
  5507. ScriptEvents::PRE_ARCHIVE_CMD,
  5508. ScriptEvents::POST_ARCHIVE_CMD,
  5509. ScriptEvents::PRE_AUTOLOAD_DUMP,
  5510. ScriptEvents::POST_AUTOLOAD_DUMP,
  5511. );
  5512. protected function configure()
  5513. {
  5514. $this
  5515. ->setName('run-script')
  5516. ->setAliases(array('run'))
  5517. ->setDescription('Runs the scripts defined in composer.json.')
  5518. ->setDefinition(array(
  5519. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  5520. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5521. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  5522. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5523. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5524. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  5525. ))
  5526. ->setHelp(
  5527. <<<EOT
  5528. The <info>run-script</info> command runs scripts defined in composer.json:
  5529. <info>php composer.phar run-script post-update-cmd</info>
  5530. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5531. EOT
  5532. )
  5533. ;
  5534. }
  5535. protected function execute(InputInterface $input, OutputInterface $output)
  5536. {
  5537. if ($input->getOption('list')) {
  5538. return $this->listScripts($output);
  5539. }
  5540. if (!$input->getArgument('script')) {
  5541. throw new \RuntimeException('Missing required argument "script"');
  5542. }
  5543. $script = $input->getArgument('script');
  5544. if (!in_array($script, $this->scriptEvents)) {
  5545. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  5546. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  5547. }
  5548. }
  5549. $composer = $this->getComposer();
  5550. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  5551. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  5552. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  5553. if (!$hasListeners) {
  5554. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  5555. }
  5556. $args = $input->getArgument('args');
  5557. if (null !== $timeout = $input->getOption('timeout')) {
  5558. if (!ctype_digit($timeout)) {
  5559. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  5560. }
  5561. ProcessExecutor::setTimeout((int) $timeout);
  5562. }
  5563. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  5564. }
  5565. protected function listScripts(OutputInterface $output)
  5566. {
  5567. $scripts = $this->getComposer()->getPackage()->getScripts();
  5568. if (!count($scripts)) {
  5569. return 0;
  5570. }
  5571. $io = $this->getIO();
  5572. $io->writeError('<info>scripts:</info>');
  5573. $table = array();
  5574. foreach ($scripts as $name => $script) {
  5575. $description = '';
  5576. try {
  5577. $cmd = $this->getApplication()->find($name);
  5578. if ($cmd instanceof ScriptAliasCommand) {
  5579. $description = $cmd->getDescription();
  5580. }
  5581. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  5582. }
  5583. $table[] = array(' '.$name, $description);
  5584. }
  5585. $this->renderTable($table, $output);
  5586. return 0;
  5587. }
  5588. }
  5589. <?php
  5590. namespace Composer\Command;
  5591. use Symfony\Component\Console\Input\InputInterface;
  5592. use Symfony\Component\Console\Input\InputOption;
  5593. use Symfony\Component\Console\Input\InputArgument;
  5594. use Symfony\Component\Console\Output\OutputInterface;
  5595. class ScriptAliasCommand extends BaseCommand
  5596. {
  5597. private $script;
  5598. private $description;
  5599. public function __construct($script, $description)
  5600. {
  5601. $this->script = $script;
  5602. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  5603. parent::__construct();
  5604. }
  5605. protected function configure()
  5606. {
  5607. $this
  5608. ->setName($this->script)
  5609. ->setDescription($this->description)
  5610. ->setDefinition(array(
  5611. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5612. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5613. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5614. ))
  5615. ->setHelp(
  5616. <<<EOT
  5617. The <info>run-script</info> command runs scripts defined in composer.json:
  5618. <info>php composer.phar run-script post-update-cmd</info>
  5619. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5620. EOT
  5621. )
  5622. ;
  5623. }
  5624. protected function execute(InputInterface $input, OutputInterface $output)
  5625. {
  5626. $composer = $this->getComposer();
  5627. $args = $input->getArguments();
  5628. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  5629. }
  5630. }
  5631. <?php
  5632. namespace Composer\Command;
  5633. use Composer\Factory;
  5634. use Symfony\Component\Console\Input\InputInterface;
  5635. use Symfony\Component\Console\Input\InputArgument;
  5636. use Symfony\Component\Console\Input\InputOption;
  5637. use Symfony\Component\Console\Output\OutputInterface;
  5638. use Composer\Repository\CompositeRepository;
  5639. use Composer\Repository\PlatformRepository;
  5640. use Composer\Repository\RepositoryInterface;
  5641. use Composer\Plugin\CommandEvent;
  5642. use Composer\Plugin\PluginEvents;
  5643. class SearchCommand extends BaseCommand
  5644. {
  5645. protected $matches;
  5646. protected $lowMatches = array();
  5647. protected $tokens;
  5648. protected $output;
  5649. protected $onlyName;
  5650. protected function configure()
  5651. {
  5652. $this
  5653. ->setName('search')
  5654. ->setDescription('Searches for packages.')
  5655. ->setDefinition(array(
  5656. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in name'),
  5657. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  5658. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  5659. ))
  5660. ->setHelp(
  5661. <<<EOT
  5662. The search command searches for packages by its name
  5663. <info>php composer.phar search symfony composer</info>
  5664. Read more at https://getcomposer.org/doc/03-cli.md#search
  5665. EOT
  5666. )
  5667. ;
  5668. }
  5669. protected function execute(InputInterface $input, OutputInterface $output)
  5670. {
  5671. $platformRepo = new PlatformRepository;
  5672. $io = $this->getIO();
  5673. if (!($composer = $this->getComposer(false))) {
  5674. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  5675. }
  5676. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5677. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  5678. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  5679. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  5680. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5681. $onlyName = $input->getOption('only-name');
  5682. $type = $input->getOption('type') ?: null;
  5683. $flags = $onlyName ? RepositoryInterface::SEARCH_NAME : RepositoryInterface::SEARCH_FULLTEXT;
  5684. $results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags, $type);
  5685. foreach ($results as $result) {
  5686. $io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
  5687. }
  5688. return 0;
  5689. }
  5690. }
  5691. <?php
  5692. namespace Composer\Command;
  5693. use Composer\Composer;
  5694. use Composer\Factory;
  5695. use Composer\Config;
  5696. use Composer\Util\Filesystem;
  5697. use Composer\Util\Platform;
  5698. use Composer\SelfUpdate\Keys;
  5699. use Composer\SelfUpdate\Versions;
  5700. use Composer\IO\IOInterface;
  5701. use Composer\Downloader\FilesystemException;
  5702. use Composer\Downloader\TransportException;
  5703. use Symfony\Component\Console\Input\InputInterface;
  5704. use Symfony\Component\Console\Input\InputOption;
  5705. use Symfony\Component\Console\Input\InputArgument;
  5706. use Symfony\Component\Console\Output\OutputInterface;
  5707. use Symfony\Component\Finder\Finder;
  5708. class SelfUpdateCommand extends BaseCommand
  5709. {
  5710. const HOMEPAGE = 'getcomposer.org';
  5711. const OLD_INSTALL_EXT = '-old.phar';
  5712. protected function configure()
  5713. {
  5714. $this
  5715. ->setName('self-update')
  5716. ->setAliases(array('selfupdate'))
  5717. ->setDescription('Updates composer.phar to the latest version.')
  5718. ->setDefinition(array(
  5719. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  5720. 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'),
  5721. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  5722. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5723. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  5724. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  5725. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  5726. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  5727. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  5728. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  5729. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  5730. ))
  5731. ->setHelp(
  5732. <<<EOT
  5733. The <info>self-update</info> command checks getcomposer.org for newer
  5734. versions of composer and if found, installs the latest.
  5735. <info>php composer.phar self-update</info>
  5736. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  5737. EOT
  5738. )
  5739. ;
  5740. }
  5741. protected function execute(InputInterface $input, OutputInterface $output)
  5742. {
  5743. $config = Factory::createConfig();
  5744. if ($config->get('disable-tls') === true) {
  5745. $baseUrl = 'http://' . self::HOMEPAGE;
  5746. } else {
  5747. $baseUrl = 'https://' . self::HOMEPAGE;
  5748. }
  5749. $io = $this->getIO();
  5750. $httpDownloader = Factory::createHttpDownloader($io, $config);
  5751. $versionsUtil = new Versions($config, $httpDownloader);
  5752. $requestedChannel = null;
  5753. foreach (Versions::$channels as $channel) {
  5754. if ($input->getOption($channel)) {
  5755. $requestedChannel = $channel;
  5756. $versionsUtil->setChannel($channel);
  5757. break;
  5758. }
  5759. }
  5760. if ($input->getOption('set-channel-only')) {
  5761. return 0;
  5762. }
  5763. $cacheDir = $config->get('cache-dir');
  5764. $rollbackDir = $config->get('data-dir');
  5765. $home = $config->get('home');
  5766. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  5767. if ($input->getOption('update-keys')) {
  5768. return $this->fetchKeys($io, $config);
  5769. }
  5770. if (!file_exists($localFilename)) {
  5771. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  5772. }
  5773. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  5774. if (!is_writable($tmpDir)) {
  5775. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  5776. }
  5777. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  5778. $composeUser = posix_getpwuid(posix_geteuid());
  5779. $homeOwner = posix_getpwuid(fileowner($home));
  5780. if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  5781. $io->writeError('<warning>You are running Composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  5782. }
  5783. }
  5784. if ($input->getOption('rollback')) {
  5785. return $this->rollback($output, $rollbackDir, $localFilename);
  5786. }
  5787. $latest = $versionsUtil->getLatest();
  5788. $latestStable = $versionsUtil->getLatest('stable');
  5789. try {
  5790. $latestPreview = $versionsUtil->getLatest('preview');
  5791. } catch (\UnexpectedValueException $e) {
  5792. $latestPreview = $latestStable;
  5793. }
  5794. $latestVersion = $latest['version'];
  5795. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  5796. $currentMajorVersion = preg_replace('{^(\d+).*}', '$1', Composer::getVersion());
  5797. $updateMajorVersion = preg_replace('{^(\d+).*}', '$1', $updateVersion);
  5798. $previewMajorVersion = preg_replace('{^(\d+).*}', '$1', $latestPreview['version']);
  5799. if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
  5800. if ($currentMajorVersion < $updateMajorVersion) {
  5801. $skippedVersion = $updateVersion;
  5802. $versionsUtil->setChannel($currentMajorVersion);
  5803. $latest = $versionsUtil->getLatest();
  5804. $latestStable = $versionsUtil->getLatest('stable');
  5805. $latestVersion = $latest['version'];
  5806. $updateVersion = $latestVersion;
  5807. $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>');
  5808. } elseif ($currentMajorVersion < $previewMajorVersion) {
  5809. $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>');
  5810. }
  5811. }
  5812. if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
  5813. $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>');
  5814. }
  5815. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  5816. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  5817. return 1;
  5818. }
  5819. $channelString = $versionsUtil->getChannel();
  5820. if (is_numeric($channelString)) {
  5821. $channelString .= '.x';
  5822. }
  5823. if (Composer::VERSION === $updateVersion) {
  5824. $io->writeError(
  5825. sprintf(
  5826. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  5827. $updateVersion,
  5828. $channelString
  5829. )
  5830. );
  5831. if ($input->getOption('clean-backups')) {
  5832. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  5833. }
  5834. return 0;
  5835. }
  5836. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp.phar';
  5837. $backupFile = sprintf(
  5838. '%s/%s-%s%s',
  5839. $rollbackDir,
  5840. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  5841. preg_replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  5842. self::OLD_INSTALL_EXT
  5843. );
  5844. $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion);
  5845. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  5846. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  5847. try {
  5848. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  5849. } catch (TransportException $e) {
  5850. if ($e->getStatusCode() === 404) {
  5851. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  5852. }
  5853. throw $e;
  5854. }
  5855. $io->writeError(' ', false);
  5856. $httpDownloader->copy($remoteFilename, $tempFilename);
  5857. $io->writeError('');
  5858. if (!file_exists($tempFilename) || !$signature) {
  5859. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  5860. return 1;
  5861. }
  5862. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  5863. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  5864. } else {
  5865. if (!extension_loaded('openssl')) {
  5866. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  5867. . '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.');
  5868. }
  5869. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  5870. if (!file_exists($sigFile)) {
  5871. file_put_contents(
  5872. $home.'/keys.dev.pub',
  5873. <<<DEVPUBKEY
  5874. -----BEGIN PUBLIC KEY-----
  5875. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  5876. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  5877. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  5878. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  5879. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  5880. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  5881. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  5882. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  5883. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  5884. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  5885. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  5886. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  5887. -----END PUBLIC KEY-----
  5888. DEVPUBKEY
  5889. );
  5890. file_put_contents(
  5891. $home.'/keys.tags.pub',
  5892. <<<TAGSPUBKEY
  5893. -----BEGIN PUBLIC KEY-----
  5894. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  5895. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  5896. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  5897. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  5898. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  5899. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  5900. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  5901. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  5902. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  5903. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  5904. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  5905. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  5906. -----END PUBLIC KEY-----
  5907. TAGSPUBKEY
  5908. );
  5909. }
  5910. $pubkeyid = openssl_pkey_get_public($sigFile);
  5911. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  5912. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  5913. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  5914. }
  5915. $signature = json_decode($signature, true);
  5916. $signature = base64_decode($signature['sha384']);
  5917. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  5918. if (PHP_VERSION_ID < 80000) {
  5919. openssl_free_key($pubkeyid);
  5920. }
  5921. if (!$verified) {
  5922. 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');
  5923. }
  5924. }
  5925. if ($input->getOption('clean-backups')) {
  5926. $this->cleanBackups($rollbackDir);
  5927. }
  5928. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  5929. @unlink($tempFilename);
  5930. return 1;
  5931. }
  5932. if (file_exists($backupFile)) {
  5933. $io->writeError(sprintf(
  5934. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  5935. Composer::VERSION
  5936. ));
  5937. } else {
  5938. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  5939. }
  5940. return 0;
  5941. }
  5942. protected function fetchKeys(IOInterface $io, Config $config)
  5943. {
  5944. if (!$io->isInteractive()) {
  5945. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  5946. }
  5947. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  5948. $validator = function ($value) {
  5949. if (!preg_match('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  5950. throw new \UnexpectedValueException('Invalid input');
  5951. }
  5952. return trim($value)."\n";
  5953. };
  5954. $devKey = '';
  5955. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  5956. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  5957. while ($line = $io->ask('')) {
  5958. $devKey .= trim($line)."\n";
  5959. if (trim($line) === '-----END PUBLIC KEY-----') {
  5960. break;
  5961. }
  5962. }
  5963. }
  5964. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  5965. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5966. $tagsKey = '';
  5967. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  5968. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  5969. while ($line = $io->ask('')) {
  5970. $tagsKey .= trim($line)."\n";
  5971. if (trim($line) === '-----END PUBLIC KEY-----') {
  5972. break;
  5973. }
  5974. }
  5975. }
  5976. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  5977. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5978. $io->write('Public keys stored in '.$config->get('home'));
  5979. }
  5980. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  5981. {
  5982. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  5983. if (!$rollbackVersion) {
  5984. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  5985. }
  5986. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  5987. if (!is_file($oldFile)) {
  5988. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  5989. }
  5990. if (!is_readable($oldFile)) {
  5991. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  5992. }
  5993. $io = $this->getIO();
  5994. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  5995. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  5996. return 1;
  5997. }
  5998. return 0;
  5999. }
  6000. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  6001. {
  6002. $io = $this->getIO();
  6003. @chmod($newFilename, fileperms($localFilename));
  6004. if (!$this->validatePhar($newFilename, $error)) {
  6005. $io->writeError('<error>The '.($backupTarget ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  6006. if ($backupTarget) {
  6007. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  6008. }
  6009. return false;
  6010. }
  6011. if ($backupTarget) {
  6012. @copy($localFilename, $backupTarget);
  6013. }
  6014. try {
  6015. if (Platform::isWindows()) {
  6016. copy($newFilename, $localFilename);
  6017. @unlink($newFilename);
  6018. } else {
  6019. rename($newFilename, $localFilename);
  6020. }
  6021. return true;
  6022. } catch (\Exception $e) {
  6023. if (!is_writable(dirname($localFilename))
  6024. && $io->isInteractive()
  6025. && $this->isWindowsNonAdminUser()) {
  6026. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  6027. }
  6028. $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
  6029. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  6030. }
  6031. }
  6032. protected function cleanBackups($rollbackDir, $except = null)
  6033. {
  6034. $finder = $this->getOldInstallationFinder($rollbackDir);
  6035. $io = $this->getIO();
  6036. $fs = new Filesystem;
  6037. foreach ($finder as $file) {
  6038. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  6039. continue;
  6040. }
  6041. $file = (string) $file;
  6042. $io->writeError('<info>Removing: '.$file.'</info>');
  6043. $fs->remove($file);
  6044. }
  6045. }
  6046. protected function getLastBackupVersion($rollbackDir)
  6047. {
  6048. $finder = $this->getOldInstallationFinder($rollbackDir);
  6049. $finder->sortByName();
  6050. $files = iterator_to_array($finder);
  6051. if (count($files)) {
  6052. return basename(end($files), self::OLD_INSTALL_EXT);
  6053. }
  6054. return false;
  6055. }
  6056. protected function getOldInstallationFinder($rollbackDir)
  6057. {
  6058. return Finder::create()
  6059. ->depth(0)
  6060. ->files()
  6061. ->name('*' . self::OLD_INSTALL_EXT)
  6062. ->in($rollbackDir);
  6063. }
  6064. protected function validatePhar($pharFile, &$error)
  6065. {
  6066. if (ini_get('phar.readonly')) {
  6067. return true;
  6068. }
  6069. try {
  6070. $phar = new \Phar($pharFile);
  6071. unset($phar);
  6072. $result = true;
  6073. } catch (\Exception $e) {
  6074. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  6075. throw $e;
  6076. }
  6077. $error = $e->getMessage();
  6078. $result = false;
  6079. }
  6080. return $result;
  6081. }
  6082. protected function isWindowsNonAdminUser()
  6083. {
  6084. if (!Platform::isWindows()) {
  6085. return false;
  6086. }
  6087. exec('fltmc.exe filters', $output, $exitCode);
  6088. return $exitCode !== 0;
  6089. }
  6090. protected function tryAsWindowsAdmin($localFilename, $newFilename)
  6091. {
  6092. $io = $this->getIO();
  6093. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6094. $helpMessage = 'Please run the self-update command as an Administrator.';
  6095. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6096. if (!$io->askConfirmation($question, false)) {
  6097. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6098. return false;
  6099. }
  6100. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6101. $script = $tmpFile.'.vbs';
  6102. rename($tmpFile, $script);
  6103. $checksum = hash_file('sha256', $newFilename);
  6104. $source = str_replace('/', '\\', $newFilename);
  6105. $destination = str_replace('/', '\\', $localFilename);
  6106. $vbs = <<<EOT
  6107. Set UAC = CreateObject("Shell.Application")
  6108. UAC.ShellExecute "cmd.exe", "/c copy /b /y ""$source"" ""$destination""", "", "runas", 0
  6109. Wscript.Sleep(300)
  6110. EOT;
  6111. file_put_contents($script, $vbs);
  6112. exec('"'.$script.'"');
  6113. @unlink($script);
  6114. if ($result = is_readable($localFilename) && (hash_file('sha256', $localFilename) === $checksum)) {
  6115. $io->writeError('<info>Operation succeeded.</info>');
  6116. @unlink($newFilename);
  6117. } else {
  6118. $io->writeError('<error>Operation failed.'.$helpMessage.'</error>');
  6119. }
  6120. return $result;
  6121. }
  6122. }
  6123. <?php
  6124. namespace Composer\Command;
  6125. use Composer\Composer;
  6126. use Composer\DependencyResolver\DefaultPolicy;
  6127. use Composer\Json\JsonFile;
  6128. use Composer\Package\BasePackage;
  6129. use Composer\Package\CompletePackageInterface;
  6130. use Composer\Package\Link;
  6131. use Composer\Package\AliasPackage;
  6132. use Composer\Package\PackageInterface;
  6133. use Composer\Package\Version\VersionParser;
  6134. use Composer\Package\Version\VersionSelector;
  6135. use Composer\Plugin\CommandEvent;
  6136. use Composer\Plugin\PluginEvents;
  6137. use Composer\Repository\InstalledArrayRepository;
  6138. use Composer\Repository\ComposerRepository;
  6139. use Composer\Repository\CompositeRepository;
  6140. use Composer\Repository\PlatformRepository;
  6141. use Composer\Repository\RepositoryFactory;
  6142. use Composer\Repository\InstalledRepository;
  6143. use Composer\Repository\RepositoryInterface;
  6144. use Composer\Repository\RepositorySet;
  6145. use Composer\Repository\RootPackageRepository;
  6146. use Composer\Semver\Constraint\ConstraintInterface;
  6147. use Composer\Semver\Semver;
  6148. use Composer\Spdx\SpdxLicenses;
  6149. use Composer\Util\Platform;
  6150. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  6151. use Symfony\Component\Console\Input\InputArgument;
  6152. use Symfony\Component\Console\Input\InputInterface;
  6153. use Symfony\Component\Console\Input\InputOption;
  6154. use Symfony\Component\Console\Output\OutputInterface;
  6155. use Symfony\Component\Console\Terminal;
  6156. class ShowCommand extends BaseCommand
  6157. {
  6158. protected $versionParser;
  6159. protected $colors;
  6160. private $repositorySet;
  6161. protected function configure()
  6162. {
  6163. $this
  6164. ->setName('show')
  6165. ->setAliases(array('info'))
  6166. ->setDescription('Shows information about packages.')
  6167. ->setDefinition(array(
  6168. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  6169. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  6170. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  6171. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  6172. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  6173. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  6174. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  6175. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  6176. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  6177. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  6178. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  6179. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  6180. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  6181. 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.'),
  6182. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  6183. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6184. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6185. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6186. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6187. ))
  6188. ->setHelp(
  6189. <<<EOT
  6190. The show command displays detailed information about a package, or
  6191. lists all packages available.
  6192. Read more at https://getcomposer.org/doc/03-cli.md#show
  6193. EOT
  6194. )
  6195. ;
  6196. }
  6197. protected function execute(InputInterface $input, OutputInterface $output)
  6198. {
  6199. $this->versionParser = new VersionParser;
  6200. if ($input->getOption('tree')) {
  6201. $this->initStyles($output);
  6202. }
  6203. $composer = $this->getComposer(false);
  6204. $io = $this->getIO();
  6205. if ($input->getOption('installed')) {
  6206. $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>');
  6207. }
  6208. if ($input->getOption('outdated')) {
  6209. $input->setOption('latest', true);
  6210. } elseif ($input->getOption('ignore')) {
  6211. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  6212. }
  6213. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  6214. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  6215. return 1;
  6216. }
  6217. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  6218. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  6219. return 1;
  6220. }
  6221. if ($input->getOption('tree') && $input->getOption('latest')) {
  6222. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  6223. return 1;
  6224. }
  6225. if ($input->getOption('tree') && $input->getOption('path')) {
  6226. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  6227. return 1;
  6228. }
  6229. $format = $input->getOption('format');
  6230. if (!in_array($format, array('text', 'json'))) {
  6231. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6232. return 1;
  6233. }
  6234. $platformOverrides = array();
  6235. if ($composer) {
  6236. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  6237. }
  6238. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  6239. $lockedRepo = null;
  6240. if ($input->getOption('self')) {
  6241. $package = $this->getComposer()->getPackage();
  6242. if ($input->getOption('name-only')) {
  6243. $io->write($package->getName());
  6244. return 0;
  6245. }
  6246. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  6247. } elseif ($input->getOption('platform')) {
  6248. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  6249. } elseif ($input->getOption('available')) {
  6250. $installedRepo = new InstalledRepository(array($platformRepo));
  6251. if ($composer) {
  6252. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  6253. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  6254. } else {
  6255. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6256. $repos = new CompositeRepository($defaultRepos);
  6257. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6258. }
  6259. } elseif ($input->getOption('all') && $composer) {
  6260. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6261. $locker = $composer->getLocker();
  6262. if ($locker->isLocked()) {
  6263. $lockedRepo = $locker->getLockedRepository(true);
  6264. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  6265. } else {
  6266. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  6267. }
  6268. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6269. } elseif ($input->getOption('all')) {
  6270. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6271. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6272. $installedRepo = new InstalledRepository(array($platformRepo));
  6273. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  6274. } elseif ($input->getOption('locked')) {
  6275. if (!$composer || !$composer->getLocker()->isLocked()) {
  6276. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  6277. }
  6278. $locker = $composer->getLocker();
  6279. $lockedRepo = $locker->getLockedRepository(!$input->getOption('no-dev'));
  6280. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  6281. } else {
  6282. if (!$composer) {
  6283. $composer = $this->getComposer();
  6284. }
  6285. $rootPkg = $composer->getPackage();
  6286. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  6287. if ($input->getOption('no-dev')) {
  6288. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  6289. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) {
  6290. return clone $pkg;
  6291. }, $packages))));
  6292. }
  6293. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  6294. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  6295. }
  6296. }
  6297. if ($composer) {
  6298. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  6299. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6300. }
  6301. if ($input->getOption('latest') && null === $composer) {
  6302. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  6303. $input->setOption('latest', false);
  6304. }
  6305. $packageFilter = $input->getArgument('package');
  6306. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  6307. if (empty($package)) {
  6308. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  6309. if (empty($package)) {
  6310. $options = $input->getOptions();
  6311. if (!isset($options['working-dir']) || !file_exists('composer.json')) {
  6312. if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
  6313. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
  6314. }
  6315. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
  6316. }
  6317. $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
  6318. return 1;
  6319. }
  6320. } else {
  6321. $versions = array($package->getPrettyVersion() => $package->getVersion());
  6322. }
  6323. $exitCode = 0;
  6324. if ($input->getOption('tree')) {
  6325. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  6326. if ('json' === $format) {
  6327. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  6328. } else {
  6329. $this->displayPackageTree(array($arrayTree));
  6330. }
  6331. } else {
  6332. $latestPackage = null;
  6333. if ($input->getOption('latest')) {
  6334. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'));
  6335. }
  6336. if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) {
  6337. $exitCode = 1;
  6338. }
  6339. if ($input->getOption('path')) {
  6340. $io->write($package->getName(), false);
  6341. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  6342. return $exitCode;
  6343. }
  6344. if ('json' === $format) {
  6345. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  6346. } else {
  6347. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  6348. }
  6349. }
  6350. return $exitCode;
  6351. }
  6352. if ($input->getOption('tree')) {
  6353. $rootRequires = $this->getRootRequires();
  6354. $packages = $installedRepo->getPackages();
  6355. usort($packages, 'strcmp');
  6356. $arrayTree = array();
  6357. foreach ($packages as $package) {
  6358. if (in_array($package->getName(), $rootRequires, true)) {
  6359. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  6360. }
  6361. }
  6362. if ('json' === $format) {
  6363. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  6364. } else {
  6365. $this->displayPackageTree($arrayTree);
  6366. }
  6367. return 0;
  6368. }
  6369. if ($repos instanceof CompositeRepository) {
  6370. $repos = $repos->getRepositories();
  6371. } elseif (!is_array($repos)) {
  6372. $repos = array($repos);
  6373. }
  6374. $packages = array();
  6375. $packageFilterRegex = null;
  6376. if (null !== $packageFilter) {
  6377. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  6378. }
  6379. $packageListFilter = array();
  6380. if ($input->getOption('direct')) {
  6381. $packageListFilter = $this->getRootRequires();
  6382. }
  6383. if (class_exists('Symfony\Component\Console\Terminal')) {
  6384. $terminal = new Terminal();
  6385. $width = $terminal->getWidth();
  6386. } else {
  6387. list($width) = $this->getApplication()->getTerminalDimensions();
  6388. }
  6389. if (null === $width) {
  6390. $width = PHP_INT_MAX;
  6391. }
  6392. if (Platform::isWindows()) {
  6393. $width--;
  6394. } else {
  6395. $width = max(80, $width);
  6396. }
  6397. if ($input->getOption('path') && null === $composer) {
  6398. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  6399. $input->setOption('path', false);
  6400. }
  6401. foreach ($repos as $repo) {
  6402. if ($repo === $platformRepo) {
  6403. $type = 'platform';
  6404. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  6405. $type = 'locked';
  6406. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  6407. $type = 'installed';
  6408. } else {
  6409. $type = 'available';
  6410. }
  6411. if ($repo instanceof ComposerRepository) {
  6412. foreach ($repo->getPackageNames($packageFilter) as $name) {
  6413. $packages[$type][$name] = $name;
  6414. }
  6415. } else {
  6416. foreach ($repo->getPackages() as $package) {
  6417. if (!isset($packages[$type][$package->getName()])
  6418. || !is_object($packages[$type][$package->getName()])
  6419. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  6420. ) {
  6421. while ($package instanceof AliasPackage) {
  6422. $package = $package->getAliasOf();
  6423. }
  6424. if (!$packageFilterRegex || preg_match($packageFilterRegex, $package->getName())) {
  6425. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  6426. $packages[$type][$package->getName()] = $package;
  6427. }
  6428. }
  6429. }
  6430. }
  6431. }
  6432. }
  6433. $showAllTypes = $input->getOption('all');
  6434. $showLatest = $input->getOption('latest');
  6435. $showMinorOnly = $input->getOption('minor-only');
  6436. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  6437. $indent = $showAllTypes ? ' ' : '';
  6438. $latestPackages = array();
  6439. $exitCode = 0;
  6440. $viewData = array();
  6441. $viewMetaData = array();
  6442. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  6443. if (isset($packages[$type])) {
  6444. ksort($packages[$type]);
  6445. $nameLength = $versionLength = $latestLength = 0;
  6446. if ($showLatest && $showVersion) {
  6447. foreach ($packages[$type] as $package) {
  6448. if (is_object($package)) {
  6449. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly);
  6450. if ($latestPackage === false) {
  6451. continue;
  6452. }
  6453. $latestPackages[$package->getPrettyName()] = $latestPackage;
  6454. }
  6455. }
  6456. }
  6457. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  6458. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  6459. $writeLatest = $writeVersion && $showLatest;
  6460. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  6461. $hasOutdatedPackages = false;
  6462. $viewData[$type] = array();
  6463. foreach ($packages[$type] as $package) {
  6464. $packageViewData = array();
  6465. if (is_object($package)) {
  6466. $latestPackage = null;
  6467. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  6468. $latestPackage = $latestPackages[$package->getPrettyName()];
  6469. }
  6470. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackage->isAbandoned();
  6471. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  6472. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  6473. continue;
  6474. }
  6475. if ($input->getOption('outdated') || $input->getOption('strict')) {
  6476. $hasOutdatedPackages = true;
  6477. }
  6478. $packageViewData['name'] = $package->getPrettyName();
  6479. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  6480. if ($writeVersion) {
  6481. $packageViewData['version'] = $package->getFullPrettyVersion();
  6482. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  6483. }
  6484. if ($writeLatest && $latestPackage) {
  6485. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  6486. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  6487. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  6488. }
  6489. if ($writeDescription) {
  6490. $packageViewData['description'] = $package->getDescription();
  6491. }
  6492. if ($writePath) {
  6493. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  6494. }
  6495. if ($latestPackage && $latestPackage->isAbandoned()) {
  6496. $replacement = is_string($latestPackage->getReplacementPackage())
  6497. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  6498. : 'No replacement was suggested';
  6499. $packageWarning = sprintf(
  6500. 'Package %s is abandoned, you should avoid using it. %s.',
  6501. $package->getPrettyName(),
  6502. $replacement
  6503. );
  6504. $packageViewData['warning'] = $packageWarning;
  6505. }
  6506. } else {
  6507. $packageViewData['name'] = $package;
  6508. $nameLength = max($nameLength, strlen($package));
  6509. }
  6510. $viewData[$type][] = $packageViewData;
  6511. }
  6512. $viewMetaData[$type] = array(
  6513. 'nameLength' => $nameLength,
  6514. 'versionLength' => $versionLength,
  6515. 'latestLength' => $latestLength,
  6516. );
  6517. if ($input->getOption('strict') && $hasOutdatedPackages) {
  6518. $exitCode = 1;
  6519. break;
  6520. }
  6521. }
  6522. }
  6523. if ('json' === $format) {
  6524. $io->write(JsonFile::encode($viewData));
  6525. } else {
  6526. foreach ($viewData as $type => $packages) {
  6527. $nameLength = $viewMetaData[$type]['nameLength'];
  6528. $versionLength = $viewMetaData[$type]['versionLength'];
  6529. $latestLength = $viewMetaData[$type]['latestLength'];
  6530. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  6531. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  6532. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  6533. if ($writeLatest && !$io->isDecorated()) {
  6534. $latestLength += 2;
  6535. }
  6536. if ($showAllTypes) {
  6537. if ('available' === $type) {
  6538. $io->write('<comment>' . $type . '</comment>:');
  6539. } else {
  6540. $io->write('<info>' . $type . '</info>:');
  6541. }
  6542. }
  6543. foreach ($packages as $package) {
  6544. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  6545. if (isset($package['version']) && $writeVersion) {
  6546. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  6547. }
  6548. if (isset($package['latest']) && $writeLatest) {
  6549. $latestVersion = $package['latest'];
  6550. $updateStatus = $package['latest-status'];
  6551. $style = $this->updateStatusToVersionStyle($updateStatus);
  6552. if (!$io->isDecorated()) {
  6553. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  6554. }
  6555. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  6556. }
  6557. if (isset($package['description']) && $writeDescription) {
  6558. $description = strtok($package['description'], "\r\n");
  6559. $remaining = $width - $nameLength - $versionLength - 4;
  6560. if ($writeLatest) {
  6561. $remaining -= $latestLength;
  6562. }
  6563. if (strlen($description) > $remaining) {
  6564. $description = substr($description, 0, $remaining - 3) . '...';
  6565. }
  6566. $io->write(' ' . $description, false);
  6567. }
  6568. if (isset($package['path'])) {
  6569. $io->write(' ' . $package['path'], false);
  6570. }
  6571. $io->write('');
  6572. if (isset($package['warning'])) {
  6573. $io->write('<warning>' . $package['warning'] . '</warning>');
  6574. }
  6575. }
  6576. if ($showAllTypes) {
  6577. $io->write('');
  6578. }
  6579. }
  6580. }
  6581. return $exitCode;
  6582. }
  6583. protected function getRootRequires()
  6584. {
  6585. $rootPackage = $this->getComposer()->getPackage();
  6586. return array_map(
  6587. 'strtolower',
  6588. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  6589. );
  6590. }
  6591. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  6592. {
  6593. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  6594. }
  6595. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
  6596. {
  6597. $name = strtolower($name);
  6598. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  6599. $policy = new DefaultPolicy();
  6600. $repositorySet = new RepositorySet('dev');
  6601. $repositorySet->allowInstalledRepositories();
  6602. $repositorySet->addRepository($repos);
  6603. $matchedPackage = null;
  6604. $versions = array();
  6605. if (PlatformRepository::isPlatformPackage($name)) {
  6606. $pool = $repositorySet->createPoolWithAllPackages();
  6607. } else {
  6608. $pool = $repositorySet->createPoolForPackage($name);
  6609. }
  6610. $matches = $pool->whatProvides($name, $constraint);
  6611. foreach ($matches as $index => $package) {
  6612. if (null === $version && $installedRepo->hasPackage($package)) {
  6613. $matchedPackage = $package;
  6614. }
  6615. $versions[$package->getPrettyVersion()] = $package->getVersion();
  6616. $matches[$index] = $package->getId();
  6617. }
  6618. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  6619. $matchedPackage = $pool->literalToPackage($preferred[0]);
  6620. }
  6621. return array($matchedPackage, $versions);
  6622. }
  6623. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6624. {
  6625. $io = $this->getIO();
  6626. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  6627. $this->printLinks($package, Link::TYPE_REQUIRE);
  6628. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  6629. if ($package->getSuggests()) {
  6630. $io->write("\n<info>suggests</info>");
  6631. foreach ($package->getSuggests() as $suggested => $reason) {
  6632. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  6633. }
  6634. }
  6635. $this->printLinks($package, Link::TYPE_PROVIDE);
  6636. $this->printLinks($package, Link::TYPE_CONFLICT);
  6637. $this->printLinks($package, Link::TYPE_REPLACE);
  6638. }
  6639. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6640. {
  6641. $io = $this->getIO();
  6642. $io->write('<info>name</info> : ' . $package->getPrettyName());
  6643. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  6644. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  6645. $this->printVersions($package, $versions, $installedRepo);
  6646. if ($latestPackage) {
  6647. $style = $this->getVersionStyle($latestPackage, $package);
  6648. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  6649. } else {
  6650. $latestPackage = $package;
  6651. }
  6652. $io->write('<info>type</info> : ' . $package->getType());
  6653. $this->printLicenses($package);
  6654. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  6655. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  6656. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  6657. if ($installedRepo->hasPackage($package)) {
  6658. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  6659. }
  6660. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  6661. if ($latestPackage->isAbandoned()) {
  6662. $replacement = ($latestPackage->getReplacementPackage() !== null)
  6663. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  6664. : null;
  6665. $io->writeError(
  6666. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  6667. );
  6668. }
  6669. if ($package->getSupport()) {
  6670. $io->write("\n<info>support</info>");
  6671. foreach ($package->getSupport() as $type => $value) {
  6672. $io->write('<comment>' . $type . '</comment> : '.$value);
  6673. }
  6674. }
  6675. if ($package->getAutoload()) {
  6676. $io->write("\n<info>autoload</info>");
  6677. foreach ($package->getAutoload() as $type => $autoloads) {
  6678. $io->write('<comment>' . $type . '</comment>');
  6679. if ($type === 'psr-0' || $type === 'psr-4') {
  6680. foreach ($autoloads as $name => $path) {
  6681. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  6682. }
  6683. } elseif ($type === 'classmap') {
  6684. $io->write(implode(', ', $autoloads));
  6685. }
  6686. }
  6687. if ($package->getIncludePaths()) {
  6688. $io->write('<comment>include-path</comment>');
  6689. $io->write(implode(', ', $package->getIncludePaths()));
  6690. }
  6691. }
  6692. }
  6693. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
  6694. {
  6695. $versions = array_keys($versions);
  6696. $versions = Semver::rsort($versions);
  6697. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  6698. foreach ($installedPackages as $installedPackage) {
  6699. $installedVersion = $installedPackage->getPrettyVersion();
  6700. $key = array_search($installedVersion, $versions);
  6701. if (false !== $key) {
  6702. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  6703. }
  6704. }
  6705. }
  6706. $versions = implode(', ', $versions);
  6707. $this->getIO()->write('<info>versions</info> : ' . $versions);
  6708. }
  6709. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  6710. {
  6711. $title = $title ?: $linkType;
  6712. $io = $this->getIO();
  6713. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  6714. $io->write("\n<info>" . $title . "</info>");
  6715. foreach ($links as $link) {
  6716. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  6717. }
  6718. }
  6719. }
  6720. protected function printLicenses(CompletePackageInterface $package)
  6721. {
  6722. $spdxLicenses = new SpdxLicenses();
  6723. $licenses = $package->getLicense();
  6724. $io = $this->getIO();
  6725. foreach ($licenses as $licenseId) {
  6726. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6727. if (!$license) {
  6728. $out = $licenseId;
  6729. } else {
  6730. if ($license[1] === true) {
  6731. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  6732. } else {
  6733. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  6734. }
  6735. }
  6736. $io->write('<info>license</info> : ' . $out);
  6737. }
  6738. }
  6739. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6740. {
  6741. $json = array(
  6742. 'name' => $package->getPrettyName(),
  6743. 'description' => $package->getDescription(),
  6744. 'keywords' => $package->getKeywords() ?: array(),
  6745. 'type' => $package->getType(),
  6746. 'homepage' => $package->getHomepage(),
  6747. 'names' => $package->getNames(),
  6748. );
  6749. $json = $this->appendVersions($json, $versions);
  6750. $json = $this->appendLicenses($json, $package);
  6751. if ($latestPackage) {
  6752. $json['latest'] = $latestPackage->getPrettyVersion();
  6753. } else {
  6754. $latestPackage = $package;
  6755. }
  6756. if ($package->getSourceType()) {
  6757. $json['source'] = array(
  6758. 'type' => $package->getSourceType(),
  6759. 'url' => $package->getSourceUrl(),
  6760. 'reference' => $package->getSourceReference(),
  6761. );
  6762. }
  6763. if ($package->getDistType()) {
  6764. $json['dist'] = array(
  6765. 'type' => $package->getDistType(),
  6766. 'url' => $package->getDistUrl(),
  6767. 'reference' => $package->getDistReference(),
  6768. );
  6769. }
  6770. if ($installedRepo->hasPackage($package)) {
  6771. $json['path'] = realpath($this->getComposer()->getInstallationManager()->getInstallPath($package));
  6772. if ($json['path'] === false) {
  6773. unset($json['path']);
  6774. }
  6775. }
  6776. if ($latestPackage->isAbandoned()) {
  6777. $json['replacement'] = $latestPackage->getReplacementPackage();
  6778. }
  6779. if ($package->getSuggests()) {
  6780. $json['suggests'] = $package->getSuggests();
  6781. }
  6782. if ($package->getSupport()) {
  6783. $json['support'] = $package->getSupport();
  6784. }
  6785. $json = $this->appendAutoload($json, $package);
  6786. if ($package->getIncludePaths()) {
  6787. $json['include_path'] = $package->getIncludePaths();
  6788. }
  6789. $json = $this->appendLinks($json, $package);
  6790. $this->getIO()->write(JsonFile::encode($json));
  6791. }
  6792. private function appendVersions($json, array $versions)
  6793. {
  6794. uasort($versions, 'version_compare');
  6795. $versions = array_keys(array_reverse($versions));
  6796. $json['versions'] = $versions;
  6797. return $json;
  6798. }
  6799. private function appendLicenses($json, CompletePackageInterface $package)
  6800. {
  6801. if ($licenses = $package->getLicense()) {
  6802. $spdxLicenses = new SpdxLicenses();
  6803. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  6804. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6805. if (!$license) {
  6806. return $licenseId;
  6807. }
  6808. return array(
  6809. 'name' => $license[0],
  6810. 'osi' => $licenseId,
  6811. 'url' => $license[2],
  6812. );
  6813. }, $licenses);
  6814. }
  6815. return $json;
  6816. }
  6817. private function appendAutoload($json, CompletePackageInterface $package)
  6818. {
  6819. if ($package->getAutoload()) {
  6820. $autoload = array();
  6821. foreach ($package->getAutoload() as $type => $autoloads) {
  6822. if ($type === 'psr-0' || $type === 'psr-4') {
  6823. $psr = array();
  6824. foreach ($autoloads as $name => $path) {
  6825. if (!$path) {
  6826. $path = '.';
  6827. }
  6828. $psr[$name ?: '*'] = $path;
  6829. }
  6830. $autoload[$type] = $psr;
  6831. } elseif ($type === 'classmap') {
  6832. $autoload['classmap'] = $autoloads;
  6833. }
  6834. }
  6835. $json['autoload'] = $autoload;
  6836. }
  6837. return $json;
  6838. }
  6839. private function appendLinks($json, CompletePackageInterface $package)
  6840. {
  6841. foreach (Link::$TYPES as $linkType) {
  6842. $json = $this->appendLink($json, $package, $linkType);
  6843. }
  6844. return $json;
  6845. }
  6846. private function appendLink($json, CompletePackageInterface $package, $linkType)
  6847. {
  6848. $links = $package->{'get' . ucfirst($linkType)}();
  6849. if ($links) {
  6850. $json[$linkType] = array();
  6851. foreach ($links as $link) {
  6852. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  6853. }
  6854. }
  6855. return $json;
  6856. }
  6857. protected function initStyles(OutputInterface $output)
  6858. {
  6859. $this->colors = array(
  6860. 'green',
  6861. 'yellow',
  6862. 'cyan',
  6863. 'magenta',
  6864. 'blue',
  6865. );
  6866. foreach ($this->colors as $color) {
  6867. $style = new OutputFormatterStyle($color);
  6868. $output->getFormatter()->setStyle($color, $style);
  6869. }
  6870. }
  6871. protected function displayPackageTree(array $arrayTree)
  6872. {
  6873. $io = $this->getIO();
  6874. foreach ($arrayTree as $package) {
  6875. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  6876. $io->write(' ' . $package['version'], false);
  6877. $io->write(' ' . strtok($package['description'], "\r\n"));
  6878. if (isset($package['requires'])) {
  6879. $requires = $package['requires'];
  6880. $treeBar = '├';
  6881. $j = 0;
  6882. $total = count($requires);
  6883. foreach ($requires as $require) {
  6884. $requireName = $require['name'];
  6885. $j++;
  6886. if ($j === $total) {
  6887. $treeBar = 'â””';
  6888. }
  6889. $level = 1;
  6890. $color = $this->colors[$level];
  6891. $info = sprintf(
  6892. '%s──<%s>%s</%s> %s',
  6893. $treeBar,
  6894. $color,
  6895. $requireName,
  6896. $color,
  6897. $require['version']
  6898. );
  6899. $this->writeTreeLine($info);
  6900. $treeBar = str_replace('â””', ' ', $treeBar);
  6901. $packagesInTree = array($package['name'], $requireName);
  6902. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  6903. }
  6904. }
  6905. }
  6906. }
  6907. protected function generatePackageTree(
  6908. PackageInterface $package,
  6909. InstalledRepository $installedRepo,
  6910. RepositoryInterface $remoteRepos
  6911. ) {
  6912. $requires = $package->getRequires();
  6913. ksort($requires);
  6914. $children = array();
  6915. foreach ($requires as $requireName => $require) {
  6916. $packagesInTree = array($package->getName(), $requireName);
  6917. $treeChildDesc = array(
  6918. 'name' => $requireName,
  6919. 'version' => $require->getPrettyConstraint(),
  6920. );
  6921. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  6922. if ($deepChildren) {
  6923. $treeChildDesc['requires'] = $deepChildren;
  6924. }
  6925. $children[] = $treeChildDesc;
  6926. }
  6927. $tree = array(
  6928. 'name' => $package->getPrettyName(),
  6929. 'version' => $package->getPrettyVersion(),
  6930. 'description' => $package->getDescription(),
  6931. );
  6932. if ($children) {
  6933. $tree['requires'] = $children;
  6934. }
  6935. return $tree;
  6936. }
  6937. protected function displayTree(
  6938. $package,
  6939. array $packagesInTree,
  6940. $previousTreeBar = '├',
  6941. $level = 1
  6942. ) {
  6943. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  6944. if (is_array($package) && isset($package['requires'])) {
  6945. $requires = $package['requires'];
  6946. $treeBar = $previousTreeBar . ' ├';
  6947. $i = 0;
  6948. $total = count($requires);
  6949. foreach ($requires as $require) {
  6950. $currentTree = $packagesInTree;
  6951. $i++;
  6952. if ($i === $total) {
  6953. $treeBar = $previousTreeBar . ' â””';
  6954. }
  6955. $colorIdent = $level % count($this->colors);
  6956. $color = $this->colors[$colorIdent];
  6957. $circularWarn = in_array(
  6958. $require['name'],
  6959. $currentTree,
  6960. true
  6961. ) ? '(circular dependency aborted here)' : '';
  6962. $info = rtrim(sprintf(
  6963. '%s──<%s>%s</%s> %s %s',
  6964. $treeBar,
  6965. $color,
  6966. $require['name'],
  6967. $color,
  6968. $require['version'],
  6969. $circularWarn
  6970. ));
  6971. $this->writeTreeLine($info);
  6972. $treeBar = str_replace('â””', ' ', $treeBar);
  6973. $currentTree[] = $require['name'];
  6974. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  6975. }
  6976. }
  6977. }
  6978. protected function addTree(
  6979. $name,
  6980. $package,
  6981. InstalledRepository $installedRepo,
  6982. RepositoryInterface $remoteRepos,
  6983. array $packagesInTree
  6984. ) {
  6985. $children = array();
  6986. list($package) = $this->getPackage(
  6987. $installedRepo,
  6988. $remoteRepos,
  6989. $name,
  6990. $package->getPrettyConstraint() === 'self.version' ? $package->getConstraint() : $package->getPrettyConstraint()
  6991. );
  6992. if (is_object($package)) {
  6993. $requires = $package->getRequires();
  6994. ksort($requires);
  6995. foreach ($requires as $requireName => $require) {
  6996. $currentTree = $packagesInTree;
  6997. $treeChildDesc = array(
  6998. 'name' => $requireName,
  6999. 'version' => $require->getPrettyConstraint(),
  7000. );
  7001. if (!in_array($requireName, $currentTree, true)) {
  7002. $currentTree[] = $requireName;
  7003. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  7004. if ($deepChildren) {
  7005. $treeChildDesc['requires'] = $deepChildren;
  7006. }
  7007. }
  7008. $children[] = $treeChildDesc;
  7009. }
  7010. }
  7011. return $children;
  7012. }
  7013. private function updateStatusToVersionStyle($updateStatus)
  7014. {
  7015. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  7016. }
  7017. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  7018. {
  7019. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  7020. return 'up-to-date';
  7021. }
  7022. $constraint = $package->getVersion();
  7023. if (0 !== strpos($constraint, 'dev-')) {
  7024. $constraint = '^'.$constraint;
  7025. }
  7026. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  7027. return 'semver-safe-update';
  7028. }
  7029. return 'update-possible';
  7030. }
  7031. private function writeTreeLine($line)
  7032. {
  7033. $io = $this->getIO();
  7034. if (!$io->isDecorated()) {
  7035. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  7036. }
  7037. $io->write($line);
  7038. }
  7039. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, $minorOnly = false)
  7040. {
  7041. $name = $package->getName();
  7042. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  7043. $stability = $composer->getPackage()->getMinimumStability();
  7044. $flags = $composer->getPackage()->getStabilityFlags();
  7045. if (isset($flags[$name])) {
  7046. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  7047. }
  7048. $bestStability = $stability;
  7049. if ($composer->getPackage()->getPreferStable()) {
  7050. $bestStability = $package->getStability();
  7051. }
  7052. $targetVersion = null;
  7053. if (0 === strpos($package->getVersion(), 'dev-')) {
  7054. $targetVersion = $package->getVersion();
  7055. }
  7056. if ($targetVersion === null && $minorOnly) {
  7057. $targetVersion = '^' . $package->getVersion();
  7058. }
  7059. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability);
  7060. while ($candidate instanceof AliasPackage) {
  7061. $candidate = $candidate->getAliasOf();
  7062. }
  7063. return $candidate;
  7064. }
  7065. private function getRepositorySet(Composer $composer)
  7066. {
  7067. if (!$this->repositorySet) {
  7068. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  7069. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  7070. }
  7071. return $this->repositorySet;
  7072. }
  7073. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  7074. {
  7075. $requires = $package->getRequires();
  7076. foreach ($repo->getPackages() as $candidate) {
  7077. foreach ($candidate->getNames() as $name) {
  7078. if (isset($requires[$name])) {
  7079. if (!in_array($candidate, $bucket, true)) {
  7080. $bucket[] = $candidate;
  7081. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  7082. }
  7083. break;
  7084. }
  7085. }
  7086. }
  7087. return $bucket;
  7088. }
  7089. }
  7090. <?php
  7091. namespace Composer\Command;
  7092. use Symfony\Component\Console\Input\InputInterface;
  7093. use Symfony\Component\Console\Input\InputOption;
  7094. use Symfony\Component\Console\Output\OutputInterface;
  7095. use Composer\Downloader\ChangeReportInterface;
  7096. use Composer\Downloader\DvcsDownloaderInterface;
  7097. use Composer\Downloader\VcsCapableDownloaderInterface;
  7098. use Composer\Package\Dumper\ArrayDumper;
  7099. use Composer\Package\Version\VersionGuesser;
  7100. use Composer\Package\Version\VersionParser;
  7101. use Composer\Plugin\CommandEvent;
  7102. use Composer\Plugin\PluginEvents;
  7103. use Composer\Script\ScriptEvents;
  7104. use Composer\Util\ProcessExecutor;
  7105. class StatusCommand extends BaseCommand
  7106. {
  7107. const EXIT_CODE_ERRORS = 1;
  7108. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  7109. const EXIT_CODE_VERSION_CHANGES = 4;
  7110. protected function configure()
  7111. {
  7112. $this
  7113. ->setName('status')
  7114. ->setDescription('Shows a list of locally modified packages.')
  7115. ->setDefinition(array(
  7116. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  7117. ))
  7118. ->setHelp(
  7119. <<<EOT
  7120. The status command displays a list of dependencies that have
  7121. been modified locally.
  7122. Read more at https://getcomposer.org/doc/03-cli.md#status
  7123. EOT
  7124. )
  7125. ;
  7126. }
  7127. protected function execute(InputInterface $input, OutputInterface $output)
  7128. {
  7129. $composer = $this->getComposer();
  7130. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  7131. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7132. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  7133. $exitCode = $this->doExecute($input);
  7134. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  7135. return $exitCode;
  7136. }
  7137. private function doExecute(InputInterface $input)
  7138. {
  7139. $composer = $this->getComposer();
  7140. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  7141. $dm = $composer->getDownloadManager();
  7142. $im = $composer->getInstallationManager();
  7143. $errors = array();
  7144. $io = $this->getIO();
  7145. $unpushedChanges = array();
  7146. $vcsVersionChanges = array();
  7147. $parser = new VersionParser;
  7148. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  7149. $dumper = new ArrayDumper;
  7150. foreach ($installedRepo->getCanonicalPackages() as $package) {
  7151. $downloader = $dm->getDownloaderForPackage($package);
  7152. $targetDir = $im->getInstallPath($package);
  7153. if ($downloader instanceof ChangeReportInterface) {
  7154. if (is_link($targetDir)) {
  7155. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  7156. }
  7157. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  7158. $errors[$targetDir] = $changes;
  7159. }
  7160. }
  7161. if ($downloader instanceof VcsCapableDownloaderInterface) {
  7162. if ($downloader->getVcsReference($package, $targetDir)) {
  7163. switch ($package->getInstallationSource()) {
  7164. case 'source':
  7165. $previousRef = $package->getSourceReference();
  7166. break;
  7167. case 'dist':
  7168. $previousRef = $package->getDistReference();
  7169. break;
  7170. default:
  7171. $previousRef = null;
  7172. }
  7173. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  7174. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  7175. $vcsVersionChanges[$targetDir] = array(
  7176. 'previous' => array(
  7177. 'version' => $package->getPrettyVersion(),
  7178. 'ref' => $previousRef,
  7179. ),
  7180. 'current' => array(
  7181. 'version' => $currentVersion['pretty_version'],
  7182. 'ref' => $currentVersion['commit'],
  7183. ),
  7184. );
  7185. }
  7186. }
  7187. }
  7188. if ($downloader instanceof DvcsDownloaderInterface) {
  7189. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  7190. $unpushedChanges[$targetDir] = $unpushed;
  7191. }
  7192. }
  7193. }
  7194. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  7195. $io->writeError('<info>No local changes</info>');
  7196. return 0;
  7197. }
  7198. if ($errors) {
  7199. $io->writeError('<error>You have changes in the following dependencies:</error>');
  7200. foreach ($errors as $path => $changes) {
  7201. if ($input->getOption('verbose')) {
  7202. $indentedChanges = implode("\n", array_map(function ($line) {
  7203. return ' ' . ltrim($line);
  7204. }, explode("\n", $changes)));
  7205. $io->write('<info>'.$path.'</info>:');
  7206. $io->write($indentedChanges);
  7207. } else {
  7208. $io->write($path);
  7209. }
  7210. }
  7211. }
  7212. if ($unpushedChanges) {
  7213. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  7214. foreach ($unpushedChanges as $path => $changes) {
  7215. if ($input->getOption('verbose')) {
  7216. $indentedChanges = implode("\n", array_map(function ($line) {
  7217. return ' ' . ltrim($line);
  7218. }, explode("\n", $changes)));
  7219. $io->write('<info>'.$path.'</info>:');
  7220. $io->write($indentedChanges);
  7221. } else {
  7222. $io->write($path);
  7223. }
  7224. }
  7225. }
  7226. if ($vcsVersionChanges) {
  7227. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  7228. foreach ($vcsVersionChanges as $path => $changes) {
  7229. if ($input->getOption('verbose')) {
  7230. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  7231. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  7232. if ($io->isVeryVerbose()) {
  7233. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  7234. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  7235. }
  7236. $io->write('<info>'.$path.'</info>:');
  7237. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  7238. } else {
  7239. $io->write($path);
  7240. }
  7241. }
  7242. }
  7243. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  7244. $io->writeError('Use --verbose (-v) to see a list of files');
  7245. }
  7246. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  7247. }
  7248. }
  7249. <?php
  7250. namespace Composer\Command;
  7251. use Composer\Repository\PlatformRepository;
  7252. use Composer\Repository\RootPackageRepository;
  7253. use Composer\Repository\InstalledRepository;
  7254. use Composer\Installer\SuggestedPackagesReporter;
  7255. use Symfony\Component\Console\Input\InputArgument;
  7256. use Symfony\Component\Console\Input\InputInterface;
  7257. use Symfony\Component\Console\Input\InputOption;
  7258. use Symfony\Component\Console\Output\OutputInterface;
  7259. class SuggestsCommand extends BaseCommand
  7260. {
  7261. protected function configure()
  7262. {
  7263. $this
  7264. ->setName('suggests')
  7265. ->setDescription('Shows package suggestions.')
  7266. ->setDefinition(array(
  7267. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  7268. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  7269. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  7270. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  7271. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  7272. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  7273. ))
  7274. ->setHelp(
  7275. <<<EOT
  7276. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  7277. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  7278. EOT
  7279. )
  7280. ;
  7281. }
  7282. protected function execute(InputInterface $input, OutputInterface $output)
  7283. {
  7284. $composer = $this->getComposer();
  7285. $installedRepos = array(
  7286. new RootPackageRepository(clone $composer->getPackage()),
  7287. );
  7288. $locker = $composer->getLocker();
  7289. if ($locker->isLocked()) {
  7290. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  7291. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7292. } else {
  7293. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  7294. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  7295. }
  7296. $installedRepo = new InstalledRepository($installedRepos);
  7297. $reporter = new SuggestedPackagesReporter($this->getIO());
  7298. $filter = $input->getArgument('packages');
  7299. $packages = $installedRepo->getPackages();
  7300. $packages[] = $composer->getPackage();
  7301. foreach ($packages as $package) {
  7302. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  7303. continue;
  7304. }
  7305. $reporter->addSuggestionsFromPackage($package);
  7306. }
  7307. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7308. if ($input->getOption('by-suggestion')) {
  7309. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  7310. }
  7311. if ($input->getOption('by-package')) {
  7312. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7313. }
  7314. if ($input->getOption('list')) {
  7315. $mode = SuggestedPackagesReporter::MODE_LIST;
  7316. }
  7317. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  7318. return 0;
  7319. }
  7320. }
  7321. <?php
  7322. namespace Composer\Command;
  7323. use Composer\Composer;
  7324. use Composer\DependencyResolver\Request;
  7325. use Composer\Installer;
  7326. use Composer\IO\IOInterface;
  7327. use Composer\Plugin\CommandEvent;
  7328. use Composer\Plugin\PluginEvents;
  7329. use Composer\Package\Version\VersionParser;
  7330. use Composer\Util\HttpDownloader;
  7331. use Composer\Semver\Constraint\MultiConstraint;
  7332. use Composer\Package\Link;
  7333. use Symfony\Component\Console\Helper\Table;
  7334. use Symfony\Component\Console\Input\InputInterface;
  7335. use Symfony\Component\Console\Input\InputOption;
  7336. use Symfony\Component\Console\Input\InputArgument;
  7337. use Symfony\Component\Console\Output\OutputInterface;
  7338. use Symfony\Component\Console\Question\Question;
  7339. class UpdateCommand extends BaseCommand
  7340. {
  7341. protected function configure()
  7342. {
  7343. $this
  7344. ->setName('update')
  7345. ->setAliases(array('u', 'upgrade'))
  7346. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  7347. ->setDefinition(array(
  7348. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  7349. 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'),
  7350. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  7351. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  7352. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  7353. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  7354. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  7355. 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.'),
  7356. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  7357. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  7358. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  7359. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  7360. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7361. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  7362. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  7363. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  7364. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  7365. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  7366. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  7367. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  7368. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  7369. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  7370. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  7371. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  7372. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  7373. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  7374. ))
  7375. ->setHelp(
  7376. <<<EOT
  7377. The <info>update</info> command reads the composer.json file from the
  7378. current directory, processes it, and updates, removes or installs all the
  7379. dependencies.
  7380. <info>php composer.phar update</info>
  7381. To limit the update operation to a few packages, you can list the package(s)
  7382. you want to update as such:
  7383. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  7384. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  7385. from a specific vendor:
  7386. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  7387. To run an update with more restrictive constraints you can use:
  7388. <info>php composer.phar update --with vendor/package:1.0.*</info>
  7389. To run a partial update with more restrictive constraints you can use the shorthand:
  7390. <info>php composer.phar update vendor/package:1.0.*</info>
  7391. To select packages names interactively with auto-completion use <info>-i</info>.
  7392. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  7393. EOT
  7394. )
  7395. ;
  7396. }
  7397. protected function execute(InputInterface $input, OutputInterface $output)
  7398. {
  7399. $io = $this->getIO();
  7400. if ($input->getOption('dev')) {
  7401. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  7402. }
  7403. if ($input->getOption('no-suggest')) {
  7404. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  7405. }
  7406. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  7407. if (!HttpDownloader::isCurlEnabled()) {
  7408. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  7409. }
  7410. $packages = $input->getArgument('packages');
  7411. $reqs = $this->formatRequirements($input->getOption('with'));
  7412. if ($packages) {
  7413. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg) {
  7414. return preg_match('{\S+[ =:]\S+}', $pkg) > 0;
  7415. });
  7416. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  7417. $reqs[$package] = $constraint;
  7418. }
  7419. foreach ($allowlistPackagesWithRequirements as $package) {
  7420. $packageName = preg_replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  7421. $index = array_search($package, $packages);
  7422. $packages[$index] = $packageName;
  7423. }
  7424. }
  7425. $rootRequires = $composer->getPackage()->getRequires();
  7426. $rootDevRequires = $composer->getPackage()->getDevRequires();
  7427. foreach ($reqs as $package => $constraint) {
  7428. if (isset($rootRequires[$package])) {
  7429. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  7430. } elseif (isset($rootDevRequires[$package])) {
  7431. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  7432. } else {
  7433. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  7434. }
  7435. }
  7436. $composer->getPackage()->setRequires($rootRequires);
  7437. $composer->getPackage()->setDevRequires($rootDevRequires);
  7438. if ($input->getOption('interactive')) {
  7439. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  7440. }
  7441. if ($input->getOption('root-reqs')) {
  7442. $requires = array_keys($rootRequires);
  7443. if (!$input->getOption('no-dev')) {
  7444. $requires = array_merge($requires, array_keys($rootDevRequires));
  7445. }
  7446. if (!empty($packages)) {
  7447. $packages = array_intersect($packages, $requires);
  7448. } else {
  7449. $packages = $requires;
  7450. }
  7451. }
  7452. $filteredPackages = array_filter($packages, function ($package) {
  7453. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  7454. });
  7455. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  7456. $packages = $filteredPackages;
  7457. if ($updateMirrors && !empty($packages)) {
  7458. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  7459. return -1;
  7460. }
  7461. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  7462. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7463. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7464. $install = Installer::create($io, $composer);
  7465. $config = $composer->getConfig();
  7466. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  7467. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  7468. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  7469. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7470. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  7471. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7472. if ($input->getOption('with-all-dependencies')) {
  7473. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7474. } elseif ($input->getOption('with-dependencies')) {
  7475. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7476. }
  7477. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  7478. $install
  7479. ->setDryRun($input->getOption('dry-run'))
  7480. ->setVerbose($input->getOption('verbose'))
  7481. ->setPreferSource($preferSource)
  7482. ->setPreferDist($preferDist)
  7483. ->setDevMode(!$input->getOption('no-dev'))
  7484. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  7485. ->setRunScripts(!$input->getOption('no-scripts'))
  7486. ->setOptimizeAutoloader($optimize)
  7487. ->setClassMapAuthoritative($authoritative)
  7488. ->setApcuAutoloader($apcu, $apcuPrefix)
  7489. ->setUpdate(true)
  7490. ->setInstall(!$input->getOption('no-install'))
  7491. ->setUpdateMirrors($updateMirrors)
  7492. ->setUpdateAllowList($packages)
  7493. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7494. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  7495. ->setPreferStable($input->getOption('prefer-stable'))
  7496. ->setPreferLowest($input->getOption('prefer-lowest'))
  7497. ;
  7498. if ($input->getOption('no-plugins')) {
  7499. $install->disablePlugins();
  7500. }
  7501. return $install->run();
  7502. }
  7503. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  7504. {
  7505. if (!$input->isInteractive()) {
  7506. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  7507. }
  7508. $requires = array_merge(
  7509. $composer->getPackage()->getRequires(),
  7510. $composer->getPackage()->getDevRequires()
  7511. );
  7512. $autocompleterValues = array();
  7513. foreach ($requires as $require) {
  7514. $target = $require->getTarget();
  7515. $autocompleterValues[strtolower($target)] = $target;
  7516. }
  7517. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  7518. foreach ($installedPackages as $package) {
  7519. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  7520. }
  7521. $helper = $this->getHelper('question');
  7522. $question = new Question('<comment>Enter package name: </comment>', null);
  7523. $io->writeError('<info>Press enter without value to end submission</info>');
  7524. do {
  7525. $autocompleterValues = array_diff($autocompleterValues, $packages);
  7526. $question->setAutocompleterValues($autocompleterValues);
  7527. $addedPackage = $helper->ask($input, $output, $question);
  7528. if (!is_string($addedPackage) || empty($addedPackage)) {
  7529. break;
  7530. }
  7531. $addedPackage = strtolower($addedPackage);
  7532. if (!in_array($addedPackage, $packages)) {
  7533. $packages[] = $addedPackage;
  7534. }
  7535. } while (true);
  7536. $packages = array_filter($packages);
  7537. if (!$packages) {
  7538. throw new \InvalidArgumentException('You must enter minimum one package.');
  7539. }
  7540. $table = new Table($output);
  7541. $table->setHeaders(array('Selected packages'));
  7542. foreach ($packages as $package) {
  7543. $table->addRow(array($package));
  7544. }
  7545. $table->render();
  7546. if ($io->askConfirmation(sprintf(
  7547. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  7548. 1 === count($packages) ? '' : 's'
  7549. ))) {
  7550. return $packages;
  7551. }
  7552. throw new \RuntimeException('Installation aborted.');
  7553. }
  7554. private function appendConstraintToLink(Link $link, $constraint)
  7555. {
  7556. $parser = new VersionParser;
  7557. $oldPrettyString = $link->getConstraint()->getPrettyString();
  7558. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  7559. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  7560. return new Link(
  7561. $link->getSource(),
  7562. $link->getTarget(),
  7563. $newConstraint,
  7564. $link->getDescription(),
  7565. $link->getPrettyConstraint() . ', ' . $constraint
  7566. );
  7567. }
  7568. }
  7569. <?php
  7570. namespace Composer\Command;
  7571. use Composer\Factory;
  7572. use Composer\Package\Loader\ValidatingArrayLoader;
  7573. use Composer\Plugin\CommandEvent;
  7574. use Composer\Plugin\PluginEvents;
  7575. use Composer\Util\ConfigValidator;
  7576. use Symfony\Component\Console\Input\InputArgument;
  7577. use Symfony\Component\Console\Input\InputInterface;
  7578. use Symfony\Component\Console\Input\InputOption;
  7579. use Symfony\Component\Console\Output\OutputInterface;
  7580. class ValidateCommand extends BaseCommand
  7581. {
  7582. protected function configure()
  7583. {
  7584. $this
  7585. ->setName('validate')
  7586. ->setDescription('Validates a composer.json and composer.lock.')
  7587. ->setDefinition(array(
  7588. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  7589. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  7590. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  7591. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  7592. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  7593. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  7594. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  7595. ))
  7596. ->setHelp(
  7597. <<<EOT
  7598. The validate command validates a given composer.json and composer.lock
  7599. Exit codes in case of errors are:
  7600. 1 validation warning(s), only when --strict is given
  7601. 2 validation error(s)
  7602. 3 file unreadable or missing
  7603. Read more at https://getcomposer.org/doc/03-cli.md#validate
  7604. EOT
  7605. );
  7606. }
  7607. protected function execute(InputInterface $input, OutputInterface $output)
  7608. {
  7609. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  7610. $io = $this->getIO();
  7611. if (!file_exists($file)) {
  7612. $io->writeError('<error>' . $file . ' not found.</error>');
  7613. return 3;
  7614. }
  7615. if (!is_readable($file)) {
  7616. $io->writeError('<error>' . $file . ' is not readable.</error>');
  7617. return 3;
  7618. }
  7619. $validator = new ConfigValidator($io);
  7620. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  7621. $checkPublish = !$input->getOption('no-check-publish');
  7622. $checkLock = !$input->getOption('no-check-lock');
  7623. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  7624. $isStrict = $input->getOption('strict');
  7625. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7626. $lockErrors = array();
  7627. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  7628. $locker = $composer->getLocker();
  7629. if ($locker->isLocked() && !$locker->isFresh()) {
  7630. $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>`.';
  7631. }
  7632. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  7633. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7634. if ($input->getOption('with-dependencies')) {
  7635. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7636. foreach ($localRepo->getPackages() as $package) {
  7637. $path = $composer->getInstallationManager()->getInstallPath($package);
  7638. $file = $path . '/composer.json';
  7639. if (is_dir($path) && file_exists($file)) {
  7640. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7641. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  7642. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7643. $exitCode = max($depCode, $exitCode);
  7644. }
  7645. }
  7646. }
  7647. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  7648. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7649. return max($eventCode, $exitCode);
  7650. }
  7651. private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false)
  7652. {
  7653. $doPrintSchemaUrl = false;
  7654. if ($errors) {
  7655. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  7656. } elseif ($publishErrors) {
  7657. $io->writeError('<info>' . $name . ' is valid for simple usage with composer but has</info>');
  7658. $io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
  7659. $doPrintSchemaUrl = $printSchemaUrl;
  7660. } elseif ($warnings) {
  7661. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  7662. $doPrintSchemaUrl = $printSchemaUrl;
  7663. } else {
  7664. $io->write('<info>' . $name . ' is valid</info>');
  7665. }
  7666. if ($doPrintSchemaUrl) {
  7667. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  7668. }
  7669. $extraWarnings = array();
  7670. if ($checkPublish) {
  7671. $errors = array_merge($errors, $publishErrors);
  7672. } else {
  7673. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  7674. }
  7675. if ($checkLock) {
  7676. $errors = array_merge($errors, $lockErrors);
  7677. } else {
  7678. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  7679. }
  7680. $messages = array(
  7681. 'error' => $errors,
  7682. 'warning' => array_merge($warnings, $extraWarnings),
  7683. );
  7684. foreach ($messages as $style => $msgs) {
  7685. foreach ($msgs as $msg) {
  7686. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  7687. }
  7688. }
  7689. }
  7690. }
  7691. <?php
  7692. namespace Composer;
  7693. use Composer\Package\RootPackageInterface;
  7694. use Composer\Package\Locker;
  7695. use Composer\Util\Loop;
  7696. use Composer\Repository\RepositoryManager;
  7697. use Composer\Installer\InstallationManager;
  7698. use Composer\Plugin\PluginManager;
  7699. use Composer\Downloader\DownloadManager;
  7700. use Composer\EventDispatcher\EventDispatcher;
  7701. use Composer\Autoload\AutoloadGenerator;
  7702. use Composer\Package\Archiver\ArchiveManager;
  7703. class Composer
  7704. {
  7705. const VERSION = '2.0.13';
  7706. const BRANCH_ALIAS_VERSION = '';
  7707. const RELEASE_DATE = '2021-04-27 13:11:08';
  7708. const SOURCE_VERSION = '';
  7709. const RUNTIME_API_VERSION = '2.0.0';
  7710. public static function getVersion()
  7711. {
  7712. if (self::VERSION === '@package_version'.'@') {
  7713. return self::SOURCE_VERSION;
  7714. }
  7715. if (self::BRANCH_ALIAS_VERSION !== '' && preg_match('{^[a-f0-9]{40}$}', self::VERSION)) {
  7716. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  7717. }
  7718. return self::VERSION;
  7719. }
  7720. private $package;
  7721. private $locker;
  7722. private $loop;
  7723. private $repositoryManager;
  7724. private $downloadManager;
  7725. private $installationManager;
  7726. private $pluginManager;
  7727. private $config;
  7728. private $eventDispatcher;
  7729. private $autoloadGenerator;
  7730. private $archiveManager;
  7731. public function setPackage(RootPackageInterface $package)
  7732. {
  7733. $this->package = $package;
  7734. }
  7735. public function getPackage()
  7736. {
  7737. return $this->package;
  7738. }
  7739. public function setConfig(Config $config)
  7740. {
  7741. $this->config = $config;
  7742. }
  7743. public function getConfig()
  7744. {
  7745. return $this->config;
  7746. }
  7747. public function setLocker(Locker $locker)
  7748. {
  7749. $this->locker = $locker;
  7750. }
  7751. public function getLocker()
  7752. {
  7753. return $this->locker;
  7754. }
  7755. public function setLoop(Loop $loop)
  7756. {
  7757. $this->loop = $loop;
  7758. }
  7759. public function getLoop()
  7760. {
  7761. return $this->loop;
  7762. }
  7763. public function setRepositoryManager(RepositoryManager $manager)
  7764. {
  7765. $this->repositoryManager = $manager;
  7766. }
  7767. public function getRepositoryManager()
  7768. {
  7769. return $this->repositoryManager;
  7770. }
  7771. public function setDownloadManager(DownloadManager $manager)
  7772. {
  7773. $this->downloadManager = $manager;
  7774. }
  7775. public function getDownloadManager()
  7776. {
  7777. return $this->downloadManager;
  7778. }
  7779. public function setArchiveManager(ArchiveManager $manager)
  7780. {
  7781. $this->archiveManager = $manager;
  7782. }
  7783. public function getArchiveManager()
  7784. {
  7785. return $this->archiveManager;
  7786. }
  7787. public function setInstallationManager(InstallationManager $manager)
  7788. {
  7789. $this->installationManager = $manager;
  7790. }
  7791. public function getInstallationManager()
  7792. {
  7793. return $this->installationManager;
  7794. }
  7795. public function setPluginManager(PluginManager $manager)
  7796. {
  7797. $this->pluginManager = $manager;
  7798. }
  7799. public function getPluginManager()
  7800. {
  7801. return $this->pluginManager;
  7802. }
  7803. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  7804. {
  7805. $this->eventDispatcher = $eventDispatcher;
  7806. }
  7807. public function getEventDispatcher()
  7808. {
  7809. return $this->eventDispatcher;
  7810. }
  7811. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  7812. {
  7813. $this->autoloadGenerator = $autoloadGenerator;
  7814. }
  7815. public function getAutoloadGenerator()
  7816. {
  7817. return $this->autoloadGenerator;
  7818. }
  7819. }
  7820. <?php
  7821. namespace Composer;
  7822. use Composer\Config\ConfigSourceInterface;
  7823. use Composer\Downloader\TransportException;
  7824. use Composer\IO\IOInterface;
  7825. use Composer\Util\Platform;
  7826. use Composer\Util\ProcessExecutor;
  7827. class Config
  7828. {
  7829. const RELATIVE_PATHS = 1;
  7830. public static $defaultConfig = array(
  7831. 'process-timeout' => 300,
  7832. 'use-include-path' => false,
  7833. 'preferred-install' => 'auto',
  7834. 'notify-on-install' => true,
  7835. 'github-protocols' => array('https', 'ssh', 'git'),
  7836. 'vendor-dir' => 'vendor',
  7837. 'bin-dir' => '{$vendor-dir}/bin',
  7838. 'cache-dir' => '{$home}/cache',
  7839. 'data-dir' => '{$home}',
  7840. 'cache-files-dir' => '{$cache-dir}/files',
  7841. 'cache-repo-dir' => '{$cache-dir}/repo',
  7842. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  7843. 'cache-ttl' => 15552000,
  7844. 'cache-files-ttl' => null,
  7845. 'cache-files-maxsize' => '300MiB',
  7846. 'cache-read-only' => false,
  7847. 'bin-compat' => 'auto',
  7848. 'discard-changes' => false,
  7849. 'autoloader-suffix' => null,
  7850. 'sort-packages' => false,
  7851. 'optimize-autoloader' => false,
  7852. 'classmap-authoritative' => false,
  7853. 'apcu-autoloader' => false,
  7854. 'prepend-autoloader' => true,
  7855. 'github-domains' => array('github.com'),
  7856. 'bitbucket-expose-hostname' => true,
  7857. 'disable-tls' => false,
  7858. 'secure-http' => true,
  7859. 'cafile' => null,
  7860. 'capath' => null,
  7861. 'github-expose-hostname' => true,
  7862. 'gitlab-domains' => array('gitlab.com'),
  7863. 'store-auths' => 'prompt',
  7864. 'platform' => array(),
  7865. 'archive-format' => 'tar',
  7866. 'archive-dir' => '.',
  7867. 'htaccess-protect' => true,
  7868. 'use-github-api' => true,
  7869. 'lock' => true,
  7870. 'platform-check' => 'php-only',
  7871. );
  7872. public static $defaultRepositories = array(
  7873. 'packagist.org' => array(
  7874. 'type' => 'composer',
  7875. 'url' => 'https://repo.packagist.org',
  7876. ),
  7877. );
  7878. private $config;
  7879. private $baseDir;
  7880. private $repositories;
  7881. private $configSource;
  7882. private $authConfigSource;
  7883. private $useEnvironment;
  7884. private $warnedHosts = array();
  7885. public function __construct($useEnvironment = true, $baseDir = null)
  7886. {
  7887. $this->config = static::$defaultConfig;
  7888. $this->repositories = static::$defaultRepositories;
  7889. $this->useEnvironment = (bool) $useEnvironment;
  7890. $this->baseDir = $baseDir;
  7891. }
  7892. public function setConfigSource(ConfigSourceInterface $source)
  7893. {
  7894. $this->configSource = $source;
  7895. }
  7896. public function getConfigSource()
  7897. {
  7898. return $this->configSource;
  7899. }
  7900. public function setAuthConfigSource(ConfigSourceInterface $source)
  7901. {
  7902. $this->authConfigSource = $source;
  7903. }
  7904. public function getAuthConfigSource()
  7905. {
  7906. return $this->authConfigSource;
  7907. }
  7908. public function merge($config)
  7909. {
  7910. if (!empty($config['config']) && is_array($config['config'])) {
  7911. foreach ($config['config'] as $key => $val) {
  7912. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer')) && isset($this->config[$key])) {
  7913. $this->config[$key] = array_merge($this->config[$key], $val);
  7914. } elseif (in_array($key, array('gitlab-domains', 'github-domains')) && isset($this->config[$key])) {
  7915. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  7916. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  7917. if (is_array($val) || is_array($this->config[$key])) {
  7918. if (is_string($val)) {
  7919. $val = array('*' => $val);
  7920. }
  7921. if (is_string($this->config[$key])) {
  7922. $this->config[$key] = array('*' => $this->config[$key]);
  7923. }
  7924. $this->config[$key] = array_merge($this->config[$key], $val);
  7925. if (isset($this->config[$key]['*'])) {
  7926. $wildcard = $this->config[$key]['*'];
  7927. unset($this->config[$key]['*']);
  7928. $this->config[$key]['*'] = $wildcard;
  7929. }
  7930. } else {
  7931. $this->config[$key] = $val;
  7932. }
  7933. } else {
  7934. $this->config[$key] = $val;
  7935. }
  7936. }
  7937. }
  7938. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  7939. $this->repositories = array_reverse($this->repositories, true);
  7940. $newRepos = array_reverse($config['repositories'], true);
  7941. foreach ($newRepos as $name => $repository) {
  7942. if (false === $repository) {
  7943. $this->disableRepoByName($name);
  7944. continue;
  7945. }
  7946. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  7947. $this->disableRepoByName(key($repository));
  7948. continue;
  7949. }
  7950. if (isset($repository['type'], $repository['url']) && $repository['type'] === 'composer' && preg_match('{^https?://(?:[a-z0-9-.]+\.)?packagist.org(/|$)}', $repository['url'])) {
  7951. $this->disableRepoByName('packagist.org');
  7952. }
  7953. if (is_int($name)) {
  7954. $this->repositories[] = $repository;
  7955. } else {
  7956. if ($name === 'packagist') {
  7957. $this->repositories[$name . '.org'] = $repository;
  7958. } else {
  7959. $this->repositories[$name] = $repository;
  7960. }
  7961. }
  7962. }
  7963. $this->repositories = array_reverse($this->repositories, true);
  7964. }
  7965. }
  7966. public function getRepositories()
  7967. {
  7968. return $this->repositories;
  7969. }
  7970. public function get($key, $flags = 0)
  7971. {
  7972. switch ($key) {
  7973. case 'vendor-dir':
  7974. case 'bin-dir':
  7975. case 'process-timeout':
  7976. case 'data-dir':
  7977. case 'cache-dir':
  7978. case 'cache-files-dir':
  7979. case 'cache-repo-dir':
  7980. case 'cache-vcs-dir':
  7981. case 'cafile':
  7982. case 'capath':
  7983. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7984. $val = $this->getComposerEnv($env);
  7985. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  7986. $val = Platform::expandPath($val);
  7987. if (substr($key, -4) !== '-dir') {
  7988. return $val;
  7989. }
  7990. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  7991. case 'cache-read-only':
  7992. case 'htaccess-protect':
  7993. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7994. $val = $this->getComposerEnv($env);
  7995. if (false === $val) {
  7996. $val = $this->config[$key];
  7997. }
  7998. return $val !== 'false' && (bool) $val;
  7999. case 'disable-tls':
  8000. case 'secure-http':
  8001. case 'use-github-api':
  8002. case 'lock':
  8003. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  8004. return false;
  8005. }
  8006. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  8007. case 'cache-ttl':
  8008. return (int) $this->config[$key];
  8009. case 'cache-files-maxsize':
  8010. if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  8011. throw new \RuntimeException(
  8012. "Could not parse the value of '$key': {$this->config[$key]}"
  8013. );
  8014. }
  8015. $size = $matches[1];
  8016. if (isset($matches[2])) {
  8017. switch (strtolower($matches[2])) {
  8018. case 'g':
  8019. $size *= 1024;
  8020. case 'm':
  8021. $size *= 1024;
  8022. case 'k':
  8023. $size *= 1024;
  8024. break;
  8025. }
  8026. }
  8027. return $size;
  8028. case 'cache-files-ttl':
  8029. if (isset($this->config[$key])) {
  8030. return (int) $this->config[$key];
  8031. }
  8032. return (int) $this->config['cache-ttl'];
  8033. case 'home':
  8034. $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  8035. return rtrim($this->process($val, $flags), '/\\');
  8036. case 'bin-compat':
  8037. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  8038. if (!in_array($value, array('auto', 'full'))) {
  8039. throw new \RuntimeException(
  8040. "Invalid value for 'bin-compat': {$value}. Expected auto, full"
  8041. );
  8042. }
  8043. return $value;
  8044. case 'discard-changes':
  8045. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  8046. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  8047. throw new \RuntimeException(
  8048. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  8049. );
  8050. }
  8051. if ('stash' === $env) {
  8052. return 'stash';
  8053. }
  8054. return $env !== 'false' && (bool) $env;
  8055. }
  8056. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  8057. throw new \RuntimeException(
  8058. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  8059. );
  8060. }
  8061. return $this->config[$key];
  8062. case 'github-protocols':
  8063. $protos = $this->config['github-protocols'];
  8064. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  8065. unset($protos[$index]);
  8066. }
  8067. if (reset($protos) === 'http') {
  8068. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  8069. }
  8070. return $protos;
  8071. default:
  8072. if (!isset($this->config[$key])) {
  8073. return null;
  8074. }
  8075. return $this->process($this->config[$key], $flags);
  8076. }
  8077. }
  8078. public function all($flags = 0)
  8079. {
  8080. $all = array(
  8081. 'repositories' => $this->getRepositories(),
  8082. );
  8083. foreach (array_keys($this->config) as $key) {
  8084. $all['config'][$key] = $this->get($key, $flags);
  8085. }
  8086. return $all;
  8087. }
  8088. public function raw()
  8089. {
  8090. return array(
  8091. 'repositories' => $this->getRepositories(),
  8092. 'config' => $this->config,
  8093. );
  8094. }
  8095. public function has($key)
  8096. {
  8097. return array_key_exists($key, $this->config);
  8098. }
  8099. private function process($value, $flags)
  8100. {
  8101. $config = $this;
  8102. if (!is_string($value)) {
  8103. return $value;
  8104. }
  8105. return preg_replace_callback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  8106. return $config->get($match[1], $flags);
  8107. }, $value);
  8108. }
  8109. private function realpath($path)
  8110. {
  8111. if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  8112. return $path;
  8113. }
  8114. return $this->baseDir . '/' . $path;
  8115. }
  8116. private function getComposerEnv($var)
  8117. {
  8118. if ($this->useEnvironment) {
  8119. return getenv($var);
  8120. }
  8121. return false;
  8122. }
  8123. private function disableRepoByName($name)
  8124. {
  8125. if (isset($this->repositories[$name])) {
  8126. unset($this->repositories[$name]);
  8127. } elseif ($name === 'packagist') {
  8128. unset($this->repositories['packagist.org']);
  8129. }
  8130. }
  8131. public function prohibitUrlByConfig($url, IOInterface $io = null)
  8132. {
  8133. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  8134. return;
  8135. }
  8136. $scheme = parse_url($url, PHP_URL_SCHEME);
  8137. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  8138. if ($this->get('secure-http')) {
  8139. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  8140. }
  8141. if ($io) {
  8142. $host = parse_url($url, PHP_URL_HOST);
  8143. if (!isset($this->warnedHosts[$host])) {
  8144. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  8145. }
  8146. $this->warnedHosts[$host] = true;
  8147. }
  8148. }
  8149. }
  8150. public static function disableProcessTimeout()
  8151. {
  8152. ProcessExecutor::setTimeout(0);
  8153. }
  8154. }
  8155. <?php
  8156. namespace Composer\Config;
  8157. interface ConfigSourceInterface
  8158. {
  8159. public function addRepository($name, $config, $append = true);
  8160. public function removeRepository($name);
  8161. public function addConfigSetting($name, $value);
  8162. public function removeConfigSetting($name);
  8163. public function addProperty($name, $value);
  8164. public function removeProperty($name);
  8165. public function addLink($type, $name, $value);
  8166. public function removeLink($type, $name);
  8167. public function getName();
  8168. }
  8169. <?php
  8170. namespace Composer\Config;
  8171. use Composer\Json\JsonFile;
  8172. use Composer\Json\JsonManipulator;
  8173. use Composer\Json\JsonValidationException;
  8174. use Composer\Util\Silencer;
  8175. class JsonConfigSource implements ConfigSourceInterface
  8176. {
  8177. private $file;
  8178. private $authConfig;
  8179. public function __construct(JsonFile $file, $authConfig = false)
  8180. {
  8181. $this->file = $file;
  8182. $this->authConfig = $authConfig;
  8183. }
  8184. public function getName()
  8185. {
  8186. return $this->file->getPath();
  8187. }
  8188. public function addRepository($name, $config, $append = true)
  8189. {
  8190. $this->manipulateJson('addRepository', $name, $config, $append, function (&$config, $repo, $repoConfig) use ($append) {
  8191. if (isset($config['repositories'])) {
  8192. foreach ($config['repositories'] as $index => $val) {
  8193. if ($index === $repo) {
  8194. continue;
  8195. }
  8196. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  8197. unset($config['repositories'][$index]);
  8198. $config['repositories']['packagist.org'] = false;
  8199. break;
  8200. }
  8201. }
  8202. }
  8203. if ($append) {
  8204. $config['repositories'][$repo] = $repoConfig;
  8205. } else {
  8206. $config['repositories'] = array($repo => $repoConfig) + $config['repositories'];
  8207. }
  8208. });
  8209. }
  8210. public function removeRepository($name)
  8211. {
  8212. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  8213. unset($config['repositories'][$repo]);
  8214. });
  8215. }
  8216. public function addConfigSetting($name, $value)
  8217. {
  8218. $authConfig = $this->authConfig;
  8219. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  8220. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8221. list($key, $host) = explode('.', $key, 2);
  8222. if ($authConfig) {
  8223. $config[$key][$host] = $val;
  8224. } else {
  8225. $config['config'][$key][$host] = $val;
  8226. }
  8227. } else {
  8228. $config['config'][$key] = $val;
  8229. }
  8230. });
  8231. }
  8232. public function removeConfigSetting($name)
  8233. {
  8234. $authConfig = $this->authConfig;
  8235. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  8236. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8237. list($key, $host) = explode('.', $key, 2);
  8238. if ($authConfig) {
  8239. unset($config[$key][$host]);
  8240. } else {
  8241. unset($config['config'][$key][$host]);
  8242. }
  8243. } else {
  8244. unset($config['config'][$key]);
  8245. }
  8246. });
  8247. }
  8248. public function addProperty($name, $value)
  8249. {
  8250. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  8251. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8252. $bits = explode('.', $key);
  8253. $last = array_pop($bits);
  8254. $arr = &$config[reset($bits)];
  8255. foreach ($bits as $bit) {
  8256. if (!isset($arr[$bit])) {
  8257. $arr[$bit] = array();
  8258. }
  8259. $arr = &$arr[$bit];
  8260. }
  8261. $arr[$last] = $val;
  8262. } else {
  8263. $config[$key] = $val;
  8264. }
  8265. });
  8266. }
  8267. public function removeProperty($name)
  8268. {
  8269. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  8270. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8271. $bits = explode('.', $key);
  8272. $last = array_pop($bits);
  8273. $arr = &$config[reset($bits)];
  8274. foreach ($bits as $bit) {
  8275. if (!isset($arr[$bit])) {
  8276. return;
  8277. }
  8278. $arr = &$arr[$bit];
  8279. }
  8280. unset($arr[$last]);
  8281. } else {
  8282. unset($config[$key]);
  8283. }
  8284. });
  8285. }
  8286. public function addLink($type, $name, $value)
  8287. {
  8288. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  8289. $config[$type][$name] = $value;
  8290. });
  8291. }
  8292. public function removeLink($type, $name)
  8293. {
  8294. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  8295. unset($config[$type][$name]);
  8296. });
  8297. $this->manipulateJson('removeMainKeyIfEmpty', $type, function (&$config, $type) {
  8298. if (0 === count($config[$type])) {
  8299. unset($config[$type]);
  8300. }
  8301. });
  8302. }
  8303. protected function manipulateJson($method, $args, $fallback)
  8304. {
  8305. $args = func_get_args();
  8306. array_shift($args);
  8307. $fallback = array_pop($args);
  8308. if ($this->file->exists()) {
  8309. if (!is_writable($this->file->getPath())) {
  8310. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  8311. }
  8312. if (!is_readable($this->file->getPath())) {
  8313. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  8314. }
  8315. $contents = file_get_contents($this->file->getPath());
  8316. } elseif ($this->authConfig) {
  8317. $contents = "{\n}\n";
  8318. } else {
  8319. $contents = "{\n \"config\": {\n }\n}\n";
  8320. }
  8321. $manipulator = new JsonManipulator($contents);
  8322. $newFile = !$this->file->exists();
  8323. if ($this->authConfig && $method === 'addConfigSetting') {
  8324. $method = 'addSubNode';
  8325. list($mainNode, $name) = explode('.', $args[0], 2);
  8326. $args = array($mainNode, $name, $args[1]);
  8327. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  8328. $method = 'removeSubNode';
  8329. list($mainNode, $name) = explode('.', $args[0], 2);
  8330. $args = array($mainNode, $name);
  8331. }
  8332. if (call_user_func_array(array($manipulator, $method), $args)) {
  8333. file_put_contents($this->file->getPath(), $manipulator->getContents());
  8334. } else {
  8335. $config = $this->file->read();
  8336. $this->arrayUnshiftRef($args, $config);
  8337. call_user_func_array($fallback, $args);
  8338. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support') as $prop) {
  8339. if (isset($config[$prop]) && $config[$prop] === array()) {
  8340. $config[$prop] = new \stdClass;
  8341. }
  8342. }
  8343. foreach (array('psr-0', 'psr-4') as $prop) {
  8344. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === array()) {
  8345. $config['autoload'][$prop] = new \stdClass;
  8346. }
  8347. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === array()) {
  8348. $config['autoload-dev'][$prop] = new \stdClass;
  8349. }
  8350. }
  8351. foreach (array('platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install') as $prop) {
  8352. if (isset($config['config'][$prop]) && $config['config'][$prop] === array()) {
  8353. $config['config'][$prop] = new \stdClass;
  8354. }
  8355. }
  8356. $this->file->write($config);
  8357. }
  8358. try {
  8359. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  8360. } catch (JsonValidationException $e) {
  8361. file_put_contents($this->file->getPath(), $contents);
  8362. 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);
  8363. }
  8364. if ($newFile) {
  8365. Silencer::call('chmod', $this->file->getPath(), 0600);
  8366. }
  8367. }
  8368. private function arrayUnshiftRef(&$array, &$value)
  8369. {
  8370. $return = array_unshift($array, '');
  8371. $array[0] = &$value;
  8372. return $return;
  8373. }
  8374. }
  8375. <?php
  8376. namespace Composer\Console;
  8377. use Composer\IO\NullIO;
  8378. use Composer\Util\Platform;
  8379. use Composer\Util\Silencer;
  8380. use Symfony\Component\Console\Application as BaseApplication;
  8381. use Symfony\Component\Console\Exception\CommandNotFoundException;
  8382. use Symfony\Component\Console\Helper\HelperSet;
  8383. use Symfony\Component\Console\Helper\QuestionHelper;
  8384. use Symfony\Component\Console\Input\InputInterface;
  8385. use Symfony\Component\Console\Input\InputOption;
  8386. use Symfony\Component\Console\Output\OutputInterface;
  8387. use Seld\JsonLint\ParsingException;
  8388. use Composer\Command;
  8389. use Composer\Composer;
  8390. use Composer\Factory;
  8391. use Composer\IO\IOInterface;
  8392. use Composer\IO\ConsoleIO;
  8393. use Composer\Json\JsonValidationException;
  8394. use Composer\Util\ErrorHandler;
  8395. use Composer\Util\HttpDownloader;
  8396. use Composer\EventDispatcher\ScriptExecutionException;
  8397. use Composer\Exception\NoSslException;
  8398. class Application extends BaseApplication
  8399. {
  8400. protected $composer;
  8401. protected $io;
  8402. private static $logo = ' ______
  8403. / ____/___ ____ ___ ____ ____ ________ _____
  8404. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  8405. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  8406. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  8407. /_/
  8408. ';
  8409. private $hasPluginCommands = false;
  8410. private $disablePluginsByDefault = false;
  8411. private $initialWorkingDirectory;
  8412. public function __construct()
  8413. {
  8414. static $shutdownRegistered = false;
  8415. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  8416. ini_set('xdebug.show_exception_trace', false);
  8417. ini_set('xdebug.scream', false);
  8418. }
  8419. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  8420. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  8421. }
  8422. if (!$shutdownRegistered) {
  8423. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  8424. pcntl_async_signals(true);
  8425. pcntl_signal(SIGINT, function ($sig) {
  8426. exit(130);
  8427. });
  8428. }
  8429. $shutdownRegistered = true;
  8430. register_shutdown_function(function () {
  8431. $lastError = error_get_last();
  8432. if ($lastError && $lastError['message'] &&
  8433. (strpos($lastError['message'], 'Allowed memory') !== false ||
  8434. strpos($lastError['message'], 'exceeded memory') !== false )) {
  8435. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  8436. }
  8437. });
  8438. }
  8439. $this->io = new NullIO();
  8440. $this->initialWorkingDirectory = getcwd();
  8441. parent::__construct('Composer', Composer::getVersion());
  8442. }
  8443. public function run(InputInterface $input = null, OutputInterface $output = null)
  8444. {
  8445. if (null === $output) {
  8446. $output = Factory::createOutput();
  8447. }
  8448. return parent::run($input, $output);
  8449. }
  8450. public function doRun(InputInterface $input, OutputInterface $output)
  8451. {
  8452. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  8453. if (getenv('COMPOSER_NO_INTERACTION') || !Platform::isTty(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'))) {
  8454. $input->setInteractive(false);
  8455. }
  8456. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  8457. new QuestionHelper(),
  8458. )));
  8459. ErrorHandler::register($io);
  8460. if ($input->hasParameterOption('--no-cache')) {
  8461. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  8462. $_SERVER['COMPOSER_CACHE_DIR'] = Platform::isWindows() ? 'nul' : '/dev/null';
  8463. putenv('COMPOSER_CACHE_DIR='.$_SERVER['COMPOSER_CACHE_DIR']);
  8464. }
  8465. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  8466. $oldWorkingDir = getcwd();
  8467. chdir($newWorkDir);
  8468. $this->initialWorkingDirectory = $newWorkDir;
  8469. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  8470. }
  8471. $commandName = '';
  8472. if ($name = $this->getCommandName($input)) {
  8473. try {
  8474. $commandName = $this->find($name)->getName();
  8475. } catch (CommandNotFoundException $e) {
  8476. $commandName = false;
  8477. } catch (\InvalidArgumentException $e) {
  8478. }
  8479. }
  8480. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile())) {
  8481. $dir = dirname(getcwd());
  8482. $home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
  8483. while (dirname($dir) !== $dir && $dir !== $home) {
  8484. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  8485. if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  8486. $oldWorkingDir = getcwd();
  8487. chdir($dir);
  8488. }
  8489. break;
  8490. }
  8491. $dir = dirname($dir);
  8492. }
  8493. }
  8494. if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) {
  8495. try {
  8496. foreach ($this->getPluginCommands() as $command) {
  8497. if ($this->has($command->getName())) {
  8498. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  8499. } else {
  8500. $this->add($command);
  8501. }
  8502. }
  8503. } catch (NoSslException $e) {
  8504. } catch (ParsingException $e) {
  8505. $details = $e->getDetails();
  8506. $file = realpath(Factory::getComposerFile());
  8507. $line = null;
  8508. if ($details && isset($details['line'])) {
  8509. $line = $details['line'];
  8510. }
  8511. $ghe = new GithubActionError($this->io);
  8512. $ghe->emit($e->getMessage(), $file, $line);
  8513. throw $e;
  8514. }
  8515. $this->hasPluginCommands = true;
  8516. }
  8517. $isProxyCommand = false;
  8518. if ($name = $this->getCommandName($input)) {
  8519. try {
  8520. $command = $this->find($name);
  8521. $commandName = $command->getName();
  8522. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  8523. } catch (\InvalidArgumentException $e) {
  8524. }
  8525. }
  8526. if (!$isProxyCommand) {
  8527. $io->writeError(sprintf(
  8528. 'Running %s (%s) with %s on %s',
  8529. Composer::getVersion(),
  8530. Composer::RELEASE_DATE,
  8531. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  8532. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  8533. ), true, IOInterface::DEBUG);
  8534. if (PHP_VERSION_ID < 50302) {
  8535. $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>');
  8536. }
  8537. if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  8538. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  8539. }
  8540. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  8541. $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']));
  8542. }
  8543. if (
  8544. !Platform::isWindows()
  8545. && function_exists('exec')
  8546. && !getenv('COMPOSER_ALLOW_SUPERUSER')
  8547. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  8548. ) {
  8549. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  8550. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  8551. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  8552. if ($io->isInteractive()) {
  8553. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  8554. return 1;
  8555. }
  8556. }
  8557. }
  8558. if ($uid = (int) getenv('SUDO_UID')) {
  8559. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  8560. }
  8561. }
  8562. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  8563. }
  8564. Silencer::call(function () use ($io) {
  8565. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  8566. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  8567. $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()));
  8568. }
  8569. });
  8570. $file = Factory::getComposerFile();
  8571. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  8572. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  8573. foreach ($composer['scripts'] as $script => $dummy) {
  8574. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  8575. if ($this->has($script)) {
  8576. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  8577. } else {
  8578. $description = null;
  8579. if (isset($composer['scripts-descriptions'][$script])) {
  8580. $description = $composer['scripts-descriptions'][$script];
  8581. }
  8582. $this->add(new Command\ScriptAliasCommand($script, $description));
  8583. }
  8584. }
  8585. }
  8586. }
  8587. }
  8588. }
  8589. try {
  8590. if ($input->hasParameterOption('--profile')) {
  8591. $startTime = microtime(true);
  8592. $this->io->enableDebugging($startTime);
  8593. }
  8594. $result = parent::doRun($input, $output);
  8595. if (isset($oldWorkingDir)) {
  8596. Silencer::call('chdir', $oldWorkingDir);
  8597. }
  8598. if (isset($startTime)) {
  8599. $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');
  8600. }
  8601. restore_error_handler();
  8602. return $result;
  8603. } catch (ScriptExecutionException $e) {
  8604. return (int) $e->getCode();
  8605. } catch (\Exception $e) {
  8606. $ghe = new GithubActionError($this->io);
  8607. $ghe->emit($e->getMessage());
  8608. $this->hintCommonErrors($e);
  8609. restore_error_handler();
  8610. throw $e;
  8611. }
  8612. }
  8613. private function getNewWorkingDir(InputInterface $input)
  8614. {
  8615. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  8616. if (false !== $workingDir && !is_dir($workingDir)) {
  8617. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  8618. }
  8619. return $workingDir;
  8620. }
  8621. private function hintCommonErrors($exception)
  8622. {
  8623. $io = $this->getIO();
  8624. Silencer::suppress();
  8625. try {
  8626. $composer = $this->getComposer(false, true);
  8627. if ($composer) {
  8628. $config = $composer->getConfig();
  8629. $minSpaceFree = 1024 * 1024;
  8630. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  8631. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  8632. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  8633. ) {
  8634. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  8635. }
  8636. }
  8637. } catch (\Exception $e) {
  8638. }
  8639. Silencer::restore();
  8640. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  8641. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  8642. $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);
  8643. }
  8644. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  8645. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  8646. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  8647. }
  8648. if ($hints = HttpDownloader::getExceptionHints($exception)) {
  8649. foreach ($hints as $hint) {
  8650. $io->writeError($hint, true, IOInterface::QUIET);
  8651. }
  8652. }
  8653. }
  8654. public function getComposer($required = true, $disablePlugins = null)
  8655. {
  8656. if (null === $disablePlugins) {
  8657. $disablePlugins = $this->disablePluginsByDefault;
  8658. }
  8659. if (null === $this->composer) {
  8660. try {
  8661. $this->composer = Factory::create($this->io, null, $disablePlugins);
  8662. } catch (\InvalidArgumentException $e) {
  8663. if ($required) {
  8664. $this->io->writeError($e->getMessage());
  8665. exit(1);
  8666. }
  8667. } catch (JsonValidationException $e) {
  8668. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  8669. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  8670. throw new JsonValidationException($message);
  8671. }
  8672. }
  8673. return $this->composer;
  8674. }
  8675. public function resetComposer()
  8676. {
  8677. $this->composer = null;
  8678. if ($this->getIO() && method_exists($this->getIO(), 'resetAuthentications')) {
  8679. $this->getIO()->resetAuthentications();
  8680. }
  8681. }
  8682. public function getIO()
  8683. {
  8684. return $this->io;
  8685. }
  8686. public function getHelp()
  8687. {
  8688. return self::$logo . parent::getHelp();
  8689. }
  8690. protected function getDefaultCommands()
  8691. {
  8692. $commands = array_merge(parent::getDefaultCommands(), array(
  8693. new Command\AboutCommand(),
  8694. new Command\ConfigCommand(),
  8695. new Command\DependsCommand(),
  8696. new Command\ProhibitsCommand(),
  8697. new Command\InitCommand(),
  8698. new Command\InstallCommand(),
  8699. new Command\CreateProjectCommand(),
  8700. new Command\UpdateCommand(),
  8701. new Command\SearchCommand(),
  8702. new Command\ValidateCommand(),
  8703. new Command\ShowCommand(),
  8704. new Command\SuggestsCommand(),
  8705. new Command\RequireCommand(),
  8706. new Command\DumpAutoloadCommand(),
  8707. new Command\StatusCommand(),
  8708. new Command\ArchiveCommand(),
  8709. new Command\DiagnoseCommand(),
  8710. new Command\RunScriptCommand(),
  8711. new Command\LicensesCommand(),
  8712. new Command\GlobalCommand(),
  8713. new Command\ClearCacheCommand(),
  8714. new Command\RemoveCommand(),
  8715. new Command\HomeCommand(),
  8716. new Command\ExecCommand(),
  8717. new Command\OutdatedCommand(),
  8718. new Command\CheckPlatformReqsCommand(),
  8719. new Command\FundCommand(),
  8720. ));
  8721. if (strpos(__FILE__, 'phar:') === 0) {
  8722. $commands[] = new Command\SelfUpdateCommand();
  8723. }
  8724. return $commands;
  8725. }
  8726. public function getLongVersion()
  8727. {
  8728. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  8729. return sprintf(
  8730. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  8731. $this->getName(),
  8732. Composer::BRANCH_ALIAS_VERSION,
  8733. $this->getVersion(),
  8734. Composer::RELEASE_DATE
  8735. );
  8736. }
  8737. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  8738. }
  8739. protected function getDefaultInputDefinition()
  8740. {
  8741. $definition = parent::getDefaultInputDefinition();
  8742. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  8743. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  8744. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  8745. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  8746. return $definition;
  8747. }
  8748. private function getPluginCommands()
  8749. {
  8750. $commands = array();
  8751. $composer = $this->getComposer(false, false);
  8752. if (null === $composer) {
  8753. $composer = Factory::createGlobal($this->io);
  8754. }
  8755. if (null !== $composer) {
  8756. $pm = $composer->getPluginManager();
  8757. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  8758. $newCommands = $capability->getCommands();
  8759. if (!is_array($newCommands)) {
  8760. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  8761. }
  8762. foreach ($newCommands as $command) {
  8763. if (!$command instanceof Command\BaseCommand) {
  8764. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  8765. }
  8766. }
  8767. $commands = array_merge($commands, $newCommands);
  8768. }
  8769. }
  8770. return $commands;
  8771. }
  8772. public function getInitialWorkingDirectory()
  8773. {
  8774. return $this->initialWorkingDirectory;
  8775. }
  8776. }
  8777. <?php
  8778. namespace Composer\Console;
  8779. use Composer\IO\IOInterface;
  8780. final class GithubActionError
  8781. {
  8782. protected $io;
  8783. public function __construct(IOInterface $io)
  8784. {
  8785. $this->io = $io;
  8786. }
  8787. public function emit($message, $file = null, $line = null)
  8788. {
  8789. if (getenv('GITHUB_ACTIONS') && !getenv('COMPOSER_TESTS_ARE_RUNNING')) {
  8790. $message = str_replace("\n", '%0A', $message);
  8791. if ($file && $line) {
  8792. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  8793. } elseif ($file) {
  8794. $this->io->write("::error file=". $file ."::". $message);
  8795. } else {
  8796. $this->io->write("::error ::". $message);
  8797. }
  8798. }
  8799. }
  8800. }
  8801. <?php
  8802. namespace Composer\Console;
  8803. use Symfony\Component\Console\Formatter\OutputFormatter;
  8804. class HtmlOutputFormatter extends OutputFormatter
  8805. {
  8806. private static $availableForegroundColors = array(
  8807. 30 => 'black',
  8808. 31 => 'red',
  8809. 32 => 'green',
  8810. 33 => 'yellow',
  8811. 34 => 'blue',
  8812. 35 => 'magenta',
  8813. 36 => 'cyan',
  8814. 37 => 'white',
  8815. );
  8816. private static $availableBackgroundColors = array(
  8817. 40 => 'black',
  8818. 41 => 'red',
  8819. 42 => 'green',
  8820. 43 => 'yellow',
  8821. 44 => 'blue',
  8822. 45 => 'magenta',
  8823. 46 => 'cyan',
  8824. 47 => 'white',
  8825. );
  8826. private static $availableOptions = array(
  8827. 1 => 'bold',
  8828. 4 => 'underscore',
  8829. );
  8830. public function __construct(array $styles = array())
  8831. {
  8832. parent::__construct(true, $styles);
  8833. }
  8834. public function format($message)
  8835. {
  8836. $formatted = parent::format($message);
  8837. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  8838. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  8839. }
  8840. private function formatHtml($matches)
  8841. {
  8842. $out = '<span style="';
  8843. foreach (explode(';', $matches[1]) as $code) {
  8844. if (isset(self::$availableForegroundColors[$code])) {
  8845. $out .= 'color:'.self::$availableForegroundColors[$code].';';
  8846. } elseif (isset(self::$availableBackgroundColors[$code])) {
  8847. $out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
  8848. } elseif (isset(self::$availableOptions[$code])) {
  8849. switch (self::$availableOptions[$code]) {
  8850. case 'bold':
  8851. $out .= 'font-weight:bold;';
  8852. break;
  8853. case 'underscore':
  8854. $out .= 'text-decoration:underline;';
  8855. break;
  8856. }
  8857. }
  8858. }
  8859. return $out.'">'.$matches[2].'</span>';
  8860. }
  8861. }
  8862. <?php
  8863. namespace Composer\DependencyResolver;
  8864. class Decisions implements \Iterator, \Countable
  8865. {
  8866. const DECISION_LITERAL = 0;
  8867. const DECISION_REASON = 1;
  8868. protected $pool;
  8869. protected $decisionMap;
  8870. protected $decisionQueue = array();
  8871. public function __construct($pool)
  8872. {
  8873. $this->pool = $pool;
  8874. $this->decisionMap = array();
  8875. }
  8876. public function decide($literal, $level, $why)
  8877. {
  8878. $this->addDecision($literal, $level);
  8879. $this->decisionQueue[] = array(
  8880. self::DECISION_LITERAL => $literal,
  8881. self::DECISION_REASON => $why,
  8882. );
  8883. }
  8884. public function satisfy($literal)
  8885. {
  8886. $packageId = abs($literal);
  8887. return (
  8888. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  8889. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  8890. );
  8891. }
  8892. public function conflict($literal)
  8893. {
  8894. $packageId = abs($literal);
  8895. return (
  8896. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  8897. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  8898. );
  8899. }
  8900. public function decided($literalOrPackageId)
  8901. {
  8902. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  8903. }
  8904. public function undecided($literalOrPackageId)
  8905. {
  8906. return empty($this->decisionMap[abs($literalOrPackageId)]);
  8907. }
  8908. public function decidedInstall($literalOrPackageId)
  8909. {
  8910. $packageId = abs($literalOrPackageId);
  8911. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  8912. }
  8913. public function decisionLevel($literalOrPackageId)
  8914. {
  8915. $packageId = abs($literalOrPackageId);
  8916. if (isset($this->decisionMap[$packageId])) {
  8917. return abs($this->decisionMap[$packageId]);
  8918. }
  8919. return 0;
  8920. }
  8921. public function decisionRule($literalOrPackageId)
  8922. {
  8923. $packageId = abs($literalOrPackageId);
  8924. foreach ($this->decisionQueue as $i => $decision) {
  8925. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  8926. return $decision[self::DECISION_REASON];
  8927. }
  8928. }
  8929. return null;
  8930. }
  8931. public function atOffset($queueOffset)
  8932. {
  8933. return $this->decisionQueue[$queueOffset];
  8934. }
  8935. public function validOffset($queueOffset)
  8936. {
  8937. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  8938. }
  8939. public function lastReason()
  8940. {
  8941. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  8942. }
  8943. public function lastLiteral()
  8944. {
  8945. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  8946. }
  8947. public function reset()
  8948. {
  8949. while ($decision = array_pop($this->decisionQueue)) {
  8950. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8951. }
  8952. }
  8953. public function resetToOffset($offset)
  8954. {
  8955. while (\count($this->decisionQueue) > $offset + 1) {
  8956. $decision = array_pop($this->decisionQueue);
  8957. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8958. }
  8959. }
  8960. public function revertLast()
  8961. {
  8962. $this->decisionMap[abs($this->lastLiteral())] = 0;
  8963. array_pop($this->decisionQueue);
  8964. }
  8965. public function count()
  8966. {
  8967. return \count($this->decisionQueue);
  8968. }
  8969. public function rewind()
  8970. {
  8971. end($this->decisionQueue);
  8972. }
  8973. public function current()
  8974. {
  8975. return current($this->decisionQueue);
  8976. }
  8977. public function key()
  8978. {
  8979. return key($this->decisionQueue);
  8980. }
  8981. public function next()
  8982. {
  8983. return prev($this->decisionQueue);
  8984. }
  8985. public function valid()
  8986. {
  8987. return false !== current($this->decisionQueue);
  8988. }
  8989. public function isEmpty()
  8990. {
  8991. return \count($this->decisionQueue) === 0;
  8992. }
  8993. protected function addDecision($literal, $level)
  8994. {
  8995. $packageId = abs($literal);
  8996. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  8997. if ($previousDecision != 0) {
  8998. $literalString = $this->pool->literalToPrettyString($literal, array());
  8999. $package = $this->pool->literalToPackage($literal);
  9000. throw new SolverBugException(
  9001. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  9002. );
  9003. }
  9004. if ($literal > 0) {
  9005. $this->decisionMap[$packageId] = $level;
  9006. } else {
  9007. $this->decisionMap[$packageId] = -$level;
  9008. }
  9009. }
  9010. public function toString(Pool $pool = null)
  9011. {
  9012. $decisionMap = $this->decisionMap;
  9013. ksort($decisionMap);
  9014. $str = '[';
  9015. foreach ($decisionMap as $packageId => $level) {
  9016. $str .= (($pool) ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  9017. }
  9018. $str .= ']';
  9019. return $str;
  9020. }
  9021. public function __toString()
  9022. {
  9023. return $this->toString();
  9024. }
  9025. }
  9026. <?php
  9027. namespace Composer\DependencyResolver;
  9028. use Composer\Package\PackageInterface;
  9029. use Composer\Package\AliasPackage;
  9030. use Composer\Package\BasePackage;
  9031. use Composer\Semver\Constraint\Constraint;
  9032. class DefaultPolicy implements PolicyInterface
  9033. {
  9034. private $preferStable;
  9035. private $preferLowest;
  9036. public function __construct($preferStable = false, $preferLowest = false)
  9037. {
  9038. $this->preferStable = $preferStable;
  9039. $this->preferLowest = $preferLowest;
  9040. }
  9041. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  9042. {
  9043. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  9044. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  9045. }
  9046. $constraint = new Constraint($operator, $b->getVersion());
  9047. $version = new Constraint('==', $a->getVersion());
  9048. return $constraint->matchSpecific($version, true);
  9049. }
  9050. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
  9051. {
  9052. $packages = $this->groupLiteralsByName($pool, $literals);
  9053. $policy = $this;
  9054. foreach ($packages as &$nameLiterals) {
  9055. usort($nameLiterals, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9056. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  9057. });
  9058. }
  9059. foreach ($packages as &$sortedLiterals) {
  9060. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  9061. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  9062. }
  9063. $selected = \call_user_func_array('array_merge', array_values($packages));
  9064. usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9065. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  9066. });
  9067. return $selected;
  9068. }
  9069. protected function groupLiteralsByName(Pool $pool, $literals)
  9070. {
  9071. $packages = array();
  9072. foreach ($literals as $literal) {
  9073. $packageName = $pool->literalToPackage($literal)->getName();
  9074. if (!isset($packages[$packageName])) {
  9075. $packages[$packageName] = array();
  9076. }
  9077. $packages[$packageName][] = $literal;
  9078. }
  9079. return $packages;
  9080. }
  9081. public function compareByPriority(Pool $pool, PackageInterface $a, PackageInterface $b, $requiredPackage = null, $ignoreReplace = false)
  9082. {
  9083. if ($a->getName() === $b->getName()) {
  9084. $aAliased = $a instanceof AliasPackage;
  9085. $bAliased = $b instanceof AliasPackage;
  9086. if ($aAliased && !$bAliased) {
  9087. return -1;
  9088. }
  9089. if (!$aAliased && $bAliased) {
  9090. return 1;
  9091. }
  9092. }
  9093. if (!$ignoreReplace) {
  9094. if ($this->replaces($a, $b)) {
  9095. return 1;
  9096. }
  9097. if ($this->replaces($b, $a)) {
  9098. return -1;
  9099. }
  9100. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  9101. $requiredVendor = substr($requiredPackage, 0, $pos);
  9102. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  9103. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  9104. if ($bIsSameVendor !== $aIsSameVendor) {
  9105. return $aIsSameVendor ? -1 : 1;
  9106. }
  9107. }
  9108. }
  9109. if ($a->id === $b->id) {
  9110. return 0;
  9111. }
  9112. return ($a->id < $b->id) ? -1 : 1;
  9113. }
  9114. protected function replaces(PackageInterface $source, PackageInterface $target)
  9115. {
  9116. foreach ($source->getReplaces() as $link) {
  9117. if ($link->getTarget() === $target->getName()
  9118. ) {
  9119. return true;
  9120. }
  9121. }
  9122. return false;
  9123. }
  9124. protected function pruneToBestVersion(Pool $pool, $literals)
  9125. {
  9126. $operator = $this->preferLowest ? '<' : '>';
  9127. $bestLiterals = array($literals[0]);
  9128. $bestPackage = $pool->literalToPackage($literals[0]);
  9129. foreach ($literals as $i => $literal) {
  9130. if (0 === $i) {
  9131. continue;
  9132. }
  9133. $package = $pool->literalToPackage($literal);
  9134. if ($this->versionCompare($package, $bestPackage, $operator)) {
  9135. $bestPackage = $package;
  9136. $bestLiterals = array($literal);
  9137. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  9138. $bestLiterals[] = $literal;
  9139. }
  9140. }
  9141. return $bestLiterals;
  9142. }
  9143. protected function pruneRemoteAliases(Pool $pool, array $literals)
  9144. {
  9145. $hasLocalAlias = false;
  9146. foreach ($literals as $literal) {
  9147. $package = $pool->literalToPackage($literal);
  9148. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9149. $hasLocalAlias = true;
  9150. break;
  9151. }
  9152. }
  9153. if (!$hasLocalAlias) {
  9154. return $literals;
  9155. }
  9156. $selected = array();
  9157. foreach ($literals as $literal) {
  9158. $package = $pool->literalToPackage($literal);
  9159. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9160. $selected[] = $literal;
  9161. }
  9162. }
  9163. return $selected;
  9164. }
  9165. }
  9166. <?php
  9167. namespace Composer\DependencyResolver;
  9168. use Composer\Package\PackageInterface;
  9169. use Composer\Package\Link;
  9170. class GenericRule extends Rule
  9171. {
  9172. protected $literals;
  9173. public function __construct(array $literals, $reason, $reasonData)
  9174. {
  9175. parent::__construct($reason, $reasonData);
  9176. sort($literals);
  9177. $this->literals = $literals;
  9178. }
  9179. public function getLiterals()
  9180. {
  9181. return $this->literals;
  9182. }
  9183. public function getHash()
  9184. {
  9185. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  9186. return $data['hash'];
  9187. }
  9188. public function equals(Rule $rule)
  9189. {
  9190. return $this->literals === $rule->getLiterals();
  9191. }
  9192. public function isAssertion()
  9193. {
  9194. return 1 === \count($this->literals);
  9195. }
  9196. public function __toString()
  9197. {
  9198. $result = $this->isDisabled() ? 'disabled(' : '(';
  9199. foreach ($this->literals as $i => $literal) {
  9200. if ($i != 0) {
  9201. $result .= '|';
  9202. }
  9203. $result .= $literal;
  9204. }
  9205. $result .= ')';
  9206. return $result;
  9207. }
  9208. }
  9209. <?php
  9210. namespace Composer\DependencyResolver;
  9211. use Composer\Repository\RepositoryInterface;
  9212. class LocalRepoTransaction extends Transaction
  9213. {
  9214. public function __construct(RepositoryInterface $lockedRepository, $localRepository)
  9215. {
  9216. parent::__construct(
  9217. $localRepository->getPackages(),
  9218. $lockedRepository->getPackages()
  9219. );
  9220. }
  9221. }
  9222. <?php
  9223. namespace Composer\DependencyResolver;
  9224. use Composer\Package\AliasPackage;
  9225. use Composer\Package\RootAliasPackage;
  9226. class LockTransaction extends Transaction
  9227. {
  9228. protected $presentMap;
  9229. protected $unlockableMap;
  9230. protected $resultPackages;
  9231. public function __construct(Pool $pool, $presentMap, $unlockableMap, $decisions)
  9232. {
  9233. $this->presentMap = $presentMap;
  9234. $this->unlockableMap = $unlockableMap;
  9235. $this->setResultPackages($pool, $decisions);
  9236. parent::__construct($this->presentMap, $this->resultPackages['all']);
  9237. }
  9238. public function setResultPackages(Pool $pool, Decisions $decisions)
  9239. {
  9240. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  9241. foreach ($decisions as $i => $decision) {
  9242. $literal = $decision[Decisions::DECISION_LITERAL];
  9243. if ($literal > 0) {
  9244. $package = $pool->literalToPackage($literal);
  9245. $this->resultPackages['all'][] = $package;
  9246. if (!isset($this->unlockableMap[$package->id])) {
  9247. $this->resultPackages['non-dev'][] = $package;
  9248. }
  9249. }
  9250. }
  9251. }
  9252. public function setNonDevPackages(LockTransaction $extractionResult)
  9253. {
  9254. $packages = $extractionResult->getNewLockPackages(false);
  9255. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  9256. $this->resultPackages['non-dev'] = array();
  9257. foreach ($packages as $package) {
  9258. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  9259. if ($package->getName() == $resultPackage->getName()) {
  9260. $this->resultPackages['non-dev'][] = $resultPackage;
  9261. unset($this->resultPackages['dev'][$i]);
  9262. }
  9263. }
  9264. }
  9265. }
  9266. public function getNewLockPackages($devMode, $updateMirrors = false)
  9267. {
  9268. $packages = array();
  9269. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  9270. if (!($package instanceof AliasPackage) && !($package instanceof RootAliasPackage)) {
  9271. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  9272. foreach ($this->presentMap as $presentPackage) {
  9273. if ($package->getName() == $presentPackage->getName() && $package->getVersion() == $presentPackage->getVersion()) {
  9274. if ($presentPackage->getSourceReference() && $presentPackage->getSourceType() === $package->getSourceType()) {
  9275. $package->setSourceDistReferences($presentPackage->getSourceReference());
  9276. }
  9277. if ($presentPackage->getReleaseDate()) {
  9278. $package->setReleaseDate($presentPackage->getReleaseDate());
  9279. }
  9280. }
  9281. }
  9282. }
  9283. $packages[] = $package;
  9284. }
  9285. }
  9286. return $packages;
  9287. }
  9288. public function getAliases($aliases)
  9289. {
  9290. $usedAliases = array();
  9291. foreach ($this->resultPackages['all'] as $package) {
  9292. if ($package instanceof AliasPackage) {
  9293. foreach ($aliases as $index => $alias) {
  9294. if ($alias['package'] === $package->getName()) {
  9295. $usedAliases[] = $alias;
  9296. unset($aliases[$index]);
  9297. }
  9298. }
  9299. }
  9300. }
  9301. usort($usedAliases, function ($a, $b) {
  9302. return strcmp($a['package'], $b['package']);
  9303. });
  9304. return $usedAliases;
  9305. }
  9306. }
  9307. <?php
  9308. namespace Composer\DependencyResolver;
  9309. use Composer\Package\PackageInterface;
  9310. use Composer\Package\Link;
  9311. class MultiConflictRule extends Rule
  9312. {
  9313. protected $literals;
  9314. public function __construct(array $literals, $reason, $reasonData)
  9315. {
  9316. parent::__construct($reason, $reasonData);
  9317. if (\count($literals) < 3) {
  9318. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  9319. }
  9320. sort($literals);
  9321. $this->literals = $literals;
  9322. }
  9323. public function getLiterals()
  9324. {
  9325. return $this->literals;
  9326. }
  9327. public function getHash()
  9328. {
  9329. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  9330. return $data['hash'];
  9331. }
  9332. public function equals(Rule $rule)
  9333. {
  9334. if ($rule instanceof MultiConflictRule) {
  9335. return $this->literals === $rule->getLiterals();
  9336. }
  9337. return false;
  9338. }
  9339. public function isAssertion()
  9340. {
  9341. return false;
  9342. }
  9343. public function disable()
  9344. {
  9345. 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.");
  9346. }
  9347. public function __toString()
  9348. {
  9349. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  9350. foreach ($this->literals as $i => $literal) {
  9351. if ($i != 0) {
  9352. $result .= '|';
  9353. }
  9354. $result .= $literal;
  9355. }
  9356. $result .= '))';
  9357. return $result;
  9358. }
  9359. }
  9360. <?php
  9361. namespace Composer\DependencyResolver\Operation;
  9362. use Composer\Package\PackageInterface;
  9363. class InstallOperation extends SolverOperation implements OperationInterface
  9364. {
  9365. const TYPE = 'install';
  9366. protected $package;
  9367. public function __construct(PackageInterface $package)
  9368. {
  9369. $this->package = $package;
  9370. }
  9371. public function getPackage()
  9372. {
  9373. return $this->package;
  9374. }
  9375. public function show($lock)
  9376. {
  9377. return self::format($this->package, $lock);
  9378. }
  9379. public static function format(PackageInterface $package, $lock = false)
  9380. {
  9381. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9382. }
  9383. }
  9384. <?php
  9385. namespace Composer\DependencyResolver\Operation;
  9386. use Composer\Package\AliasPackage;
  9387. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  9388. {
  9389. const TYPE = 'markAliasInstalled';
  9390. protected $package;
  9391. public function __construct(AliasPackage $package)
  9392. {
  9393. $this->package = $package;
  9394. }
  9395. public function getPackage()
  9396. {
  9397. return $this->package;
  9398. }
  9399. public function show($lock)
  9400. {
  9401. 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>)';
  9402. }
  9403. }
  9404. <?php
  9405. namespace Composer\DependencyResolver\Operation;
  9406. use Composer\Package\AliasPackage;
  9407. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  9408. {
  9409. const TYPE = 'markAliasUninstalled';
  9410. protected $package;
  9411. public function __construct(AliasPackage $package)
  9412. {
  9413. $this->package = $package;
  9414. }
  9415. public function getPackage()
  9416. {
  9417. return $this->package;
  9418. }
  9419. public function show($lock)
  9420. {
  9421. 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>)';
  9422. }
  9423. }
  9424. <?php
  9425. namespace Composer\DependencyResolver\Operation;
  9426. interface OperationInterface
  9427. {
  9428. public function getOperationType();
  9429. public function show($lock);
  9430. public function __toString();
  9431. }
  9432. <?php
  9433. namespace Composer\DependencyResolver\Operation;
  9434. abstract class SolverOperation implements OperationInterface
  9435. {
  9436. const TYPE = null;
  9437. public function getOperationType()
  9438. {
  9439. return static::TYPE;
  9440. }
  9441. public function __toString()
  9442. {
  9443. return $this->show(false);
  9444. }
  9445. }
  9446. <?php
  9447. namespace Composer\DependencyResolver\Operation;
  9448. use Composer\Package\PackageInterface;
  9449. class UninstallOperation extends SolverOperation implements OperationInterface
  9450. {
  9451. const TYPE = 'uninstall';
  9452. protected $package;
  9453. public function __construct(PackageInterface $package)
  9454. {
  9455. $this->package = $package;
  9456. }
  9457. public function getPackage()
  9458. {
  9459. return $this->package;
  9460. }
  9461. public function show($lock)
  9462. {
  9463. return self::format($this->package, $lock);
  9464. }
  9465. public static function format(PackageInterface $package, $lock = false)
  9466. {
  9467. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9468. }
  9469. }
  9470. <?php
  9471. namespace Composer\DependencyResolver\Operation;
  9472. use Composer\Package\PackageInterface;
  9473. use Composer\Package\Version\VersionParser;
  9474. class UpdateOperation extends SolverOperation implements OperationInterface
  9475. {
  9476. const TYPE = 'update';
  9477. protected $initialPackage;
  9478. protected $targetPackage;
  9479. public function __construct(PackageInterface $initial, PackageInterface $target)
  9480. {
  9481. $this->initialPackage = $initial;
  9482. $this->targetPackage = $target;
  9483. }
  9484. public function getInitialPackage()
  9485. {
  9486. return $this->initialPackage;
  9487. }
  9488. public function getTargetPackage()
  9489. {
  9490. return $this->targetPackage;
  9491. }
  9492. public function show($lock)
  9493. {
  9494. return self::format($this->initialPackage, $this->targetPackage, $lock);
  9495. }
  9496. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
  9497. {
  9498. $fromVersion = $initialPackage->getFullPrettyVersion();
  9499. $toVersion = $targetPackage->getFullPrettyVersion();
  9500. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  9501. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9502. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9503. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  9504. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9505. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9506. }
  9507. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  9508. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  9509. }
  9510. }
  9511. <?php
  9512. namespace Composer\DependencyResolver;
  9513. use Composer\Package\PackageInterface;
  9514. interface PolicyInterface
  9515. {
  9516. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  9517. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
  9518. }
  9519. <?php
  9520. namespace Composer\DependencyResolver;
  9521. use Composer\Package\Version\VersionParser;
  9522. use Composer\Semver\CompilingMatcher;
  9523. use Composer\Semver\Constraint\ConstraintInterface;
  9524. use Composer\Semver\Constraint\Constraint;
  9525. use Composer\Package\PackageInterface;
  9526. class Pool implements \Countable
  9527. {
  9528. protected $packages = array();
  9529. protected $packageByName = array();
  9530. protected $versionParser;
  9531. protected $providerCache = array();
  9532. protected $unacceptableFixedOrLockedPackages;
  9533. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array())
  9534. {
  9535. $this->versionParser = new VersionParser;
  9536. $this->setPackages($packages);
  9537. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  9538. }
  9539. private function setPackages(array $packages)
  9540. {
  9541. $id = 1;
  9542. foreach ($packages as $package) {
  9543. $this->packages[] = $package;
  9544. $package->id = $id++;
  9545. foreach ($package->getNames() as $provided) {
  9546. $this->packageByName[$provided][] = $package;
  9547. }
  9548. }
  9549. }
  9550. public function getPackages()
  9551. {
  9552. return $this->packages;
  9553. }
  9554. public function packageById($id)
  9555. {
  9556. return $this->packages[$id - 1];
  9557. }
  9558. public function count()
  9559. {
  9560. return \count($this->packages);
  9561. }
  9562. public function whatProvides($name, ConstraintInterface $constraint = null)
  9563. {
  9564. $key = (string) $constraint;
  9565. if (isset($this->providerCache[$name][$key])) {
  9566. return $this->providerCache[$name][$key];
  9567. }
  9568. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  9569. }
  9570. private function computeWhatProvides($name, $constraint)
  9571. {
  9572. if (!isset($this->packageByName[$name])) {
  9573. return array();
  9574. }
  9575. $matches = array();
  9576. foreach ($this->packageByName[$name] as $candidate) {
  9577. if ($this->match($candidate, $name, $constraint)) {
  9578. $matches[] = $candidate;
  9579. }
  9580. }
  9581. return $matches;
  9582. }
  9583. public function literalToPackage($literal)
  9584. {
  9585. $packageId = abs($literal);
  9586. return $this->packageById($packageId);
  9587. }
  9588. public function literalToPrettyString($literal, $installedMap)
  9589. {
  9590. $package = $this->literalToPackage($literal);
  9591. if (isset($installedMap[$package->id])) {
  9592. $prefix = ($literal > 0 ? 'keep' : 'remove');
  9593. } else {
  9594. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  9595. }
  9596. return $prefix.' '.$package->getPrettyString();
  9597. }
  9598. public function match($candidate, $name, ConstraintInterface $constraint = null)
  9599. {
  9600. $candidateName = $candidate->getName();
  9601. $candidateVersion = $candidate->getVersion();
  9602. if ($candidateName === $name) {
  9603. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  9604. }
  9605. $provides = $candidate->getProvides();
  9606. $replaces = $candidate->getReplaces();
  9607. if (isset($replaces[0]) || isset($provides[0])) {
  9608. foreach ($provides as $link) {
  9609. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9610. return true;
  9611. }
  9612. }
  9613. foreach ($replaces as $link) {
  9614. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9615. return true;
  9616. }
  9617. }
  9618. return false;
  9619. }
  9620. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  9621. return true;
  9622. }
  9623. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  9624. return true;
  9625. }
  9626. return false;
  9627. }
  9628. public function isUnacceptableFixedOrLockedPackage(PackageInterface $package)
  9629. {
  9630. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  9631. }
  9632. public function __toString()
  9633. {
  9634. $str = "Pool:\n";
  9635. foreach ($this->packages as $package) {
  9636. $str .= '- '.str_pad($package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  9637. }
  9638. return $str;
  9639. }
  9640. }
  9641. <?php
  9642. namespace Composer\DependencyResolver;
  9643. use Composer\EventDispatcher\EventDispatcher;
  9644. use Composer\IO\IOInterface;
  9645. use Composer\Package\AliasPackage;
  9646. use Composer\Package\BasePackage;
  9647. use Composer\Package\PackageInterface;
  9648. use Composer\Package\Version\StabilityFilter;
  9649. use Composer\Plugin\PluginEvents;
  9650. use Composer\Plugin\PrePoolCreateEvent;
  9651. use Composer\Repository\PlatformRepository;
  9652. use Composer\Repository\RootPackageRepository;
  9653. use Composer\Semver\CompilingMatcher;
  9654. use Composer\Semver\Constraint\Constraint;
  9655. use Composer\Semver\Constraint\ConstraintInterface;
  9656. use Composer\Semver\Constraint\MatchAllConstraint;
  9657. use Composer\Semver\Constraint\MultiConstraint;
  9658. use Composer\Semver\Intervals;
  9659. class PoolBuilder
  9660. {
  9661. private $acceptableStabilities;
  9662. private $stabilityFlags;
  9663. private $rootAliases;
  9664. private $rootReferences;
  9665. private $eventDispatcher;
  9666. private $io;
  9667. private $aliasMap = array();
  9668. private $packagesToLoad = array();
  9669. private $loadedPackages = array();
  9670. private $loadedPerRepo = array();
  9671. private $packages = array();
  9672. private $unacceptableFixedOrLockedPackages = array();
  9673. private $updateAllowList = array();
  9674. private $skippedLoad = array();
  9675. private $maxExtendedReqs = array();
  9676. private $updateAllowWarned = array();
  9677. private $indexCounter = 0;
  9678. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null)
  9679. {
  9680. $this->acceptableStabilities = $acceptableStabilities;
  9681. $this->stabilityFlags = $stabilityFlags;
  9682. $this->rootAliases = $rootAliases;
  9683. $this->rootReferences = $rootReferences;
  9684. $this->eventDispatcher = $eventDispatcher;
  9685. $this->io = $io;
  9686. }
  9687. public function buildPool(array $repositories, Request $request)
  9688. {
  9689. if ($request->getUpdateAllowList()) {
  9690. $this->updateAllowList = $request->getUpdateAllowList();
  9691. $this->warnAboutNonMatchingUpdateAllowList($request);
  9692. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  9693. if (!$this->isUpdateAllowed($lockedPackage)) {
  9694. $request->lockPackage($lockedPackage);
  9695. $lockedName = $lockedPackage->getName();
  9696. $this->skippedLoad[$lockedName] = $lockedName;
  9697. foreach ($lockedPackage->getReplaces() as $link) {
  9698. $this->skippedLoad[$link->getTarget()] = $lockedName;
  9699. }
  9700. }
  9701. }
  9702. }
  9703. foreach ($request->getFixedOrLockedPackages() as $package) {
  9704. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  9705. foreach ($package->getReplaces() as $link) {
  9706. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  9707. }
  9708. if (
  9709. $package->getRepository() instanceof RootPackageRepository
  9710. || $package->getRepository() instanceof PlatformRepository
  9711. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  9712. ) {
  9713. $this->loadPackage($request, $package, false);
  9714. } else {
  9715. $this->unacceptableFixedOrLockedPackages[] = $package;
  9716. }
  9717. }
  9718. foreach ($request->getRequires() as $packageName => $constraint) {
  9719. if (isset($this->loadedPackages[$packageName])) {
  9720. continue;
  9721. }
  9722. $this->packagesToLoad[$packageName] = $constraint;
  9723. $this->maxExtendedReqs[$packageName] = true;
  9724. }
  9725. foreach ($this->packagesToLoad as $name => $constraint) {
  9726. if (isset($this->loadedPackages[$name])) {
  9727. unset($this->packagesToLoad[$name]);
  9728. }
  9729. }
  9730. while (!empty($this->packagesToLoad)) {
  9731. $this->loadPackagesMarkedForLoading($request, $repositories);
  9732. }
  9733. foreach ($this->packages as $i => $package) {
  9734. if (!$package instanceof AliasPackage) {
  9735. $constraint = new Constraint('==', $package->getVersion());
  9736. $aliasedPackages = array($i => $package);
  9737. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9738. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  9739. }
  9740. $found = false;
  9741. foreach ($aliasedPackages as $packageOrAlias) {
  9742. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  9743. $found = true;
  9744. }
  9745. }
  9746. if (!$found) {
  9747. foreach ($aliasedPackages as $index => $packageOrAlias) {
  9748. unset($this->packages[$index]);
  9749. }
  9750. }
  9751. }
  9752. }
  9753. if ($this->eventDispatcher) {
  9754. $prePoolCreateEvent = new PrePoolCreateEvent(
  9755. PluginEvents::PRE_POOL_CREATE,
  9756. $repositories,
  9757. $request,
  9758. $this->acceptableStabilities,
  9759. $this->stabilityFlags,
  9760. $this->rootAliases,
  9761. $this->rootReferences,
  9762. $this->packages,
  9763. $this->unacceptableFixedOrLockedPackages
  9764. );
  9765. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  9766. $this->packages = $prePoolCreateEvent->getPackages();
  9767. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  9768. }
  9769. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  9770. $this->aliasMap = array();
  9771. $this->packagesToLoad = array();
  9772. $this->loadedPackages = array();
  9773. $this->loadedPerRepo = array();
  9774. $this->packages = array();
  9775. $this->unacceptableFixedOrLockedPackages = array();
  9776. $this->maxExtendedReqs = array();
  9777. $this->skippedLoad = array();
  9778. $this->indexCounter = 0;
  9779. Intervals::clear();
  9780. return $pool;
  9781. }
  9782. private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
  9783. {
  9784. if (PlatformRepository::isPlatformPackage($name)) {
  9785. return;
  9786. }
  9787. if (isset($this->maxExtendedReqs[$name])) {
  9788. return;
  9789. }
  9790. $rootRequires = $request->getRequires();
  9791. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  9792. $constraint = $rootRequires[$name];
  9793. }
  9794. if (!isset($this->loadedPackages[$name])) {
  9795. if (isset($this->packagesToLoad[$name])) {
  9796. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  9797. return;
  9798. }
  9799. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  9800. }
  9801. $this->packagesToLoad[$name] = $constraint;
  9802. return;
  9803. }
  9804. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  9805. return;
  9806. }
  9807. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  9808. unset($this->loadedPackages[$name]);
  9809. }
  9810. private function loadPackagesMarkedForLoading(Request $request, $repositories)
  9811. {
  9812. foreach ($this->packagesToLoad as $name => $constraint) {
  9813. $this->loadedPackages[$name] = $constraint;
  9814. }
  9815. $packageBatch = $this->packagesToLoad;
  9816. $this->packagesToLoad = array();
  9817. foreach ($repositories as $repoIndex => $repository) {
  9818. if (empty($packageBatch)) {
  9819. break;
  9820. }
  9821. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  9822. continue;
  9823. }
  9824. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
  9825. foreach ($result['namesFound'] as $name) {
  9826. unset($packageBatch[$name]);
  9827. }
  9828. foreach ($result['packages'] as $package) {
  9829. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  9830. $this->loadPackage($request, $package);
  9831. }
  9832. }
  9833. }
  9834. private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true)
  9835. {
  9836. $index = $this->indexCounter++;
  9837. $this->packages[$index] = $package;
  9838. if ($package instanceof AliasPackage) {
  9839. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  9840. }
  9841. $name = $package->getName();
  9842. if (isset($this->rootReferences[$name])) {
  9843. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  9844. $package->setSourceDistReferences($this->rootReferences[$name]);
  9845. }
  9846. }
  9847. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  9848. $alias = $this->rootAliases[$name][$package->getVersion()];
  9849. if ($package instanceof AliasPackage) {
  9850. $basePackage = $package->getAliasOf();
  9851. } else {
  9852. $basePackage = $package;
  9853. }
  9854. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  9855. $aliasPackage->setRootPackageAlias(true);
  9856. $newIndex = $this->indexCounter++;
  9857. $this->packages[$newIndex] = $aliasPackage;
  9858. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  9859. }
  9860. foreach ($package->getRequires() as $link) {
  9861. $require = $link->getTarget();
  9862. $linkConstraint = $link->getConstraint();
  9863. if (isset($this->skippedLoad[$require])) {
  9864. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9865. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$require])) {
  9866. $this->unlockPackage($request, $require);
  9867. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9868. } elseif (!isset($this->updateAllowWarned[$this->skippedLoad[$require]])) {
  9869. $this->updateAllowWarned[$this->skippedLoad[$require]] = true;
  9870. $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>');
  9871. }
  9872. }
  9873. } else {
  9874. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9875. }
  9876. }
  9877. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9878. foreach ($package->getReplaces() as $link) {
  9879. $replace = $link->getTarget();
  9880. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  9881. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
  9882. $this->unlockPackage($request, $replace);
  9883. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  9884. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
  9885. $this->updateAllowWarned[$replace] = true;
  9886. $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>');
  9887. }
  9888. }
  9889. }
  9890. }
  9891. }
  9892. private function isRootRequire(Request $request, $name)
  9893. {
  9894. $rootRequires = $request->getRequires();
  9895. return isset($rootRequires[$name]);
  9896. }
  9897. private function isUpdateAllowed(PackageInterface $package)
  9898. {
  9899. foreach ($this->updateAllowList as $pattern => $void) {
  9900. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9901. if (preg_match($patternRegexp, $package->getName())) {
  9902. return true;
  9903. }
  9904. }
  9905. return false;
  9906. }
  9907. private function warnAboutNonMatchingUpdateAllowList(Request $request)
  9908. {
  9909. foreach ($this->updateAllowList as $pattern => $void) {
  9910. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9911. foreach ($request->getLockedRepository()->getPackages() as $package) {
  9912. if (preg_match($patternRegexp, $package->getName())) {
  9913. continue 2;
  9914. }
  9915. }
  9916. foreach ($request->getRequires() as $packageName => $constraint) {
  9917. if (preg_match($patternRegexp, $packageName)) {
  9918. continue 2;
  9919. }
  9920. }
  9921. if (strpos($pattern, '*') !== false) {
  9922. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  9923. } else {
  9924. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  9925. }
  9926. }
  9927. }
  9928. private function unlockPackage(Request $request, $name)
  9929. {
  9930. if (
  9931. $this->skippedLoad[$name] !== $name
  9932. && isset($this->skippedLoad[$this->skippedLoad[$name]])
  9933. ) {
  9934. $this->unlockPackage($request, $this->skippedLoad[$name]);
  9935. }
  9936. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name]);
  9937. foreach ($request->getLockedPackages() as $lockedPackage) {
  9938. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  9939. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  9940. $request->unlockPackage($lockedPackage);
  9941. $this->removeLoadedPackage($request, $lockedPackage, $index);
  9942. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  9943. if ($fixedOrLockedPackage !== $lockedPackage && isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  9944. foreach ($fixedOrLockedPackage->getRequires() as $requireLink) {
  9945. if ($requireLink->getTarget() === $lockedPackage->getName()) {
  9946. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requireLink->getConstraint());
  9947. }
  9948. }
  9949. }
  9950. }
  9951. }
  9952. }
  9953. }
  9954. }
  9955. private function removeLoadedPackage(Request $request, PackageInterface $package, $index)
  9956. {
  9957. unset($this->packages[$index]);
  9958. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9959. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  9960. $request->unlockPackage($aliasPackage);
  9961. unset($this->packages[$aliasIndex]);
  9962. }
  9963. unset($this->aliasMap[spl_object_hash($package)]);
  9964. }
  9965. }
  9966. }
  9967. <?php
  9968. namespace Composer\DependencyResolver;
  9969. use Composer\Package\CompletePackageInterface;
  9970. use Composer\Package\AliasPackage;
  9971. use Composer\Repository\RepositorySet;
  9972. use Composer\Repository\LockArrayRepository;
  9973. use Composer\Semver\Constraint\Constraint;
  9974. use Composer\Package\Version\VersionParser;
  9975. class Problem
  9976. {
  9977. protected $reasonSeen;
  9978. protected $reasons = array();
  9979. protected $section = 0;
  9980. public function addRule(Rule $rule)
  9981. {
  9982. $this->addReason(spl_object_hash($rule), $rule);
  9983. }
  9984. public function getReasons()
  9985. {
  9986. return $this->reasons;
  9987. }
  9988. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  9989. {
  9990. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  9991. if (count($reasons) === 1) {
  9992. reset($reasons);
  9993. $rule = current($reasons);
  9994. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  9995. throw new \LogicException("Single reason problems must contain a request rule.");
  9996. }
  9997. $reasonData = $rule->getReasonData();
  9998. $packageName = $reasonData['packageName'];
  9999. $constraint = $reasonData['constraint'];
  10000. if (isset($constraint)) {
  10001. $packages = $pool->whatProvides($packageName, $constraint);
  10002. } else {
  10003. $packages = array();
  10004. }
  10005. if (empty($packages)) {
  10006. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  10007. }
  10008. }
  10009. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10010. }
  10011. public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10012. {
  10013. $messages = array();
  10014. $templates = array();
  10015. $parser = new VersionParser;
  10016. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  10017. foreach ($rules as $rule) {
  10018. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10019. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && preg_match('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  10020. $template = preg_replace('{^\S+ \S+ }', '%s%s ', $message);
  10021. $messages[] = $template;
  10022. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  10023. } elseif ($message !== '') {
  10024. $messages[] = $message;
  10025. }
  10026. }
  10027. $result = array();
  10028. foreach (array_unique($messages) as $message) {
  10029. if (isset($templates[$message])) {
  10030. foreach ($templates[$message] as $package => $versions) {
  10031. uksort($versions, 'version_compare');
  10032. if (!$isVerbose) {
  10033. $versions = self::condenseVersionList($versions, 1);
  10034. }
  10035. if (count($versions) > 1) {
  10036. $message = preg_replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  10037. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  10038. } else {
  10039. $result[] = sprintf($message, $package, ' '.reset($versions));
  10040. }
  10041. }
  10042. } else {
  10043. $result[] = $message;
  10044. }
  10045. }
  10046. return "\n$indent- ".implode("\n$indent- ", $result);
  10047. }
  10048. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10049. {
  10050. foreach ($this->reasons as $sectionRules) {
  10051. foreach ($sectionRules as $rule) {
  10052. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  10053. return true;
  10054. }
  10055. }
  10056. }
  10057. }
  10058. protected function addReason($id, Rule $reason)
  10059. {
  10060. if (!isset($this->reasonSeen[$id])) {
  10061. $this->reasonSeen[$id] = true;
  10062. $this->reasons[$this->section][] = $reason;
  10063. }
  10064. }
  10065. public function nextSection()
  10066. {
  10067. $this->section++;
  10068. }
  10069. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, $constraint = null)
  10070. {
  10071. if ($packageName === 'php' || $packageName === 'php-64bit' || $packageName === 'hhvm') {
  10072. $version = phpversion();
  10073. $available = $pool->whatProvides($packageName);
  10074. if (count($available)) {
  10075. $firstAvailable = reset($available);
  10076. $version = $firstAvailable->getPrettyVersion();
  10077. $extra = $firstAvailable->getExtra();
  10078. if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  10079. $version .= '; ' . str_replace('Package ', '', $firstAvailable->getDescription());
  10080. }
  10081. }
  10082. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  10083. if (defined('HHVM_VERSION') || (count($available) && $packageName === 'hhvm')) {
  10084. return array($msg, 'your HHVM version does not satisfy that requirement.');
  10085. }
  10086. if ($packageName === 'hhvm') {
  10087. return array($msg, 'you are running this with PHP and not HHVM.');
  10088. }
  10089. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  10090. }
  10091. if (0 === stripos($packageName, 'ext-')) {
  10092. if (false !== strpos($packageName, ' ')) {
  10093. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  10094. }
  10095. $ext = substr($packageName, 4);
  10096. $error = extension_loaded($ext) ? 'it has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'it is missing from your system';
  10097. return array("- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ', $error.'. Install or enable PHP\'s '.$ext.' extension.');
  10098. }
  10099. if (0 === stripos($packageName, 'lib-')) {
  10100. if (strtolower($packageName) === 'lib-icu') {
  10101. $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.';
  10102. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  10103. }
  10104. 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.');
  10105. }
  10106. $lockedPackage = null;
  10107. foreach ($request->getLockedPackages() as $package) {
  10108. if ($package->getName() === $packageName) {
  10109. $lockedPackage = $package;
  10110. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10111. 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.');
  10112. }
  10113. break;
  10114. }
  10115. }
  10116. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  10117. $rootReqs = $repositorySet->getRootRequires();
  10118. if (isset($rootReqs[$packageName])) {
  10119. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName) {
  10120. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  10121. });
  10122. if (0 === count($filtered)) {
  10123. 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().').');
  10124. }
  10125. }
  10126. if ($lockedPackage) {
  10127. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  10128. $filtered = array_filter($packages, function ($p) use ($fixedConstraint) {
  10129. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  10130. });
  10131. if (0 === count($filtered)) {
  10132. 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.');
  10133. }
  10134. }
  10135. $nonLockedPackages = array_filter($packages, function ($p) {
  10136. return !$p->getRepository() instanceof LockArrayRepository;
  10137. });
  10138. if (!$nonLockedPackages) {
  10139. 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.');
  10140. }
  10141. 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.');
  10142. }
  10143. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10144. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10145. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'minimum-stability');
  10146. }
  10147. 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.');
  10148. }
  10149. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10150. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10151. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'constraint');
  10152. }
  10153. 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.');
  10154. }
  10155. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  10156. $illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  10157. 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.');
  10158. }
  10159. if ($providers = $repositorySet->getProviders($packageName)) {
  10160. $maxProviders = 20;
  10161. $providersStr = implode(array_map(function ($p) {
  10162. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  10163. return " - ${p['name']}".$description."\n";
  10164. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  10165. if (count($providers) > $maxProviders + 1) {
  10166. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  10167. }
  10168. 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.");
  10169. }
  10170. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  10171. }
  10172. public static function getPackageList(array $packages, $isVerbose)
  10173. {
  10174. $prepared = array();
  10175. $hasDefaultBranch = array();
  10176. foreach ($packages as $package) {
  10177. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  10178. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  10179. if ($package->isDefaultBranch()) {
  10180. $hasDefaultBranch[$package->getName()] = true;
  10181. }
  10182. }
  10183. foreach ($prepared as $name => $package) {
  10184. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  10185. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  10186. }
  10187. uksort($package['versions'], 'version_compare');
  10188. if (!$isVerbose) {
  10189. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  10190. }
  10191. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  10192. }
  10193. return implode(', ', $prepared);
  10194. }
  10195. private static function condenseVersionList(array $versions, $max)
  10196. {
  10197. if (count($versions) <= $max) {
  10198. return $versions;
  10199. }
  10200. $filtered = array();
  10201. $byMajor = array();
  10202. foreach ($versions as $version => $pretty) {
  10203. $byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  10204. }
  10205. foreach ($byMajor as $versionsForMajor) {
  10206. if (count($versionsForMajor) > $max) {
  10207. $filtered[] = $versionsForMajor[0];
  10208. $filtered[] = '...';
  10209. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  10210. } else {
  10211. $filtered = array_merge($filtered, $versionsForMajor);
  10212. }
  10213. }
  10214. return $filtered;
  10215. }
  10216. private static function hasMultipleNames(array $packages)
  10217. {
  10218. $name = null;
  10219. foreach ($packages as $package) {
  10220. if ($name === null || $name === $package->getName()) {
  10221. $name = $package->getName();
  10222. } else {
  10223. return true;
  10224. }
  10225. }
  10226. return false;
  10227. }
  10228. private static function computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, array $higherRepoPackages, array $allReposPackages, $reason)
  10229. {
  10230. $nextRepoPackages = array();
  10231. $nextRepo = null;
  10232. foreach ($allReposPackages as $package) {
  10233. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  10234. $nextRepoPackages[] = $package;
  10235. $nextRepo = $package->getRepository();
  10236. } else {
  10237. break;
  10238. }
  10239. }
  10240. if ($nextRepo instanceof LockArrayRepository) {
  10241. $singular = count($higherRepoPackages) === 1;
  10242. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', it is ',
  10243. '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.');
  10244. }
  10245. 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.');
  10246. }
  10247. protected static function constraintToText($constraint)
  10248. {
  10249. return $constraint ? ' '.$constraint->getPrettyString() : '';
  10250. }
  10251. }
  10252. <?php
  10253. namespace Composer\DependencyResolver;
  10254. use Composer\Package\Package;
  10255. use Composer\Package\PackageInterface;
  10256. use Composer\Repository\LockArrayRepository;
  10257. use Composer\Semver\Constraint\ConstraintInterface;
  10258. use Composer\Semver\Constraint\MatchAllConstraint;
  10259. class Request
  10260. {
  10261. const UPDATE_ONLY_LISTED = 0;
  10262. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  10263. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  10264. protected $lockedRepository;
  10265. protected $requires = array();
  10266. protected $fixedPackages = array();
  10267. protected $lockedPackages = array();
  10268. protected $fixedLockedPackages = array();
  10269. protected $updateAllowList = array();
  10270. protected $updateAllowTransitiveDependencies = false;
  10271. public function __construct(LockArrayRepository $lockedRepository = null)
  10272. {
  10273. $this->lockedRepository = $lockedRepository;
  10274. }
  10275. public function requireName($packageName, ConstraintInterface $constraint = null)
  10276. {
  10277. $packageName = strtolower($packageName);
  10278. if ($constraint === null) {
  10279. $constraint = new MatchAllConstraint();
  10280. }
  10281. if (isset($this->requires[$packageName])) {
  10282. 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');
  10283. }
  10284. $this->requires[$packageName] = $constraint;
  10285. }
  10286. public function fixPackage(PackageInterface $package)
  10287. {
  10288. $this->fixedPackages[spl_object_hash($package)] = $package;
  10289. }
  10290. public function lockPackage(PackageInterface $package)
  10291. {
  10292. $this->lockedPackages[spl_object_hash($package)] = $package;
  10293. }
  10294. public function fixLockedPackage(PackageInterface $package)
  10295. {
  10296. $this->fixedPackages[spl_object_hash($package)] = $package;
  10297. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  10298. }
  10299. public function unlockPackage(PackageInterface $package)
  10300. {
  10301. unset($this->lockedPackages[spl_object_hash($package)]);
  10302. }
  10303. public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)
  10304. {
  10305. $this->updateAllowList = $updateAllowList;
  10306. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  10307. }
  10308. public function getUpdateAllowList()
  10309. {
  10310. return $this->updateAllowList;
  10311. }
  10312. public function getUpdateAllowTransitiveDependencies()
  10313. {
  10314. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  10315. }
  10316. public function getUpdateAllowTransitiveRootDependencies()
  10317. {
  10318. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  10319. }
  10320. public function getRequires()
  10321. {
  10322. return $this->requires;
  10323. }
  10324. public function getFixedPackages()
  10325. {
  10326. return $this->fixedPackages;
  10327. }
  10328. public function isFixedPackage(PackageInterface $package)
  10329. {
  10330. return isset($this->fixedPackages[spl_object_hash($package)]);
  10331. }
  10332. public function getLockedPackages()
  10333. {
  10334. return $this->lockedPackages;
  10335. }
  10336. public function isLockedPackage(PackageInterface $package)
  10337. {
  10338. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  10339. }
  10340. public function getFixedOrLockedPackages()
  10341. {
  10342. return array_merge($this->fixedPackages, $this->lockedPackages);
  10343. }
  10344. public function getPresentMap($packageIds = false)
  10345. {
  10346. $presentMap = array();
  10347. if ($this->lockedRepository) {
  10348. foreach ($this->lockedRepository->getPackages() as $package) {
  10349. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10350. }
  10351. }
  10352. foreach ($this->fixedPackages as $package) {
  10353. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10354. }
  10355. return $presentMap;
  10356. }
  10357. public function getFixedPackagesMap()
  10358. {
  10359. $fixedPackagesMap = array();
  10360. foreach ($this->fixedPackages as $package) {
  10361. $fixedPackagesMap[$package->id] = $package;
  10362. }
  10363. return $fixedPackagesMap;
  10364. }
  10365. public function getLockedRepository()
  10366. {
  10367. return $this->lockedRepository;
  10368. }
  10369. }
  10370. <?php
  10371. namespace Composer\DependencyResolver;
  10372. use Composer\Package\Link;
  10373. use Composer\Package\PackageInterface;
  10374. use Composer\Package\AliasPackage;
  10375. use Composer\Repository\RepositorySet;
  10376. use Composer\Repository\PlatformRepository;
  10377. use Composer\Package\Version\VersionParser;
  10378. use Composer\Semver\Constraint\Constraint;
  10379. abstract class Rule
  10380. {
  10381. const RULE_ROOT_REQUIRE = 2;
  10382. const RULE_FIXED = 3;
  10383. const RULE_PACKAGE_CONFLICT = 6;
  10384. const RULE_PACKAGE_REQUIRES = 7;
  10385. const RULE_PACKAGE_SAME_NAME = 10;
  10386. const RULE_LEARNED = 12;
  10387. const RULE_PACKAGE_ALIAS = 13;
  10388. const RULE_PACKAGE_INVERSE_ALIAS = 14;
  10389. const BITFIELD_TYPE = 0;
  10390. const BITFIELD_REASON = 8;
  10391. const BITFIELD_DISABLED = 16;
  10392. protected $bitfield;
  10393. protected $request;
  10394. protected $reasonData;
  10395. public function __construct($reason, $reasonData)
  10396. {
  10397. $this->reasonData = $reasonData;
  10398. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  10399. ($reason << self::BITFIELD_REASON) |
  10400. (255 << self::BITFIELD_TYPE);
  10401. }
  10402. abstract public function getLiterals();
  10403. abstract public function getHash();
  10404. abstract public function equals(Rule $rule);
  10405. public function getReason()
  10406. {
  10407. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  10408. }
  10409. public function getReasonData()
  10410. {
  10411. return $this->reasonData;
  10412. }
  10413. public function getRequiredPackage()
  10414. {
  10415. $reason = $this->getReason();
  10416. if ($reason === self::RULE_ROOT_REQUIRE) {
  10417. return $this->reasonData['packageName'];
  10418. }
  10419. if ($reason === self::RULE_FIXED) {
  10420. return $this->reasonData['package']->getName();
  10421. }
  10422. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  10423. return $this->reasonData->getTarget();
  10424. }
  10425. }
  10426. public function setType($type)
  10427. {
  10428. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  10429. }
  10430. public function getType()
  10431. {
  10432. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  10433. }
  10434. public function disable()
  10435. {
  10436. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  10437. }
  10438. public function enable()
  10439. {
  10440. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  10441. }
  10442. public function isDisabled()
  10443. {
  10444. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10445. }
  10446. public function isEnabled()
  10447. {
  10448. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10449. }
  10450. abstract public function isAssertion();
  10451. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10452. {
  10453. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  10454. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  10455. return false;
  10456. }
  10457. if ($request->getLockedRepository()) {
  10458. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10459. if ($package->getName() === $this->reasonData->getTarget()) {
  10460. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10461. return true;
  10462. }
  10463. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  10464. return true;
  10465. }
  10466. if (!$request->isLockedPackage($package)) {
  10467. return true;
  10468. }
  10469. break;
  10470. }
  10471. }
  10472. }
  10473. }
  10474. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  10475. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  10476. return false;
  10477. }
  10478. if ($request->getLockedRepository()) {
  10479. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10480. if ($package->getName() === $this->reasonData['packageName']) {
  10481. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10482. return true;
  10483. }
  10484. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  10485. return true;
  10486. }
  10487. break;
  10488. }
  10489. }
  10490. }
  10491. }
  10492. return false;
  10493. }
  10494. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10495. {
  10496. $literals = $this->getLiterals();
  10497. switch ($this->getReason()) {
  10498. case self::RULE_ROOT_REQUIRE:
  10499. $packageName = $this->reasonData['packageName'];
  10500. $constraint = $this->reasonData['constraint'];
  10501. $packages = $pool->whatProvides($packageName, $constraint);
  10502. if (!$packages) {
  10503. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  10504. }
  10505. $packagesNonAlias = array_values(array_filter($packages, function ($p) {
  10506. return !($p instanceof AliasPackage);
  10507. }));
  10508. if (count($packagesNonAlias) === 1) {
  10509. $package = $packagesNonAlias[0];
  10510. if ($request->isLockedPackage($package)) {
  10511. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  10512. }
  10513. }
  10514. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose).'.';
  10515. case self::RULE_FIXED:
  10516. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  10517. if ($request->isLockedPackage($package)) {
  10518. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  10519. }
  10520. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  10521. case self::RULE_PACKAGE_CONFLICT:
  10522. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10523. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10524. return $package2->getPrettyString().' conflicts with '.$package1->getPrettyString().'.';
  10525. case self::RULE_PACKAGE_REQUIRES:
  10526. $sourceLiteral = array_shift($literals);
  10527. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  10528. $requires = array();
  10529. foreach ($literals as $literal) {
  10530. $requires[] = $pool->literalToPackage($literal);
  10531. }
  10532. $text = $this->reasonData->getPrettyString($sourcePackage);
  10533. if ($requires) {
  10534. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose) . '.';
  10535. } else {
  10536. $targetName = $this->reasonData->getTarget();
  10537. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  10538. return $text . ' -> ' . $reason[1];
  10539. }
  10540. return $text;
  10541. case self::RULE_PACKAGE_SAME_NAME:
  10542. $packageNames = array();
  10543. foreach ($literals as $literal) {
  10544. $package = $pool->literalToPackage($literal);
  10545. $packageNames[$package->getName()] = true;
  10546. }
  10547. $replacedName = $this->reasonData;
  10548. if (count($packageNames) > 1) {
  10549. $reason = null;
  10550. if (!isset($packageNames[$replacedName])) {
  10551. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  10552. } else {
  10553. $replacerNames = $packageNames;
  10554. unset($replacerNames[$replacedName]);
  10555. $replacerNames = array_keys($replacerNames);
  10556. if (count($replacerNames) == 1) {
  10557. $reason = $replacerNames[0] . ' replaces ';
  10558. } else {
  10559. $reason = '['.implode(', ', $replacerNames).'] replace ';
  10560. }
  10561. $reason .= $replacedName.' and thus cannot coexist with it.';
  10562. }
  10563. $installedPackages = array();
  10564. $removablePackages = array();
  10565. foreach ($literals as $literal) {
  10566. if (isset($installedMap[abs($literal)])) {
  10567. $installedPackages[] = $pool->literalToPackage($literal);
  10568. } else {
  10569. $removablePackages[] = $pool->literalToPackage($literal);
  10570. }
  10571. }
  10572. if ($installedPackages && $removablePackages) {
  10573. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose).'. '.$reason;
  10574. }
  10575. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose).'. '.$reason;
  10576. }
  10577. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.';
  10578. case self::RULE_LEARNED:
  10579. $learnedString = ' (conflict analysis result)';
  10580. if (count($literals) === 1) {
  10581. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  10582. } else {
  10583. $groups = array();
  10584. foreach ($literals as $literal) {
  10585. $package = $pool->literalToPackage($literal);
  10586. if (isset($installedMap[$package->id])) {
  10587. $group = $literal > 0 ? 'keep' : 'remove';
  10588. } else {
  10589. $group = $literal > 0 ? 'install' : 'don\'t install';
  10590. }
  10591. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  10592. }
  10593. $ruleTexts = array();
  10594. foreach ($groups as $group => $packages) {
  10595. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  10596. }
  10597. $ruleText = implode(' | ', $ruleTexts);
  10598. }
  10599. return 'Conclusion: '.$ruleText.$learnedString;
  10600. case self::RULE_PACKAGE_ALIAS:
  10601. $aliasPackage = $pool->literalToPackage($literals[0]);
  10602. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10603. return '';
  10604. }
  10605. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10606. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  10607. case self::RULE_PACKAGE_INVERSE_ALIAS:
  10608. $aliasPackage = $pool->literalToPackage($literals[1]);
  10609. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10610. return '';
  10611. }
  10612. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10613. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  10614. default:
  10615. $ruleText = '';
  10616. foreach ($literals as $i => $literal) {
  10617. if ($i != 0) {
  10618. $ruleText .= '|';
  10619. }
  10620. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  10621. }
  10622. return '('.$ruleText.')';
  10623. }
  10624. }
  10625. protected function formatPackagesUnique($pool, array $packages, $isVerbose)
  10626. {
  10627. foreach ($packages as $index => $package) {
  10628. if (!\is_object($package)) {
  10629. $packages[$index] = $pool->literalToPackage($package);
  10630. }
  10631. }
  10632. return Problem::getPackageList($packages, $isVerbose);
  10633. }
  10634. private function deduplicateDefaultBranchAlias(PackageInterface $package)
  10635. {
  10636. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10637. $package = $package->getAliasOf();
  10638. }
  10639. return $package;
  10640. }
  10641. }
  10642. <?php
  10643. namespace Composer\DependencyResolver;
  10644. use Composer\Package\PackageInterface;
  10645. use Composer\Package\Link;
  10646. class Rule2Literals extends Rule
  10647. {
  10648. protected $literal1;
  10649. protected $literal2;
  10650. public function __construct($literal1, $literal2, $reason, $reasonData)
  10651. {
  10652. parent::__construct($reason, $reasonData);
  10653. if ($literal1 < $literal2) {
  10654. $this->literal1 = $literal1;
  10655. $this->literal2 = $literal2;
  10656. } else {
  10657. $this->literal1 = $literal2;
  10658. $this->literal2 = $literal1;
  10659. }
  10660. }
  10661. public function getLiterals()
  10662. {
  10663. return array($this->literal1, $this->literal2);
  10664. }
  10665. public function getHash()
  10666. {
  10667. return $this->literal1.','.$this->literal2;
  10668. }
  10669. public function equals(Rule $rule)
  10670. {
  10671. if ($rule instanceof self) {
  10672. if ($this->literal1 !== $rule->literal1) {
  10673. return false;
  10674. }
  10675. if ($this->literal2 !== $rule->literal2) {
  10676. return false;
  10677. }
  10678. return true;
  10679. }
  10680. $literals = $rule->getLiterals();
  10681. if (2 != \count($literals)) {
  10682. return false;
  10683. }
  10684. if ($this->literal1 !== $literals[0]) {
  10685. return false;
  10686. }
  10687. if ($this->literal2 !== $literals[1]) {
  10688. return false;
  10689. }
  10690. return true;
  10691. }
  10692. public function isAssertion()
  10693. {
  10694. return false;
  10695. }
  10696. public function __toString()
  10697. {
  10698. $result = $this->isDisabled() ? 'disabled(' : '(';
  10699. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  10700. return $result;
  10701. }
  10702. }
  10703. <?php
  10704. namespace Composer\DependencyResolver;
  10705. use Composer\Repository\RepositorySet;
  10706. class RuleSet implements \IteratorAggregate, \Countable
  10707. {
  10708. const TYPE_PACKAGE = 0;
  10709. const TYPE_REQUEST = 1;
  10710. const TYPE_LEARNED = 4;
  10711. public $ruleById;
  10712. protected static $types = array(
  10713. 255 => 'UNKNOWN',
  10714. self::TYPE_PACKAGE => 'PACKAGE',
  10715. self::TYPE_REQUEST => 'REQUEST',
  10716. self::TYPE_LEARNED => 'LEARNED',
  10717. );
  10718. protected $rules;
  10719. protected $nextRuleId;
  10720. protected $rulesByHash;
  10721. public function __construct()
  10722. {
  10723. $this->nextRuleId = 0;
  10724. foreach ($this->getTypes() as $type) {
  10725. $this->rules[$type] = array();
  10726. }
  10727. $this->rulesByHash = array();
  10728. }
  10729. public function add(Rule $rule, $type)
  10730. {
  10731. if (!isset(self::$types[$type])) {
  10732. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  10733. }
  10734. $hash = $rule->getHash();
  10735. if (isset($this->rulesByHash[$hash])) {
  10736. $potentialDuplicates = $this->rulesByHash[$hash];
  10737. if (\is_array($potentialDuplicates)) {
  10738. foreach ($potentialDuplicates as $potentialDuplicate) {
  10739. if ($rule->equals($potentialDuplicate)) {
  10740. return;
  10741. }
  10742. }
  10743. } else {
  10744. if ($rule->equals($potentialDuplicates)) {
  10745. return;
  10746. }
  10747. }
  10748. }
  10749. if (!isset($this->rules[$type])) {
  10750. $this->rules[$type] = array();
  10751. }
  10752. $this->rules[$type][] = $rule;
  10753. $this->ruleById[$this->nextRuleId] = $rule;
  10754. $rule->setType($type);
  10755. $this->nextRuleId++;
  10756. if (!isset($this->rulesByHash[$hash])) {
  10757. $this->rulesByHash[$hash] = $rule;
  10758. } elseif (\is_array($this->rulesByHash[$hash])) {
  10759. $this->rulesByHash[$hash][] = $rule;
  10760. } else {
  10761. $originalRule = $this->rulesByHash[$hash];
  10762. $this->rulesByHash[$hash] = array($originalRule, $rule);
  10763. }
  10764. }
  10765. public function count()
  10766. {
  10767. return $this->nextRuleId;
  10768. }
  10769. public function ruleById($id)
  10770. {
  10771. return $this->ruleById[$id];
  10772. }
  10773. public function getRules()
  10774. {
  10775. return $this->rules;
  10776. }
  10777. public function getIterator()
  10778. {
  10779. return new RuleSetIterator($this->getRules());
  10780. }
  10781. public function getIteratorFor($types)
  10782. {
  10783. if (!\is_array($types)) {
  10784. $types = array($types);
  10785. }
  10786. $allRules = $this->getRules();
  10787. $rules = array();
  10788. foreach ($types as $type) {
  10789. $rules[$type] = $allRules[$type];
  10790. }
  10791. return new RuleSetIterator($rules);
  10792. }
  10793. public function getIteratorWithout($types)
  10794. {
  10795. if (!\is_array($types)) {
  10796. $types = array($types);
  10797. }
  10798. $rules = $this->getRules();
  10799. foreach ($types as $type) {
  10800. unset($rules[$type]);
  10801. }
  10802. return new RuleSetIterator($rules);
  10803. }
  10804. public function getTypes()
  10805. {
  10806. $types = self::$types;
  10807. unset($types[255]);
  10808. return array_keys($types);
  10809. }
  10810. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
  10811. {
  10812. $string = "\n";
  10813. foreach ($this->rules as $type => $rules) {
  10814. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  10815. foreach ($rules as $rule) {
  10816. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  10817. }
  10818. $string .= "\n\n";
  10819. }
  10820. return $string;
  10821. }
  10822. public function __toString()
  10823. {
  10824. return $this->getPrettyString();
  10825. }
  10826. }
  10827. <?php
  10828. namespace Composer\DependencyResolver;
  10829. use Composer\Package\PackageInterface;
  10830. use Composer\Package\AliasPackage;
  10831. use Composer\Repository\PlatformRepository;
  10832. class RuleSetGenerator
  10833. {
  10834. protected $policy;
  10835. protected $pool;
  10836. protected $rules;
  10837. protected $addedMap;
  10838. protected $conflictAddedMap;
  10839. protected $addedPackagesByNames;
  10840. protected $conflictsForName;
  10841. public function __construct(PolicyInterface $policy, Pool $pool)
  10842. {
  10843. $this->policy = $policy;
  10844. $this->pool = $pool;
  10845. }
  10846. protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
  10847. {
  10848. $literals = array(-$package->id);
  10849. foreach ($providers as $provider) {
  10850. if ($provider === $package) {
  10851. return null;
  10852. }
  10853. $literals[] = $provider->id;
  10854. }
  10855. return new GenericRule($literals, $reason, $reasonData);
  10856. }
  10857. protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
  10858. {
  10859. $literals = array();
  10860. foreach ($packages as $package) {
  10861. $literals[] = $package->id;
  10862. }
  10863. return new GenericRule($literals, $reason, $reasonData);
  10864. }
  10865. protected function createRule2Literals(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
  10866. {
  10867. if ($issuer === $provider) {
  10868. return null;
  10869. }
  10870. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  10871. }
  10872. protected function createMultiConflictRule(array $packages, $reason, $reasonData = null)
  10873. {
  10874. $literals = array();
  10875. foreach ($packages as $package) {
  10876. $literals[] = -$package->id;
  10877. }
  10878. if (\count($literals) == 2) {
  10879. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  10880. }
  10881. return new MultiConflictRule($literals, $reason, $reasonData);
  10882. }
  10883. private function addRule($type, Rule $newRule = null)
  10884. {
  10885. if (!$newRule) {
  10886. return;
  10887. }
  10888. $this->rules->add($newRule, $type);
  10889. }
  10890. protected function addRulesForPackage(PackageInterface $package, $ignorePlatformReqs)
  10891. {
  10892. $workQueue = new \SplQueue;
  10893. $workQueue->enqueue($package);
  10894. while (!$workQueue->isEmpty()) {
  10895. $package = $workQueue->dequeue();
  10896. if (isset($this->addedMap[$package->id])) {
  10897. continue;
  10898. }
  10899. $this->addedMap[$package->id] = $package;
  10900. if (!$package instanceof AliasPackage) {
  10901. foreach ($package->getNames(false) as $name) {
  10902. $this->addedPackagesByNames[$name][] = $package;
  10903. }
  10904. } else {
  10905. $workQueue->enqueue($package->getAliasOf());
  10906. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  10907. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), array($package), Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  10908. if (!$package->hasSelfVersionRequires()) {
  10909. continue;
  10910. }
  10911. }
  10912. foreach ($package->getRequires() as $link) {
  10913. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10914. continue;
  10915. }
  10916. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10917. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  10918. foreach ($possibleRequires as $require) {
  10919. $workQueue->enqueue($require);
  10920. }
  10921. }
  10922. }
  10923. }
  10924. protected function addConflictRules($ignorePlatformReqs = false)
  10925. {
  10926. foreach ($this->addedMap as $package) {
  10927. foreach ($package->getConflicts() as $link) {
  10928. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  10929. continue;
  10930. }
  10931. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10932. continue;
  10933. }
  10934. $conflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10935. foreach ($conflicts as $conflict) {
  10936. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  10937. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  10938. }
  10939. }
  10940. }
  10941. }
  10942. foreach ($this->addedPackagesByNames as $name => $packages) {
  10943. if (\count($packages) > 1) {
  10944. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  10945. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  10946. }
  10947. }
  10948. }
  10949. protected function addRulesForRequest(Request $request, $ignorePlatformReqs)
  10950. {
  10951. foreach ($request->getFixedPackages() as $package) {
  10952. if ($package->id == -1) {
  10953. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  10954. continue;
  10955. }
  10956. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  10957. }
  10958. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10959. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  10960. 'package' => $package,
  10961. ));
  10962. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10963. }
  10964. foreach ($request->getRequires() as $packageName => $constraint) {
  10965. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  10966. continue;
  10967. }
  10968. $packages = $this->pool->whatProvides($packageName, $constraint);
  10969. if ($packages) {
  10970. foreach ($packages as $package) {
  10971. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10972. }
  10973. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  10974. 'packageName' => $packageName,
  10975. 'constraint' => $constraint,
  10976. ));
  10977. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10978. }
  10979. }
  10980. }
  10981. protected function addRulesForRootAliases($ignorePlatformReqs)
  10982. {
  10983. foreach ($this->pool->getPackages() as $package) {
  10984. if (!isset($this->addedMap[$package->id]) &&
  10985. $package instanceof AliasPackage &&
  10986. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  10987. ) {
  10988. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10989. }
  10990. }
  10991. }
  10992. public function getRulesFor(Request $request, $ignorePlatformReqs = false)
  10993. {
  10994. $this->rules = new RuleSet;
  10995. $this->addedMap = array();
  10996. $this->conflictAddedMap = array();
  10997. $this->addedPackagesByNames = array();
  10998. $this->conflictsForName = array();
  10999. $this->addRulesForRequest($request, $ignorePlatformReqs);
  11000. $this->addRulesForRootAliases($ignorePlatformReqs);
  11001. $this->addConflictRules($ignorePlatformReqs);
  11002. $this->addedMap = $this->addedPackagesByNames = null;
  11003. return $this->rules;
  11004. }
  11005. }
  11006. <?php
  11007. namespace Composer\DependencyResolver;
  11008. class RuleSetIterator implements \Iterator
  11009. {
  11010. protected $rules;
  11011. protected $types;
  11012. protected $currentOffset;
  11013. protected $currentType;
  11014. protected $currentTypeOffset;
  11015. public function __construct(array $rules)
  11016. {
  11017. $this->rules = $rules;
  11018. $this->types = array_keys($rules);
  11019. sort($this->types);
  11020. $this->rewind();
  11021. }
  11022. public function current()
  11023. {
  11024. return $this->rules[$this->currentType][$this->currentOffset];
  11025. }
  11026. public function key()
  11027. {
  11028. return $this->currentType;
  11029. }
  11030. public function next()
  11031. {
  11032. $this->currentOffset++;
  11033. if (!isset($this->rules[$this->currentType])) {
  11034. return;
  11035. }
  11036. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  11037. $this->currentOffset = 0;
  11038. do {
  11039. $this->currentTypeOffset++;
  11040. if (!isset($this->types[$this->currentTypeOffset])) {
  11041. $this->currentType = -1;
  11042. break;
  11043. }
  11044. $this->currentType = $this->types[$this->currentTypeOffset];
  11045. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11046. }
  11047. }
  11048. public function rewind()
  11049. {
  11050. $this->currentOffset = 0;
  11051. $this->currentTypeOffset = -1;
  11052. $this->currentType = -1;
  11053. do {
  11054. $this->currentTypeOffset++;
  11055. if (!isset($this->types[$this->currentTypeOffset])) {
  11056. $this->currentType = -1;
  11057. break;
  11058. }
  11059. $this->currentType = $this->types[$this->currentTypeOffset];
  11060. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11061. }
  11062. public function valid()
  11063. {
  11064. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  11065. }
  11066. }
  11067. <?php
  11068. namespace Composer\DependencyResolver;
  11069. class RuleWatchChain extends \SplDoublyLinkedList
  11070. {
  11071. protected $offset = 0;
  11072. public function seek($offset)
  11073. {
  11074. $this->rewind();
  11075. for ($i = 0; $i < $offset; $i++, $this->next());
  11076. }
  11077. public function remove()
  11078. {
  11079. $offset = $this->key();
  11080. $this->offsetUnset($offset);
  11081. $this->seek($offset);
  11082. }
  11083. }
  11084. <?php
  11085. namespace Composer\DependencyResolver;
  11086. class RuleWatchGraph
  11087. {
  11088. protected $watchChains = array();
  11089. public function insert(RuleWatchNode $node)
  11090. {
  11091. if ($node->getRule()->isAssertion()) {
  11092. return;
  11093. }
  11094. if (!$node->getRule() instanceof MultiConflictRule) {
  11095. foreach (array($node->watch1, $node->watch2) as $literal) {
  11096. if (!isset($this->watchChains[$literal])) {
  11097. $this->watchChains[$literal] = new RuleWatchChain;
  11098. }
  11099. $this->watchChains[$literal]->unshift($node);
  11100. }
  11101. } else {
  11102. foreach ($node->getRule()->getLiterals() as $literal) {
  11103. if (!isset($this->watchChains[$literal])) {
  11104. $this->watchChains[$literal] = new RuleWatchChain;
  11105. }
  11106. $this->watchChains[$literal]->unshift($node);
  11107. }
  11108. }
  11109. }
  11110. public function propagateLiteral($decidedLiteral, $level, $decisions)
  11111. {
  11112. $literal = -$decidedLiteral;
  11113. if (!isset($this->watchChains[$literal])) {
  11114. return null;
  11115. }
  11116. $chain = $this->watchChains[$literal];
  11117. $chain->rewind();
  11118. while ($chain->valid()) {
  11119. $node = $chain->current();
  11120. if (!$node->getRule() instanceof MultiConflictRule) {
  11121. $otherWatch = $node->getOtherWatch($literal);
  11122. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  11123. $ruleLiterals = $node->getRule()->getLiterals();
  11124. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  11125. return $literal !== $ruleLiteral &&
  11126. $otherWatch !== $ruleLiteral &&
  11127. !$decisions->conflict($ruleLiteral);
  11128. });
  11129. if ($alternativeLiterals) {
  11130. reset($alternativeLiterals);
  11131. $this->moveWatch($literal, current($alternativeLiterals), $node);
  11132. continue;
  11133. }
  11134. if ($decisions->conflict($otherWatch)) {
  11135. return $node->getRule();
  11136. }
  11137. $decisions->decide($otherWatch, $level, $node->getRule());
  11138. }
  11139. } else {
  11140. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  11141. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  11142. if ($decisions->conflict($otherLiteral)) {
  11143. return $node->getRule();
  11144. }
  11145. $decisions->decide($otherLiteral, $level, $node->getRule());
  11146. }
  11147. }
  11148. }
  11149. $chain->next();
  11150. }
  11151. return null;
  11152. }
  11153. protected function moveWatch($fromLiteral, $toLiteral, $node)
  11154. {
  11155. if (!isset($this->watchChains[$toLiteral])) {
  11156. $this->watchChains[$toLiteral] = new RuleWatchChain;
  11157. }
  11158. $node->moveWatch($fromLiteral, $toLiteral);
  11159. $this->watchChains[$fromLiteral]->remove();
  11160. $this->watchChains[$toLiteral]->unshift($node);
  11161. }
  11162. }
  11163. <?php
  11164. namespace Composer\DependencyResolver;
  11165. class RuleWatchNode
  11166. {
  11167. public $watch1;
  11168. public $watch2;
  11169. protected $rule;
  11170. public function __construct($rule)
  11171. {
  11172. $this->rule = $rule;
  11173. $literals = $rule->getLiterals();
  11174. $literalCount = \count($literals);
  11175. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  11176. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  11177. }
  11178. public function watch2OnHighest(Decisions $decisions)
  11179. {
  11180. $literals = $this->rule->getLiterals();
  11181. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  11182. return;
  11183. }
  11184. $watchLevel = 0;
  11185. foreach ($literals as $literal) {
  11186. $level = $decisions->decisionLevel($literal);
  11187. if ($level > $watchLevel) {
  11188. $this->watch2 = $literal;
  11189. $watchLevel = $level;
  11190. }
  11191. }
  11192. }
  11193. public function getRule()
  11194. {
  11195. return $this->rule;
  11196. }
  11197. public function getOtherWatch($literal)
  11198. {
  11199. if ($this->watch1 == $literal) {
  11200. return $this->watch2;
  11201. }
  11202. return $this->watch1;
  11203. }
  11204. public function moveWatch($from, $to)
  11205. {
  11206. if ($this->watch1 == $from) {
  11207. $this->watch1 = $to;
  11208. } else {
  11209. $this->watch2 = $to;
  11210. }
  11211. }
  11212. }
  11213. <?php
  11214. namespace Composer\DependencyResolver;
  11215. use Composer\IO\IOInterface;
  11216. use Composer\Package\PackageInterface;
  11217. use Composer\Repository\PlatformRepository;
  11218. class Solver
  11219. {
  11220. const BRANCH_LITERALS = 0;
  11221. const BRANCH_LEVEL = 1;
  11222. protected $policy;
  11223. protected $pool;
  11224. protected $rules;
  11225. protected $watchGraph;
  11226. protected $decisions;
  11227. protected $fixedMap;
  11228. protected $propagateIndex;
  11229. protected $branches = array();
  11230. protected $problems = array();
  11231. protected $learnedPool = array();
  11232. protected $learnedWhy = array();
  11233. public $testFlagLearnedPositiveLiteral = false;
  11234. protected $io;
  11235. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  11236. {
  11237. $this->io = $io;
  11238. $this->policy = $policy;
  11239. $this->pool = $pool;
  11240. }
  11241. public function getRuleSetSize()
  11242. {
  11243. return \count($this->rules);
  11244. }
  11245. public function getPool()
  11246. {
  11247. return $this->pool;
  11248. }
  11249. private function makeAssertionRuleDecisions()
  11250. {
  11251. $decisionStart = \count($this->decisions) - 1;
  11252. $rulesCount = \count($this->rules);
  11253. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  11254. $rule = $this->rules->ruleById[$ruleIndex];
  11255. if (!$rule->isAssertion() || $rule->isDisabled()) {
  11256. continue;
  11257. }
  11258. $literals = $rule->getLiterals();
  11259. $literal = $literals[0];
  11260. if (!$this->decisions->decided($literal)) {
  11261. $this->decisions->decide($literal, 1, $rule);
  11262. continue;
  11263. }
  11264. if ($this->decisions->satisfy($literal)) {
  11265. continue;
  11266. }
  11267. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  11268. $rule->disable();
  11269. continue;
  11270. }
  11271. $conflict = $this->decisions->decisionRule($literal);
  11272. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  11273. $problem = new Problem();
  11274. $problem->addRule($rule);
  11275. $problem->addRule($conflict);
  11276. $rule->disable();
  11277. $this->problems[] = $problem;
  11278. continue;
  11279. }
  11280. $problem = new Problem();
  11281. $problem->addRule($rule);
  11282. $problem->addRule($conflict);
  11283. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  11284. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  11285. continue;
  11286. }
  11287. $assertRuleLiterals = $assertRule->getLiterals();
  11288. $assertRuleLiteral = $assertRuleLiterals[0];
  11289. if (abs($literal) !== abs($assertRuleLiteral)) {
  11290. continue;
  11291. }
  11292. $problem->addRule($assertRule);
  11293. $assertRule->disable();
  11294. }
  11295. $this->problems[] = $problem;
  11296. $this->decisions->resetToOffset($decisionStart);
  11297. $ruleIndex = -1;
  11298. }
  11299. }
  11300. protected function setupFixedMap(Request $request)
  11301. {
  11302. $this->fixedMap = array();
  11303. foreach ($request->getFixedPackages() as $package) {
  11304. $this->fixedMap[$package->id] = $package;
  11305. }
  11306. }
  11307. protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
  11308. {
  11309. foreach ($request->getRequires() as $packageName => $constraint) {
  11310. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  11311. continue;
  11312. }
  11313. if (!$this->pool->whatProvides($packageName, $constraint)) {
  11314. $problem = new Problem();
  11315. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  11316. $this->problems[] = $problem;
  11317. }
  11318. }
  11319. }
  11320. public function solve(Request $request, $ignorePlatformReqs = false)
  11321. {
  11322. $this->setupFixedMap($request);
  11323. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  11324. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  11325. $this->rules = $ruleSetGenerator->getRulesFor($request, $ignorePlatformReqs);
  11326. unset($ruleSetGenerator);
  11327. $this->checkForRootRequireProblems($request, $ignorePlatformReqs);
  11328. $this->decisions = new Decisions($this->pool);
  11329. $this->watchGraph = new RuleWatchGraph;
  11330. foreach ($this->rules as $rule) {
  11331. $this->watchGraph->insert(new RuleWatchNode($rule));
  11332. }
  11333. $this->makeAssertionRuleDecisions();
  11334. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  11335. $before = microtime(true);
  11336. $this->runSat();
  11337. $this->io->writeError('', true, IOInterface::DEBUG);
  11338. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  11339. if ($this->problems) {
  11340. throw new SolverProblemsException($this->problems, $this->learnedPool);
  11341. }
  11342. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  11343. }
  11344. protected function propagate($level)
  11345. {
  11346. while ($this->decisions->validOffset($this->propagateIndex)) {
  11347. $decision = $this->decisions->atOffset($this->propagateIndex);
  11348. $conflict = $this->watchGraph->propagateLiteral(
  11349. $decision[Decisions::DECISION_LITERAL],
  11350. $level,
  11351. $this->decisions
  11352. );
  11353. $this->propagateIndex++;
  11354. if ($conflict) {
  11355. return $conflict;
  11356. }
  11357. }
  11358. return null;
  11359. }
  11360. private function revert($level)
  11361. {
  11362. while (!$this->decisions->isEmpty()) {
  11363. $literal = $this->decisions->lastLiteral();
  11364. if ($this->decisions->undecided($literal)) {
  11365. break;
  11366. }
  11367. $decisionLevel = $this->decisions->decisionLevel($literal);
  11368. if ($decisionLevel <= $level) {
  11369. break;
  11370. }
  11371. $this->decisions->revertLast();
  11372. $this->propagateIndex = \count($this->decisions);
  11373. }
  11374. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  11375. array_pop($this->branches);
  11376. }
  11377. }
  11378. private function setPropagateLearn($level, $literal, Rule $rule)
  11379. {
  11380. $level++;
  11381. $this->decisions->decide($literal, $level, $rule);
  11382. while (true) {
  11383. $rule = $this->propagate($level);
  11384. if (!$rule) {
  11385. break;
  11386. }
  11387. if ($level == 1) {
  11388. return $this->analyzeUnsolvable($rule);
  11389. }
  11390. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  11391. if ($newLevel <= 0 || $newLevel >= $level) {
  11392. throw new SolverBugException(
  11393. "Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
  11394. );
  11395. }
  11396. if (!$newRule) {
  11397. throw new SolverBugException(
  11398. "No rule was learned from analyzing $rule at level $level."
  11399. );
  11400. }
  11401. $level = $newLevel;
  11402. $this->revert($level);
  11403. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  11404. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  11405. $ruleNode = new RuleWatchNode($newRule);
  11406. $ruleNode->watch2OnHighest($this->decisions);
  11407. $this->watchGraph->insert($ruleNode);
  11408. $this->decisions->decide($learnLiteral, $level, $newRule);
  11409. }
  11410. return $level;
  11411. }
  11412. private function selectAndInstall($level, array $decisionQueue, Rule $rule)
  11413. {
  11414. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  11415. $selectedLiteral = array_shift($literals);
  11416. if (\count($literals)) {
  11417. $this->branches[] = array($literals, $level);
  11418. }
  11419. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  11420. }
  11421. protected function analyze($level, Rule $rule)
  11422. {
  11423. $analyzedRule = $rule;
  11424. $ruleLevel = 1;
  11425. $num = 0;
  11426. $l1num = 0;
  11427. $seen = array();
  11428. $learnedLiterals = array(null);
  11429. $decisionId = \count($this->decisions);
  11430. $this->learnedPool[] = array();
  11431. while (true) {
  11432. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11433. foreach ($rule->getLiterals() as $literal) {
  11434. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  11435. continue;
  11436. }
  11437. if ($this->decisions->satisfy($literal)) {
  11438. continue;
  11439. }
  11440. if (isset($seen[abs($literal)])) {
  11441. continue;
  11442. }
  11443. $seen[abs($literal)] = true;
  11444. $l = $this->decisions->decisionLevel($literal);
  11445. if (1 === $l) {
  11446. $l1num++;
  11447. } elseif ($level === $l) {
  11448. $num++;
  11449. } else {
  11450. $learnedLiterals[] = $literal;
  11451. if ($l > $ruleLevel) {
  11452. $ruleLevel = $l;
  11453. }
  11454. }
  11455. }
  11456. unset($literal);
  11457. $l1retry = true;
  11458. while ($l1retry) {
  11459. $l1retry = false;
  11460. if (!$num && !--$l1num) {
  11461. break 2;
  11462. }
  11463. while (true) {
  11464. if ($decisionId <= 0) {
  11465. throw new SolverBugException(
  11466. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  11467. );
  11468. }
  11469. $decisionId--;
  11470. $decision = $this->decisions->atOffset($decisionId);
  11471. $literal = $decision[Decisions::DECISION_LITERAL];
  11472. if (isset($seen[abs($literal)])) {
  11473. break;
  11474. }
  11475. }
  11476. unset($seen[abs($literal)]);
  11477. if ($num && 0 === --$num) {
  11478. if ($literal < 0) {
  11479. $this->testFlagLearnedPositiveLiteral = true;
  11480. }
  11481. $learnedLiterals[0] = -$literal;
  11482. if (!$l1num) {
  11483. break 2;
  11484. }
  11485. foreach ($learnedLiterals as $i => $learnedLiteral) {
  11486. if ($i !== 0) {
  11487. unset($seen[abs($learnedLiteral)]);
  11488. }
  11489. }
  11490. $l1num++;
  11491. $l1retry = true;
  11492. } else {
  11493. $decision = $this->decisions->atOffset($decisionId);
  11494. $rule = $decision[Decisions::DECISION_REASON];
  11495. if ($rule instanceof MultiConflictRule) {
  11496. foreach ($rule->getLiterals() as $literal) {
  11497. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  11498. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11499. $l = $this->decisions->decisionLevel($literal);
  11500. if (1 === $l) {
  11501. $l1num++;
  11502. } elseif ($level === $l) {
  11503. $num++;
  11504. } else {
  11505. $learnedLiterals[] = $literal;
  11506. if ($l > $ruleLevel) {
  11507. $ruleLevel = $l;
  11508. }
  11509. }
  11510. $seen[abs($literal)] = true;
  11511. break;
  11512. }
  11513. }
  11514. $l1retry = true;
  11515. }
  11516. }
  11517. }
  11518. $decision = $this->decisions->atOffset($decisionId);
  11519. $rule = $decision[Decisions::DECISION_REASON];
  11520. }
  11521. $why = \count($this->learnedPool) - 1;
  11522. if (!$learnedLiterals[0]) {
  11523. throw new SolverBugException(
  11524. "Did not find a learnable literal in analyzed rule $analyzedRule."
  11525. );
  11526. }
  11527. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  11528. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  11529. }
  11530. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen)
  11531. {
  11532. $why = spl_object_hash($conflictRule);
  11533. $ruleSeen[$why] = true;
  11534. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  11535. $learnedWhy = $this->learnedWhy[$why];
  11536. $problemRules = $this->learnedPool[$learnedWhy];
  11537. foreach ($problemRules as $problemRule) {
  11538. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  11539. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  11540. }
  11541. }
  11542. return;
  11543. }
  11544. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  11545. return;
  11546. }
  11547. $problem->nextSection();
  11548. $problem->addRule($conflictRule);
  11549. }
  11550. private function analyzeUnsolvable(Rule $conflictRule)
  11551. {
  11552. $problem = new Problem();
  11553. $problem->addRule($conflictRule);
  11554. $ruleSeen = array();
  11555. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  11556. $this->problems[] = $problem;
  11557. $seen = array();
  11558. $literals = $conflictRule->getLiterals();
  11559. foreach ($literals as $literal) {
  11560. if ($this->decisions->satisfy($literal)) {
  11561. continue;
  11562. }
  11563. $seen[abs($literal)] = true;
  11564. }
  11565. foreach ($this->decisions as $decision) {
  11566. $literal = $decision[Decisions::DECISION_LITERAL];
  11567. if (!isset($seen[abs($literal)])) {
  11568. continue;
  11569. }
  11570. $why = $decision[Decisions::DECISION_REASON];
  11571. $problem->addRule($why);
  11572. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  11573. $literals = $why->getLiterals();
  11574. foreach ($literals as $literal) {
  11575. if ($this->decisions->satisfy($literal)) {
  11576. continue;
  11577. }
  11578. $seen[abs($literal)] = true;
  11579. }
  11580. }
  11581. return 0;
  11582. }
  11583. private function enableDisableLearnedRules()
  11584. {
  11585. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  11586. $why = $this->learnedWhy[spl_object_hash($rule)];
  11587. $problemRules = $this->learnedPool[$why];
  11588. $foundDisabled = false;
  11589. foreach ($problemRules as $problemRule) {
  11590. if ($problemRule->isDisabled()) {
  11591. $foundDisabled = true;
  11592. break;
  11593. }
  11594. }
  11595. if ($foundDisabled && $rule->isEnabled()) {
  11596. $rule->disable();
  11597. } elseif (!$foundDisabled && $rule->isDisabled()) {
  11598. $rule->enable();
  11599. }
  11600. }
  11601. }
  11602. private function runSat()
  11603. {
  11604. $this->propagateIndex = 0;
  11605. $level = 1;
  11606. $systemLevel = $level + 1;
  11607. while (true) {
  11608. if (1 === $level) {
  11609. $conflictRule = $this->propagate($level);
  11610. if (null !== $conflictRule) {
  11611. if ($this->analyzeUnsolvable($conflictRule)) {
  11612. continue;
  11613. }
  11614. return;
  11615. }
  11616. }
  11617. if ($level < $systemLevel) {
  11618. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  11619. foreach ($iterator as $rule) {
  11620. if ($rule->isEnabled()) {
  11621. $decisionQueue = array();
  11622. $noneSatisfied = true;
  11623. foreach ($rule->getLiterals() as $literal) {
  11624. if ($this->decisions->satisfy($literal)) {
  11625. $noneSatisfied = false;
  11626. break;
  11627. }
  11628. if ($literal > 0 && $this->decisions->undecided($literal)) {
  11629. $decisionQueue[] = $literal;
  11630. }
  11631. }
  11632. if ($noneSatisfied && \count($decisionQueue)) {
  11633. $prunedQueue = array();
  11634. foreach ($decisionQueue as $literal) {
  11635. if (isset($this->fixedMap[abs($literal)])) {
  11636. $prunedQueue[] = $literal;
  11637. }
  11638. }
  11639. if (!empty($prunedQueue)) {
  11640. $decisionQueue = $prunedQueue;
  11641. }
  11642. }
  11643. if ($noneSatisfied && \count($decisionQueue)) {
  11644. $oLevel = $level;
  11645. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11646. if (0 === $level) {
  11647. return;
  11648. }
  11649. if ($level <= $oLevel) {
  11650. break;
  11651. }
  11652. }
  11653. }
  11654. }
  11655. $systemLevel = $level + 1;
  11656. $iterator->next();
  11657. if ($iterator->valid()) {
  11658. continue;
  11659. }
  11660. }
  11661. if ($level < $systemLevel) {
  11662. $systemLevel = $level;
  11663. }
  11664. $rulesCount = \count($this->rules);
  11665. $pass = 1;
  11666. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  11667. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  11668. if ($i == $rulesCount) {
  11669. if (1 === $pass) {
  11670. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  11671. } else {
  11672. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  11673. }
  11674. $i = 0;
  11675. $pass++;
  11676. }
  11677. $rule = $this->rules->ruleById[$i];
  11678. $literals = $rule->getLiterals();
  11679. if ($rule->isDisabled()) {
  11680. continue;
  11681. }
  11682. $decisionQueue = array();
  11683. foreach ($literals as $literal) {
  11684. if ($literal <= 0) {
  11685. if (!$this->decisions->decidedInstall($literal)) {
  11686. continue 2;
  11687. }
  11688. } else {
  11689. if ($this->decisions->decidedInstall($literal)) {
  11690. continue 2;
  11691. }
  11692. if ($this->decisions->undecided($literal)) {
  11693. $decisionQueue[] = $literal;
  11694. }
  11695. }
  11696. }
  11697. if (\count($decisionQueue) < 2) {
  11698. continue;
  11699. }
  11700. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11701. if (0 === $level) {
  11702. return;
  11703. }
  11704. $rulesCount = \count($this->rules);
  11705. $n = -1;
  11706. }
  11707. if ($level < $systemLevel) {
  11708. continue;
  11709. }
  11710. if (\count($this->branches)) {
  11711. $lastLiteral = null;
  11712. $lastLevel = null;
  11713. $lastBranchIndex = 0;
  11714. $lastBranchOffset = 0;
  11715. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  11716. list($literals, $l) = $this->branches[$i];
  11717. foreach ($literals as $offset => $literal) {
  11718. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  11719. $lastLiteral = $literal;
  11720. $lastBranchIndex = $i;
  11721. $lastBranchOffset = $offset;
  11722. $lastLevel = $l;
  11723. }
  11724. }
  11725. }
  11726. if ($lastLiteral) {
  11727. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  11728. $level = $lastLevel;
  11729. $this->revert($level);
  11730. $why = $this->decisions->lastReason();
  11731. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  11732. if ($level == 0) {
  11733. return;
  11734. }
  11735. continue;
  11736. }
  11737. }
  11738. break;
  11739. }
  11740. }
  11741. }
  11742. <?php
  11743. namespace Composer\DependencyResolver;
  11744. class SolverBugException extends \RuntimeException
  11745. {
  11746. public function __construct($message)
  11747. {
  11748. parent::__construct(
  11749. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  11750. "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"
  11751. );
  11752. }
  11753. }
  11754. <?php
  11755. namespace Composer\DependencyResolver;
  11756. use Composer\Util\IniHelper;
  11757. use Composer\Repository\RepositorySet;
  11758. class SolverProblemsException extends \RuntimeException
  11759. {
  11760. protected $problems;
  11761. protected $learnedPool;
  11762. public function __construct(array $problems, array $learnedPool)
  11763. {
  11764. $this->problems = $problems;
  11765. $this->learnedPool = $learnedPool;
  11766. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', 2);
  11767. }
  11768. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
  11769. {
  11770. $installedMap = $request->getPresentMap(true);
  11771. $hasExtensionProblems = false;
  11772. $isCausedByLock = false;
  11773. $problems = array();
  11774. foreach ($this->problems as $problem) {
  11775. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  11776. if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
  11777. $hasExtensionProblems = true;
  11778. }
  11779. $isCausedByLock |= $problem->isCausedByLock($repositorySet, $request, $pool);
  11780. }
  11781. $i = 1;
  11782. $text = "\n";
  11783. foreach (array_unique($problems) as $problem) {
  11784. $text .= " Problem ".($i++).$problem;
  11785. }
  11786. $hints = array();
  11787. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  11788. $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.";
  11789. }
  11790. if ($hasExtensionProblems) {
  11791. $hints[] = $this->createExtensionHint();
  11792. }
  11793. if ($isCausedByLock && !$isDevExtraction && !$request->getUpdateAllowTransitiveRootDependencies()) {
  11794. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  11795. }
  11796. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  11797. $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+.";
  11798. }
  11799. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  11800. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  11801. $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.";
  11802. }
  11803. }
  11804. if ($hints) {
  11805. $text .= "\n" . implode("\n\n", $hints);
  11806. }
  11807. return $text;
  11808. }
  11809. public function getProblems()
  11810. {
  11811. return $this->problems;
  11812. }
  11813. private function createExtensionHint()
  11814. {
  11815. $paths = IniHelper::getAll();
  11816. if (count($paths) === 1 && empty($paths[0])) {
  11817. return '';
  11818. }
  11819. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  11820. $text .= implode("\n - ", $paths);
  11821. $text .= "\nYou can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
  11822. return $text;
  11823. }
  11824. private function hasExtensionProblems(array $reasonSets)
  11825. {
  11826. foreach ($reasonSets as $reasonSet) {
  11827. foreach ($reasonSet as $rule) {
  11828. if (0 === strpos($rule->getRequiredPackage(), 'ext-')) {
  11829. return true;
  11830. }
  11831. }
  11832. }
  11833. return false;
  11834. }
  11835. }
  11836. <?php
  11837. namespace Composer\DependencyResolver;
  11838. use Composer\Package\AliasPackage;
  11839. use Composer\Package\Link;
  11840. use Composer\Package\PackageInterface;
  11841. use Composer\Repository\PlatformRepository;
  11842. class Transaction
  11843. {
  11844. protected $operations;
  11845. protected $presentPackages;
  11846. protected $resultPackageMap;
  11847. protected $resultPackagesByName = array();
  11848. public function __construct($presentPackages, $resultPackages)
  11849. {
  11850. $this->presentPackages = $presentPackages;
  11851. $this->setResultPackageMaps($resultPackages);
  11852. $this->operations = $this->calculateOperations();
  11853. }
  11854. public function getOperations()
  11855. {
  11856. return $this->operations;
  11857. }
  11858. private function setResultPackageMaps($resultPackages)
  11859. {
  11860. $packageSort = function (PackageInterface $a, PackageInterface $b) {
  11861. if ($a->getName() == $b->getName()) {
  11862. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  11863. return $a instanceof AliasPackage ? -1 : 1;
  11864. }
  11865. return strcmp($b->getVersion(), $a->getVersion());
  11866. }
  11867. return strcmp($b->getName(), $a->getName());
  11868. };
  11869. $this->resultPackageMap = array();
  11870. foreach ($resultPackages as $package) {
  11871. $this->resultPackageMap[spl_object_hash($package)] = $package;
  11872. foreach ($package->getNames() as $name) {
  11873. $this->resultPackagesByName[$name][] = $package;
  11874. }
  11875. }
  11876. uasort($this->resultPackageMap, $packageSort);
  11877. foreach ($this->resultPackagesByName as $name => $packages) {
  11878. uasort($this->resultPackagesByName[$name], $packageSort);
  11879. }
  11880. }
  11881. protected function calculateOperations()
  11882. {
  11883. $operations = array();
  11884. $presentPackageMap = array();
  11885. $removeMap = array();
  11886. $presentAliasMap = array();
  11887. $removeAliasMap = array();
  11888. foreach ($this->presentPackages as $package) {
  11889. if ($package instanceof AliasPackage) {
  11890. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11891. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11892. } else {
  11893. $presentPackageMap[$package->getName()] = $package;
  11894. $removeMap[$package->getName()] = $package;
  11895. }
  11896. }
  11897. $stack = $this->getRootPackages();
  11898. $visited = array();
  11899. $processed = array();
  11900. while (!empty($stack)) {
  11901. $package = array_pop($stack);
  11902. if (isset($processed[spl_object_hash($package)])) {
  11903. continue;
  11904. }
  11905. if (!isset($visited[spl_object_hash($package)])) {
  11906. $visited[spl_object_hash($package)] = true;
  11907. $stack[] = $package;
  11908. if ($package instanceof AliasPackage) {
  11909. $stack[] = $package->getAliasOf();
  11910. } else {
  11911. foreach ($package->getRequires() as $link) {
  11912. $possibleRequires = $this->getProvidersInResult($link);
  11913. foreach ($possibleRequires as $require) {
  11914. $stack[] = $require;
  11915. }
  11916. }
  11917. }
  11918. } elseif (!isset($processed[spl_object_hash($package)])) {
  11919. $processed[spl_object_hash($package)] = true;
  11920. if ($package instanceof AliasPackage) {
  11921. $aliasKey = $package->getName().'::'.$package->getVersion();
  11922. if (isset($presentAliasMap[$aliasKey])) {
  11923. unset($removeAliasMap[$aliasKey]);
  11924. } else {
  11925. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  11926. }
  11927. } else {
  11928. if (isset($presentPackageMap[$package->getName()])) {
  11929. $source = $presentPackageMap[$package->getName()];
  11930. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  11931. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  11932. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  11933. ) {
  11934. $operations[] = new Operation\UpdateOperation($source, $package);
  11935. }
  11936. unset($removeMap[$package->getName()]);
  11937. } else {
  11938. $operations[] = new Operation\InstallOperation($package);
  11939. unset($removeMap[$package->getName()]);
  11940. }
  11941. }
  11942. }
  11943. }
  11944. foreach ($removeMap as $name => $package) {
  11945. array_unshift($operations, new Operation\UninstallOperation($package));
  11946. }
  11947. foreach ($removeAliasMap as $nameVersion => $package) {
  11948. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  11949. }
  11950. $operations = $this->movePluginsToFront($operations);
  11951. $operations = $this->moveUninstallsToFront($operations);
  11952. return $this->operations = $operations;
  11953. }
  11954. protected function getRootPackages()
  11955. {
  11956. $roots = $this->resultPackageMap;
  11957. foreach ($this->resultPackageMap as $packageHash => $package) {
  11958. if (!isset($roots[$packageHash])) {
  11959. continue;
  11960. }
  11961. foreach ($package->getRequires() as $link) {
  11962. $possibleRequires = $this->getProvidersInResult($link);
  11963. foreach ($possibleRequires as $require) {
  11964. if ($require !== $package) {
  11965. unset($roots[spl_object_hash($require)]);
  11966. }
  11967. }
  11968. }
  11969. }
  11970. return $roots;
  11971. }
  11972. protected function getProvidersInResult(Link $link)
  11973. {
  11974. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  11975. return array();
  11976. }
  11977. return $this->resultPackagesByName[$link->getTarget()];
  11978. }
  11979. private function movePluginsToFront(array $operations)
  11980. {
  11981. $dlModifyingPluginsNoDeps = array();
  11982. $dlModifyingPluginsWithDeps = array();
  11983. $dlModifyingPluginRequires = array();
  11984. $pluginsNoDeps = array();
  11985. $pluginsWithDeps = array();
  11986. $pluginRequires = array();
  11987. foreach (array_reverse($operations, true) as $idx => $op) {
  11988. if ($op instanceof Operation\InstallOperation) {
  11989. $package = $op->getPackage();
  11990. } elseif ($op instanceof Operation\UpdateOperation) {
  11991. $package = $op->getTargetPackage();
  11992. } else {
  11993. continue;
  11994. }
  11995. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  11996. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  11997. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  11998. return !PlatformRepository::isPlatformPackage($req);
  11999. });
  12000. if ($isDownloadsModifyingPlugin && !count($requires)) {
  12001. array_unshift($dlModifyingPluginsNoDeps, $op);
  12002. } else {
  12003. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  12004. array_unshift($dlModifyingPluginsWithDeps, $op);
  12005. }
  12006. unset($operations[$idx]);
  12007. continue;
  12008. }
  12009. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  12010. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  12011. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  12012. return !PlatformRepository::isPlatformPackage($req);
  12013. });
  12014. if ($isPlugin && !count($requires)) {
  12015. array_unshift($pluginsNoDeps, $op);
  12016. } else {
  12017. $pluginRequires = array_merge($pluginRequires, $requires);
  12018. array_unshift($pluginsWithDeps, $op);
  12019. }
  12020. unset($operations[$idx]);
  12021. }
  12022. }
  12023. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  12024. }
  12025. private function moveUninstallsToFront(array $operations)
  12026. {
  12027. $uninstOps = array();
  12028. foreach ($operations as $idx => $op) {
  12029. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  12030. $uninstOps[] = $op;
  12031. unset($operations[$idx]);
  12032. }
  12033. }
  12034. return array_merge($uninstOps, $operations);
  12035. }
  12036. }
  12037. <?php
  12038. namespace Composer\Downloader;
  12039. use Composer\Package\PackageInterface;
  12040. use Symfony\Component\Finder\Finder;
  12041. use React\Promise\PromiseInterface;
  12042. use Composer\DependencyResolver\Operation\InstallOperation;
  12043. abstract class ArchiveDownloader extends FileDownloader
  12044. {
  12045. public function install(PackageInterface $package, $path, $output = true)
  12046. {
  12047. if ($output) {
  12048. $this->io->writeError(" - " . InstallOperation::format($package).": Extracting archive");
  12049. } else {
  12050. $this->io->writeError('Extracting archive', false);
  12051. }
  12052. $vendorDir = $this->config->get('vendor-dir');
  12053. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  12054. $this->filesystem->emptyDirectory($path);
  12055. }
  12056. do {
  12057. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  12058. } while (is_dir($temporaryDir));
  12059. $this->addCleanupPath($package, $temporaryDir);
  12060. if (!is_dir($path) || realpath($path) !== getcwd()) {
  12061. $this->addCleanupPath($package, $path);
  12062. }
  12063. $this->filesystem->ensureDirectoryExists($temporaryDir);
  12064. $fileName = $this->getFileName($package, $path);
  12065. $filesystem = $this->filesystem;
  12066. $self = $this;
  12067. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package, $self) {
  12068. $self->clearLastCacheWrite($package);
  12069. $filesystem->removeDirectory($temporaryDir);
  12070. if (is_dir($path) && realpath($path) !== getcwd()) {
  12071. $filesystem->removeDirectory($path);
  12072. }
  12073. $self->removeCleanupPath($package, $temporaryDir);
  12074. $self->removeCleanupPath($package, realpath($path));
  12075. };
  12076. $promise = null;
  12077. try {
  12078. $promise = $this->extract($package, $fileName, $temporaryDir);
  12079. } catch (\Exception $e) {
  12080. $cleanup();
  12081. throw $e;
  12082. }
  12083. if (!$promise instanceof PromiseInterface) {
  12084. $promise = \React\Promise\resolve();
  12085. }
  12086. return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) {
  12087. $filesystem->unlink($fileName);
  12088. $getFolderContent = function ($dir) {
  12089. $finder = Finder::create()
  12090. ->ignoreVCS(false)
  12091. ->ignoreDotFiles(false)
  12092. ->notName('.DS_Store')
  12093. ->depth(0)
  12094. ->in($dir);
  12095. return iterator_to_array($finder);
  12096. };
  12097. $renameRecursively = null;
  12098. $renameRecursively = function ($from, $to) use ($filesystem, $getFolderContent, $package, &$renameRecursively) {
  12099. $contentDir = $getFolderContent($from);
  12100. foreach ($contentDir as $file) {
  12101. $file = (string) $file;
  12102. if (is_dir($to . '/' . basename($file))) {
  12103. if (!is_dir($file)) {
  12104. throw new \RuntimeException('Installing '.$package.' would lead to overwriting the '.$to.'/'.basename($file).' directory with a file from the package, invalid operation.');
  12105. }
  12106. $renameRecursively($file, $to . '/' . basename($file));
  12107. } else {
  12108. $filesystem->rename($file, $to . '/' . basename($file));
  12109. }
  12110. }
  12111. };
  12112. $renameAsOne = false;
  12113. if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectory($path))) {
  12114. $renameAsOne = true;
  12115. }
  12116. $contentDir = $getFolderContent($temporaryDir);
  12117. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));
  12118. if ($renameAsOne) {
  12119. if ($singleDirAtTopLevel) {
  12120. $extractedDir = (string) reset($contentDir);
  12121. } else {
  12122. $extractedDir = $temporaryDir;
  12123. }
  12124. $filesystem->rename($extractedDir, $path);
  12125. } else {
  12126. $from = $temporaryDir;
  12127. if ($singleDirAtTopLevel) {
  12128. $from = (string) reset($contentDir);
  12129. }
  12130. $renameRecursively($from, $path);
  12131. }
  12132. $filesystem->removeDirectory($temporaryDir);
  12133. $self->removeCleanupPath($package, $temporaryDir);
  12134. $self->removeCleanupPath($package, $path);
  12135. }, function ($e) use ($cleanup) {
  12136. $cleanup();
  12137. throw $e;
  12138. });
  12139. }
  12140. abstract protected function extract(PackageInterface $package, $file, $path);
  12141. }
  12142. <?php
  12143. namespace Composer\Downloader;
  12144. use Composer\Package\PackageInterface;
  12145. interface ChangeReportInterface
  12146. {
  12147. public function getLocalChanges(PackageInterface $package, $path);
  12148. }
  12149. <?php
  12150. namespace Composer\Downloader;
  12151. use Composer\Package\PackageInterface;
  12152. use Composer\IO\IOInterface;
  12153. use Composer\Util\Filesystem;
  12154. use Composer\Exception\IrrecoverableDownloadException;
  12155. use React\Promise\PromiseInterface;
  12156. class DownloadManager
  12157. {
  12158. private $io;
  12159. private $preferDist = false;
  12160. private $preferSource;
  12161. private $packagePreferences = array();
  12162. private $filesystem;
  12163. private $downloaders = array();
  12164. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  12165. {
  12166. $this->io = $io;
  12167. $this->preferSource = $preferSource;
  12168. $this->filesystem = $filesystem ?: new Filesystem();
  12169. }
  12170. public function setPreferSource($preferSource)
  12171. {
  12172. $this->preferSource = $preferSource;
  12173. return $this;
  12174. }
  12175. public function setPreferDist($preferDist)
  12176. {
  12177. $this->preferDist = $preferDist;
  12178. return $this;
  12179. }
  12180. public function setPreferences(array $preferences)
  12181. {
  12182. $this->packagePreferences = $preferences;
  12183. return $this;
  12184. }
  12185. public function setDownloader($type, DownloaderInterface $downloader)
  12186. {
  12187. $type = strtolower($type);
  12188. $this->downloaders[$type] = $downloader;
  12189. return $this;
  12190. }
  12191. public function getDownloader($type)
  12192. {
  12193. $type = strtolower($type);
  12194. if (!isset($this->downloaders[$type])) {
  12195. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  12196. }
  12197. return $this->downloaders[$type];
  12198. }
  12199. public function getDownloaderForPackage(PackageInterface $package)
  12200. {
  12201. $installationSource = $package->getInstallationSource();
  12202. if ('metapackage' === $package->getType()) {
  12203. return;
  12204. }
  12205. if ('dist' === $installationSource) {
  12206. $downloader = $this->getDownloader($package->getDistType());
  12207. } elseif ('source' === $installationSource) {
  12208. $downloader = $this->getDownloader($package->getSourceType());
  12209. } else {
  12210. throw new \InvalidArgumentException(
  12211. 'Package '.$package.' does not have an installation source set'
  12212. );
  12213. }
  12214. if ($installationSource !== $downloader->getInstallationSource()) {
  12215. throw new \LogicException(sprintf(
  12216. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  12217. get_class($downloader),
  12218. $downloader->getInstallationSource(),
  12219. $installationSource,
  12220. $package
  12221. ));
  12222. }
  12223. return $downloader;
  12224. }
  12225. public function getDownloaderType(DownloaderInterface $downloader)
  12226. {
  12227. return array_search($downloader, $this->downloaders);
  12228. }
  12229. public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12230. {
  12231. $targetDir = $this->normalizeTargetDir($targetDir);
  12232. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  12233. $sources = $this->getAvailableSources($package, $prevPackage);
  12234. $io = $this->io;
  12235. $self = $this;
  12236. $download = function ($retry = false) use (&$sources, $io, $package, $self, $targetDir, &$download, $prevPackage) {
  12237. $source = array_shift($sources);
  12238. if ($retry) {
  12239. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  12240. }
  12241. $package->setInstallationSource($source);
  12242. $downloader = $self->getDownloaderForPackage($package);
  12243. if (!$downloader) {
  12244. return \React\Promise\resolve();
  12245. }
  12246. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  12247. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  12248. if (!$sources) {
  12249. throw $e;
  12250. }
  12251. $io->writeError(
  12252. ' <warning>Failed to download '.
  12253. $package->getPrettyName().
  12254. ' from ' . $source . ': '.
  12255. $e->getMessage().'</warning>'
  12256. );
  12257. return $download(true);
  12258. }
  12259. throw $e;
  12260. };
  12261. try {
  12262. $result = $downloader->download($package, $targetDir, $prevPackage);
  12263. } catch (\Exception $e) {
  12264. return $handleError($e);
  12265. }
  12266. if (!$result instanceof PromiseInterface) {
  12267. return \React\Promise\resolve($result);
  12268. }
  12269. $res = $result->then(function ($res) {
  12270. return $res;
  12271. }, $handleError);
  12272. return $res;
  12273. };
  12274. return $download();
  12275. }
  12276. public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12277. {
  12278. $targetDir = $this->normalizeTargetDir($targetDir);
  12279. $downloader = $this->getDownloaderForPackage($package);
  12280. if ($downloader) {
  12281. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  12282. }
  12283. }
  12284. public function install(PackageInterface $package, $targetDir)
  12285. {
  12286. $targetDir = $this->normalizeTargetDir($targetDir);
  12287. $downloader = $this->getDownloaderForPackage($package);
  12288. if ($downloader) {
  12289. return $downloader->install($package, $targetDir);
  12290. }
  12291. }
  12292. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  12293. {
  12294. $targetDir = $this->normalizeTargetDir($targetDir);
  12295. $downloader = $this->getDownloaderForPackage($target);
  12296. $initialDownloader = $this->getDownloaderForPackage($initial);
  12297. if (!$initialDownloader && !$downloader) {
  12298. return;
  12299. }
  12300. if (!$downloader) {
  12301. return $initialDownloader->remove($initial, $targetDir);
  12302. }
  12303. $initialType = $this->getDownloaderType($initialDownloader);
  12304. $targetType = $this->getDownloaderType($downloader);
  12305. if ($initialType === $targetType) {
  12306. try {
  12307. return $downloader->update($initial, $target, $targetDir);
  12308. } catch (\RuntimeException $e) {
  12309. if (!$this->io->isInteractive()) {
  12310. throw $e;
  12311. }
  12312. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  12313. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  12314. throw $e;
  12315. }
  12316. }
  12317. }
  12318. $promise = $initialDownloader->remove($initial, $targetDir);
  12319. if ($promise) {
  12320. $self = $this;
  12321. return $promise->then(function ($res) use ($self, $target, $targetDir) {
  12322. return $self->install($target, $targetDir);
  12323. });
  12324. }
  12325. return $this->install($target, $targetDir);
  12326. }
  12327. public function remove(PackageInterface $package, $targetDir)
  12328. {
  12329. $targetDir = $this->normalizeTargetDir($targetDir);
  12330. $downloader = $this->getDownloaderForPackage($package);
  12331. if ($downloader) {
  12332. return $downloader->remove($package, $targetDir);
  12333. }
  12334. }
  12335. public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12336. {
  12337. $targetDir = $this->normalizeTargetDir($targetDir);
  12338. $downloader = $this->getDownloaderForPackage($package);
  12339. if ($downloader) {
  12340. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  12341. }
  12342. }
  12343. protected function resolvePackageInstallPreference(PackageInterface $package)
  12344. {
  12345. foreach ($this->packagePreferences as $pattern => $preference) {
  12346. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  12347. if (preg_match($pattern, $package->getName())) {
  12348. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  12349. return 'dist';
  12350. }
  12351. return 'source';
  12352. }
  12353. }
  12354. return $package->isDev() ? 'source' : 'dist';
  12355. }
  12356. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
  12357. {
  12358. $sourceType = $package->getSourceType();
  12359. $distType = $package->getDistType();
  12360. $sources = array();
  12361. if ($sourceType) {
  12362. $sources[] = 'source';
  12363. }
  12364. if ($distType) {
  12365. $sources[] = 'dist';
  12366. }
  12367. if (empty($sources)) {
  12368. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  12369. }
  12370. if (
  12371. $prevPackage
  12372. && in_array($prevPackage->getInstallationSource(), $sources, true)
  12373. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  12374. ) {
  12375. $prevSource = $prevPackage->getInstallationSource();
  12376. usort($sources, function ($a, $b) use ($prevSource) {
  12377. return $a === $prevSource ? -1 : 1;
  12378. });
  12379. return $sources;
  12380. }
  12381. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  12382. $sources = array_reverse($sources);
  12383. }
  12384. return $sources;
  12385. }
  12386. private function normalizeTargetDir($dir)
  12387. {
  12388. if ($dir === '\\' || $dir === '/') {
  12389. return $dir;
  12390. }
  12391. return rtrim($dir, '\\/');
  12392. }
  12393. }
  12394. <?php
  12395. namespace Composer\Downloader;
  12396. use Composer\Package\PackageInterface;
  12397. use React\Promise\PromiseInterface;
  12398. interface DownloaderInterface
  12399. {
  12400. public function getInstallationSource();
  12401. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12402. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12403. public function install(PackageInterface $package, $path);
  12404. public function update(PackageInterface $initial, PackageInterface $target, $path);
  12405. public function remove(PackageInterface $package, $path);
  12406. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12407. }
  12408. <?php
  12409. namespace Composer\Downloader;
  12410. use Composer\Package\PackageInterface;
  12411. interface DvcsDownloaderInterface
  12412. {
  12413. public function getUnpushedChanges(PackageInterface $package, $path);
  12414. }
  12415. <?php
  12416. namespace Composer\Downloader;
  12417. use Composer\Config;
  12418. use Composer\Cache;
  12419. use Composer\IO\IOInterface;
  12420. use Composer\IO\NullIO;
  12421. use Composer\Exception\IrrecoverableDownloadException;
  12422. use Composer\Package\Comparer\Comparer;
  12423. use Composer\DependencyResolver\Operation\UpdateOperation;
  12424. use Composer\DependencyResolver\Operation\InstallOperation;
  12425. use Composer\DependencyResolver\Operation\UninstallOperation;
  12426. use Composer\Package\PackageInterface;
  12427. use Composer\Plugin\PluginEvents;
  12428. use Composer\Plugin\PostFileDownloadEvent;
  12429. use Composer\Plugin\PreFileDownloadEvent;
  12430. use Composer\EventDispatcher\EventDispatcher;
  12431. use Composer\Util\Filesystem;
  12432. use Composer\Util\Silencer;
  12433. use Composer\Util\HttpDownloader;
  12434. use Composer\Util\Url as UrlUtil;
  12435. use Composer\Util\ProcessExecutor;
  12436. use React\Promise\PromiseInterface;
  12437. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  12438. {
  12439. protected $io;
  12440. protected $config;
  12441. protected $httpDownloader;
  12442. protected $filesystem;
  12443. protected $cache;
  12444. protected $eventDispatcher;
  12445. protected $process;
  12446. public $lastCacheWrites = array();
  12447. private $additionalCleanupPaths = array();
  12448. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  12449. {
  12450. $this->io = $io;
  12451. $this->config = $config;
  12452. $this->eventDispatcher = $eventDispatcher;
  12453. $this->httpDownloader = $httpDownloader;
  12454. $this->cache = $cache;
  12455. $this->process = $process ?: new ProcessExecutor($io);
  12456. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  12457. if ($this->cache && $this->cache->gcIsNecessary()) {
  12458. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  12459. }
  12460. }
  12461. public function getInstallationSource()
  12462. {
  12463. return 'dist';
  12464. }
  12465. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  12466. {
  12467. if (!$package->getDistUrl()) {
  12468. throw new \InvalidArgumentException('The given package is missing url information');
  12469. }
  12470. $cacheKeyGenerator = function (PackageInterface $package, $key) {
  12471. $cacheKey = sha1($key);
  12472. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  12473. };
  12474. $retries = 3;
  12475. $urls = $package->getDistUrls();
  12476. foreach ($urls as $index => $url) {
  12477. $processedUrl = $this->processUrl($package, $url);
  12478. $urls[$index] = array(
  12479. 'base' => $url,
  12480. 'processed' => $processedUrl,
  12481. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  12482. );
  12483. }
  12484. $fileName = $this->getFileName($package, $path);
  12485. $this->filesystem->ensureDirectoryExists($path);
  12486. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  12487. $io = $this->io;
  12488. $cache = $this->cache;
  12489. $httpDownloader = $this->httpDownloader;
  12490. $eventDispatcher = $this->eventDispatcher;
  12491. $filesystem = $this->filesystem;
  12492. $self = $this;
  12493. $accept = null;
  12494. $reject = null;
  12495. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject) {
  12496. $url = reset($urls);
  12497. $index = key($urls);
  12498. if ($eventDispatcher) {
  12499. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  12500. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  12501. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  12502. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  12503. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  12504. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  12505. }
  12506. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  12507. }
  12508. $urls[$index] = $url;
  12509. $checksum = $package->getDistSha1Checksum();
  12510. $cacheKey = $url['cacheKey'];
  12511. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  12512. if ($output) {
  12513. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  12514. }
  12515. $result = \React\Promise\resolve($fileName);
  12516. } else {
  12517. if ($output) {
  12518. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  12519. }
  12520. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  12521. ->then($accept, $reject);
  12522. }
  12523. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher) {
  12524. if (null === $result) {
  12525. return $fileName;
  12526. }
  12527. if (!file_exists($fileName)) {
  12528. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  12529. .' directory is writable and you have internet connectivity');
  12530. }
  12531. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  12532. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  12533. }
  12534. if ($eventDispatcher) {
  12535. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], $package);
  12536. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  12537. }
  12538. return $fileName;
  12539. });
  12540. };
  12541. $accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
  12542. $url = reset($urls);
  12543. $cacheKey = $url['cacheKey'];
  12544. if ($cache && !$cache->isReadOnly()) {
  12545. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  12546. $cache->copyFrom($cacheKey, $fileName);
  12547. }
  12548. $response->collect();
  12549. return $fileName;
  12550. };
  12551. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem, $self) {
  12552. if (file_exists($fileName)) {
  12553. $filesystem->unlink($fileName);
  12554. }
  12555. $self->clearLastCacheWrite($package);
  12556. if ($e instanceof IrrecoverableDownloadException) {
  12557. throw $e;
  12558. }
  12559. if ($e instanceof MaxFileSizeExceededException) {
  12560. throw $e;
  12561. }
  12562. if ($e instanceof TransportException) {
  12563. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  12564. $retries = 0;
  12565. }
  12566. }
  12567. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  12568. $retries = 0;
  12569. $urls = array();
  12570. }
  12571. if ($retries) {
  12572. usleep(500000);
  12573. $retries--;
  12574. return $download();
  12575. }
  12576. array_shift($urls);
  12577. if ($urls) {
  12578. if ($io->isDebug()) {
  12579. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  12580. $io->writeError(' Trying the next URL for '.$package->getName());
  12581. } else {
  12582. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  12583. }
  12584. $retries = 3;
  12585. usleep(100000);
  12586. return $download();
  12587. }
  12588. throw $e;
  12589. };
  12590. return $download();
  12591. }
  12592. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12593. {
  12594. }
  12595. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12596. {
  12597. $fileName = $this->getFileName($package, $path);
  12598. if (file_exists($fileName)) {
  12599. $this->filesystem->unlink($fileName);
  12600. }
  12601. $dirsToCleanUp = array(
  12602. $this->config->get('vendor-dir').'/composer/',
  12603. $this->config->get('vendor-dir'),
  12604. $path,
  12605. );
  12606. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12607. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  12608. $this->filesystem->remove($path);
  12609. }
  12610. }
  12611. foreach ($dirsToCleanUp as $dir) {
  12612. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
  12613. $this->filesystem->removeDirectory($dir);
  12614. }
  12615. }
  12616. }
  12617. public function install(PackageInterface $package, $path, $output = true)
  12618. {
  12619. if ($output) {
  12620. $this->io->writeError(" - " . InstallOperation::format($package));
  12621. }
  12622. $this->filesystem->emptyDirectory($path);
  12623. $this->filesystem->ensureDirectoryExists($path);
  12624. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
  12625. if ($package->getBinaries()) {
  12626. foreach ($package->getBinaries() as $bin) {
  12627. if (file_exists($path . '/' . $bin) && !is_executable($path . '/' . $bin)) {
  12628. Silencer::call('chmod', $path . '/' . $bin, 0777 & ~umask());
  12629. }
  12630. }
  12631. }
  12632. }
  12633. public function clearLastCacheWrite(PackageInterface $package)
  12634. {
  12635. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  12636. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  12637. unset($this->lastCacheWrites[$package->getName()]);
  12638. }
  12639. }
  12640. public function addCleanupPath(PackageInterface $package, $path)
  12641. {
  12642. $this->additionalCleanupPaths[$package->getName()][] = $path;
  12643. }
  12644. public function removeCleanupPath(PackageInterface $package, $path)
  12645. {
  12646. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12647. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  12648. if (false !== $idx) {
  12649. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  12650. }
  12651. }
  12652. }
  12653. public function update(PackageInterface $initial, PackageInterface $target, $path)
  12654. {
  12655. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . ": ", false);
  12656. $promise = $this->remove($initial, $path, false);
  12657. if ($promise === null || !$promise instanceof PromiseInterface) {
  12658. $promise = \React\Promise\resolve();
  12659. }
  12660. $self = $this;
  12661. $io = $this->io;
  12662. return $promise->then(function () use ($self, $target, $path, $io) {
  12663. $promise = $self->install($target, $path, false);
  12664. $io->writeError('');
  12665. return $promise;
  12666. });
  12667. }
  12668. public function remove(PackageInterface $package, $path, $output = true)
  12669. {
  12670. if ($output) {
  12671. $this->io->writeError(" - " . UninstallOperation::format($package));
  12672. }
  12673. if (!$this->filesystem->removeDirectory($path)) {
  12674. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  12675. }
  12676. }
  12677. protected function getFileName(PackageInterface $package, $path)
  12678. {
  12679. 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), '.');
  12680. }
  12681. protected function processUrl(PackageInterface $package, $url)
  12682. {
  12683. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  12684. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  12685. }
  12686. if ($package->getDistReference()) {
  12687. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  12688. }
  12689. return $url;
  12690. }
  12691. public function getLocalChanges(PackageInterface $package, $targetDir)
  12692. {
  12693. $prevIO = $this->io;
  12694. $this->io = new NullIO;
  12695. $this->io->loadConfiguration($this->config);
  12696. $e = null;
  12697. $output = '';
  12698. $targetDir = Filesystem::trimTrailingSlash($targetDir);
  12699. try {
  12700. if (is_dir($targetDir.'_compare')) {
  12701. $this->filesystem->removeDirectory($targetDir.'_compare');
  12702. }
  12703. $this->download($package, $targetDir.'_compare', null, false);
  12704. $this->httpDownloader->wait();
  12705. $this->install($package, $targetDir.'_compare', false);
  12706. $this->process->wait();
  12707. $comparer = new Comparer();
  12708. $comparer->setSource($targetDir.'_compare');
  12709. $comparer->setUpdate($targetDir);
  12710. $comparer->doCompare();
  12711. $output = $comparer->getChanged(true, true);
  12712. $this->filesystem->removeDirectory($targetDir.'_compare');
  12713. } catch (\Exception $e) {
  12714. }
  12715. $this->io = $prevIO;
  12716. if ($e) {
  12717. throw $e;
  12718. }
  12719. return trim($output);
  12720. }
  12721. }
  12722. <?php
  12723. namespace Composer\Downloader;
  12724. class FilesystemException extends \Exception
  12725. {
  12726. public function __construct($message = '', $code = 0, \Exception $previous = null)
  12727. {
  12728. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  12729. }
  12730. }
  12731. <?php
  12732. namespace Composer\Downloader;
  12733. use Composer\Package\PackageInterface;
  12734. use Composer\Util\ProcessExecutor;
  12735. class FossilDownloader extends VcsDownloader
  12736. {
  12737. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12738. {
  12739. }
  12740. protected function doInstall(PackageInterface $package, $path, $url)
  12741. {
  12742. $this->config->prohibitUrlByConfig($url, $this->io);
  12743. $url = ProcessExecutor::escape($url);
  12744. $ref = ProcessExecutor::escape($package->getSourceReference());
  12745. $repoFile = $path . '.fossil';
  12746. $this->io->writeError("Cloning ".$package->getSourceReference());
  12747. $command = sprintf('fossil clone -- %s %s', $url, ProcessExecutor::escape($repoFile));
  12748. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  12749. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12750. }
  12751. $command = sprintf('fossil open --nested -- %s', ProcessExecutor::escape($repoFile));
  12752. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12753. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12754. }
  12755. $command = sprintf('fossil update -- %s', $ref);
  12756. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12757. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12758. }
  12759. }
  12760. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12761. {
  12762. $this->config->prohibitUrlByConfig($url, $this->io);
  12763. $ref = ProcessExecutor::escape($target->getSourceReference());
  12764. $this->io->writeError(" Updating to ".$target->getSourceReference());
  12765. if (!$this->hasMetadataRepository($path)) {
  12766. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12767. }
  12768. $command = sprintf('fossil pull && fossil up %s', $ref);
  12769. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12770. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12771. }
  12772. }
  12773. public function getLocalChanges(PackageInterface $package, $path)
  12774. {
  12775. if (!$this->hasMetadataRepository($path)) {
  12776. return null;
  12777. }
  12778. $this->process->execute('fossil changes', $output, realpath($path));
  12779. return trim($output) ?: null;
  12780. }
  12781. protected function getCommitLogs($fromReference, $toReference, $path)
  12782. {
  12783. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  12784. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  12785. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12786. }
  12787. $log = '';
  12788. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  12789. foreach ($this->process->splitLines($output) as $line) {
  12790. if (preg_match($match, $line)) {
  12791. break;
  12792. }
  12793. $log .= $line;
  12794. }
  12795. return $log;
  12796. }
  12797. protected function hasMetadataRepository($path)
  12798. {
  12799. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  12800. }
  12801. }
  12802. <?php
  12803. namespace Composer\Downloader;
  12804. use Composer\Config;
  12805. use Composer\IO\IOInterface;
  12806. use Composer\Package\PackageInterface;
  12807. use Composer\Util\Filesystem;
  12808. use Composer\Util\Git as GitUtil;
  12809. use Composer\Util\Url;
  12810. use Composer\Util\Platform;
  12811. use Composer\Util\ProcessExecutor;
  12812. use Composer\Cache;
  12813. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  12814. {
  12815. private $hasStashedChanges = array();
  12816. private $hasDiscardedChanges = array();
  12817. private $gitUtil;
  12818. private $cachedPackages = array();
  12819. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  12820. {
  12821. parent::__construct($io, $config, $process, $fs);
  12822. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  12823. }
  12824. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12825. {
  12826. GitUtil::cleanEnv();
  12827. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12828. $gitVersion = GitUtil::getVersion($this->process);
  12829. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  12830. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  12831. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  12832. $ref = $package->getSourceReference();
  12833. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  12834. $this->cachedPackages[$package->getId()][$ref] = true;
  12835. }
  12836. } elseif (null === $gitVersion) {
  12837. throw new \RuntimeException('git was not found in your PATH, skipping source download');
  12838. }
  12839. }
  12840. protected function doInstall(PackageInterface $package, $path, $url)
  12841. {
  12842. GitUtil::cleanEnv();
  12843. $path = $this->normalizePath($path);
  12844. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12845. $ref = $package->getSourceReference();
  12846. $flag = Platform::isWindows() ? '/D ' : '';
  12847. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  12848. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  12849. $command =
  12850. 'git clone --no-checkout %cachePath% %path% --dissociate --reference %cachePath% '
  12851. . '&& cd '.$flag.'%path% '
  12852. . '&& git remote set-url origin -- %sanitizedUrl% && git remote add composer -- %sanitizedUrl%';
  12853. } else {
  12854. $msg = "Cloning ".$this->getShortHash($ref);
  12855. $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%';
  12856. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12857. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  12858. }
  12859. }
  12860. $this->io->writeError($msg);
  12861. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  12862. return str_replace(
  12863. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  12864. array(
  12865. ProcessExecutor::escape($url),
  12866. ProcessExecutor::escape($path),
  12867. ProcessExecutor::escape($cachePath),
  12868. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12869. ),
  12870. $command
  12871. );
  12872. };
  12873. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  12874. if ($url !== $package->getSourceUrl()) {
  12875. $this->updateOriginUrl($path, $package->getSourceUrl());
  12876. } else {
  12877. $this->setPushUrl($path, $url);
  12878. }
  12879. if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
  12880. if ($package->getDistReference() === $package->getSourceReference()) {
  12881. $package->setDistReference($newRef);
  12882. }
  12883. $package->setSourceReference($newRef);
  12884. }
  12885. }
  12886. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12887. {
  12888. GitUtil::cleanEnv();
  12889. $path = $this->normalizePath($path);
  12890. if (!$this->hasMetadataRepository($path)) {
  12891. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12892. }
  12893. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12894. $ref = $target->getSourceReference();
  12895. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  12896. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  12897. $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%';
  12898. } else {
  12899. $msg = "Checking out ".$this->getShortHash($ref);
  12900. $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%';
  12901. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12902. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  12903. }
  12904. }
  12905. $this->io->writeError($msg);
  12906. $commandCallable = function ($url) use ($ref, $command, $cachePath) {
  12907. return str_replace(
  12908. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  12909. array(
  12910. ProcessExecutor::escape($url),
  12911. ProcessExecutor::escape($ref.'^{commit}'),
  12912. ProcessExecutor::escape($cachePath),
  12913. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12914. ),
  12915. $command
  12916. );
  12917. };
  12918. $this->gitUtil->runCommand($commandCallable, $url, $path);
  12919. if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
  12920. if ($target->getDistReference() === $target->getSourceReference()) {
  12921. $target->setDistReference($newRef);
  12922. }
  12923. $target->setSourceReference($newRef);
  12924. }
  12925. $updateOriginUrl = false;
  12926. if (
  12927. 0 === $this->process->execute('git remote -v', $output, $path)
  12928. && preg_match('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  12929. && preg_match('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  12930. ) {
  12931. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  12932. $updateOriginUrl = true;
  12933. }
  12934. }
  12935. if ($updateOriginUrl) {
  12936. $this->updateOriginUrl($path, $target->getSourceUrl());
  12937. }
  12938. }
  12939. public function getLocalChanges(PackageInterface $package, $path)
  12940. {
  12941. GitUtil::cleanEnv();
  12942. if (!$this->hasMetadataRepository($path)) {
  12943. return;
  12944. }
  12945. $command = 'git status --porcelain --untracked-files=no';
  12946. if (0 !== $this->process->execute($command, $output, $path)) {
  12947. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12948. }
  12949. return trim($output) ?: null;
  12950. }
  12951. public function getUnpushedChanges(PackageInterface $package, $path)
  12952. {
  12953. GitUtil::cleanEnv();
  12954. $path = $this->normalizePath($path);
  12955. if (!$this->hasMetadataRepository($path)) {
  12956. return;
  12957. }
  12958. $command = 'git show-ref --head -d';
  12959. if (0 !== $this->process->execute($command, $output, $path)) {
  12960. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12961. }
  12962. $refs = trim($output);
  12963. if (!preg_match('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  12964. return;
  12965. }
  12966. $headRef = $match[1];
  12967. if (!preg_match_all('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  12968. return;
  12969. }
  12970. $candidateBranches = $matches[1];
  12971. $branch = $candidateBranches[0];
  12972. $unpushedChanges = null;
  12973. $branchNotFoundError = false;
  12974. for ($i = 0; $i <= 1; $i++) {
  12975. $remoteBranches = array();
  12976. foreach ($candidateBranches as $candidate) {
  12977. if (preg_match_all('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  12978. foreach ($matches[1] as $match) {
  12979. $branch = $candidate;
  12980. $remoteBranches[] = $match;
  12981. }
  12982. break;
  12983. }
  12984. }
  12985. if (!$remoteBranches) {
  12986. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  12987. $branchNotFoundError = true;
  12988. } else {
  12989. if ($branchNotFoundError) {
  12990. $unpushedChanges = null;
  12991. }
  12992. foreach ($remoteBranches as $remoteBranch) {
  12993. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  12994. if (0 !== $this->process->execute($command, $output, $path)) {
  12995. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12996. }
  12997. $output = trim($output);
  12998. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  12999. $unpushedChanges = $output;
  13000. }
  13001. }
  13002. }
  13003. if ($unpushedChanges && $i === 0) {
  13004. $this->process->execute('git fetch --all', $output, $path);
  13005. $command = 'git show-ref --head -d';
  13006. if (0 !== $this->process->execute($command, $output, $path)) {
  13007. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13008. }
  13009. $refs = trim($output);
  13010. }
  13011. if (!$unpushedChanges) {
  13012. break;
  13013. }
  13014. }
  13015. return $unpushedChanges;
  13016. }
  13017. protected function cleanChanges(PackageInterface $package, $path, $update)
  13018. {
  13019. GitUtil::cleanEnv();
  13020. $path = $this->normalizePath($path);
  13021. $unpushed = $this->getUnpushedChanges($package, $path);
  13022. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  13023. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  13024. }
  13025. if (!$changes = $this->getLocalChanges($package, $path)) {
  13026. return;
  13027. }
  13028. if (!$this->io->isInteractive()) {
  13029. $discardChanges = $this->config->get('discard-changes');
  13030. if (true === $discardChanges) {
  13031. return $this->discardChanges($path);
  13032. }
  13033. if ('stash' === $discardChanges) {
  13034. if (!$update) {
  13035. return parent::cleanChanges($package, $path, $update);
  13036. }
  13037. return $this->stashChanges($path);
  13038. }
  13039. return parent::cleanChanges($package, $path, $update);
  13040. }
  13041. $changes = array_map(function ($elem) {
  13042. return ' '.$elem;
  13043. }, preg_split('{\s*\r?\n\s*}', $changes));
  13044. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  13045. $this->io->writeError(array_slice($changes, 0, 10));
  13046. if (count($changes) > 10) {
  13047. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  13048. }
  13049. while (true) {
  13050. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  13051. case 'y':
  13052. $this->discardChanges($path);
  13053. break 2;
  13054. case 's':
  13055. if (!$update) {
  13056. goto help;
  13057. }
  13058. $this->stashChanges($path);
  13059. break 2;
  13060. case 'n':
  13061. throw new \RuntimeException('Update aborted');
  13062. case 'v':
  13063. $this->io->writeError($changes);
  13064. break;
  13065. case 'd':
  13066. $this->viewDiff($path);
  13067. break;
  13068. case '?':
  13069. default:
  13070. help:
  13071. $this->io->writeError(array(
  13072. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13073. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13074. ' v - view modified files',
  13075. ' d - view local modifications (diff)',
  13076. ));
  13077. if ($update) {
  13078. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  13079. }
  13080. $this->io->writeError(' ? - print help');
  13081. break;
  13082. }
  13083. }
  13084. }
  13085. protected function reapplyChanges($path)
  13086. {
  13087. $path = $this->normalizePath($path);
  13088. if (!empty($this->hasStashedChanges[$path])) {
  13089. unset($this->hasStashedChanges[$path]);
  13090. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  13091. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  13092. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  13093. }
  13094. }
  13095. unset($this->hasDiscardedChanges[$path]);
  13096. }
  13097. protected function updateToCommit($path, $reference, $branch, $date)
  13098. {
  13099. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  13100. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  13101. $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
  13102. $branches = null;
  13103. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  13104. $branches = $output;
  13105. }
  13106. $gitRef = $reference;
  13107. if (!preg_match('{^[a-f0-9]{40}$}', $reference)
  13108. && $branches
  13109. && preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  13110. ) {
  13111. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  13112. if (0 === $this->process->execute($command, $output, $path)) {
  13113. return null;
  13114. }
  13115. }
  13116. if (preg_match('{^[a-f0-9]{40}$}', $reference)) {
  13117. if (!preg_match('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && preg_match('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  13118. $branch = 'v' . $branch;
  13119. }
  13120. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  13121. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  13122. $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  13123. if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
  13124. return null;
  13125. }
  13126. }
  13127. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  13128. if (0 === $this->process->execute($command, $output, $path)) {
  13129. return null;
  13130. }
  13131. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  13132. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  13133. }
  13134. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
  13135. }
  13136. protected function updateOriginUrl($path, $url)
  13137. {
  13138. $this->process->execute(sprintf('git remote set-url origin -- %s', ProcessExecutor::escape($url)), $output, $path);
  13139. $this->setPushUrl($path, $url);
  13140. }
  13141. protected function setPushUrl($path, $url)
  13142. {
  13143. if (preg_match('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  13144. $protocols = $this->config->get('github-protocols');
  13145. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  13146. if (!in_array('ssh', $protocols, true)) {
  13147. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  13148. }
  13149. $cmd = sprintf('git remote set-url --push origin -- %s', ProcessExecutor::escape($pushUrl));
  13150. $this->process->execute($cmd, $ignoredOutput, $path);
  13151. }
  13152. }
  13153. protected function getCommitLogs($fromReference, $toReference, $path)
  13154. {
  13155. $path = $this->normalizePath($path);
  13156. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13157. if (0 !== $this->process->execute($command, $output, $path)) {
  13158. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13159. }
  13160. return $output;
  13161. }
  13162. protected function discardChanges($path)
  13163. {
  13164. $path = $this->normalizePath($path);
  13165. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  13166. throw new \RuntimeException("Could not reset changes\n\n:".$output);
  13167. }
  13168. $this->hasDiscardedChanges[$path] = true;
  13169. }
  13170. protected function stashChanges($path)
  13171. {
  13172. $path = $this->normalizePath($path);
  13173. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  13174. throw new \RuntimeException("Could not stash changes\n\n:".$output);
  13175. }
  13176. $this->hasStashedChanges[$path] = true;
  13177. }
  13178. protected function viewDiff($path)
  13179. {
  13180. $path = $this->normalizePath($path);
  13181. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  13182. throw new \RuntimeException("Could not view diff\n\n:".$output);
  13183. }
  13184. $this->io->writeError($output);
  13185. }
  13186. protected function normalizePath($path)
  13187. {
  13188. if (Platform::isWindows() && strlen($path) > 0) {
  13189. $basePath = $path;
  13190. $removed = array();
  13191. while (!is_dir($basePath) && $basePath !== '\\') {
  13192. array_unshift($removed, basename($basePath));
  13193. $basePath = dirname($basePath);
  13194. }
  13195. if ($basePath === '\\') {
  13196. return $path;
  13197. }
  13198. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  13199. }
  13200. return $path;
  13201. }
  13202. protected function hasMetadataRepository($path)
  13203. {
  13204. $path = $this->normalizePath($path);
  13205. return is_dir($path.'/.git');
  13206. }
  13207. protected function getShortHash($reference)
  13208. {
  13209. if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {
  13210. return substr($reference, 0, 10);
  13211. }
  13212. return $reference;
  13213. }
  13214. }
  13215. <?php
  13216. namespace Composer\Downloader;
  13217. use Composer\Package\PackageInterface;
  13218. use Composer\Util\Platform;
  13219. use Composer\Util\ProcessExecutor;
  13220. class GzipDownloader extends ArchiveDownloader
  13221. {
  13222. protected function extract(PackageInterface $package, $file, $path)
  13223. {
  13224. $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
  13225. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  13226. if (!Platform::isWindows()) {
  13227. $command = 'gzip -cd -- ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  13228. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13229. return;
  13230. }
  13231. if (extension_loaded('zlib')) {
  13232. $this->extractUsingExt($file, $targetFilepath);
  13233. return;
  13234. }
  13235. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13236. throw new \RuntimeException($processError);
  13237. }
  13238. $this->extractUsingExt($file, $targetFilepath);
  13239. }
  13240. private function extractUsingExt($file, $targetFilepath)
  13241. {
  13242. $archiveFile = gzopen($file, 'rb');
  13243. $targetFile = fopen($targetFilepath, 'wb');
  13244. while ($string = gzread($archiveFile, 4096)) {
  13245. fwrite($targetFile, $string, Platform::strlen($string));
  13246. }
  13247. gzclose($archiveFile);
  13248. fclose($targetFile);
  13249. }
  13250. }
  13251. <?php
  13252. namespace Composer\Downloader;
  13253. use Composer\Package\PackageInterface;
  13254. use Composer\Util\ProcessExecutor;
  13255. use Composer\Util\Hg as HgUtils;
  13256. class HgDownloader extends VcsDownloader
  13257. {
  13258. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13259. {
  13260. if (null === HgUtils::getVersion($this->process)) {
  13261. throw new \RuntimeException('hg was not found in your PATH, skipping source download');
  13262. }
  13263. }
  13264. protected function doInstall(PackageInterface $package, $path, $url)
  13265. {
  13266. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13267. $cloneCommand = function ($url) use ($path) {
  13268. return sprintf('hg clone -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  13269. };
  13270. $hgUtils->runCommand($cloneCommand, $url, $path);
  13271. $ref = ProcessExecutor::escape($package->getSourceReference());
  13272. $command = sprintf('hg up -- %s', $ref);
  13273. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13274. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13275. }
  13276. }
  13277. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13278. {
  13279. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13280. $ref = $target->getSourceReference();
  13281. $this->io->writeError(" Updating to ".$target->getSourceReference());
  13282. if (!$this->hasMetadataRepository($path)) {
  13283. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13284. }
  13285. $command = function ($url) use ($ref) {
  13286. return sprintf('hg pull -- %s && hg up -- %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  13287. };
  13288. $hgUtils->runCommand($command, $url, $path);
  13289. }
  13290. public function getLocalChanges(PackageInterface $package, $path)
  13291. {
  13292. if (!is_dir($path.'/.hg')) {
  13293. return null;
  13294. }
  13295. $this->process->execute('hg st', $output, realpath($path));
  13296. return trim($output) ?: null;
  13297. }
  13298. protected function getCommitLogs($fromReference, $toReference, $path)
  13299. {
  13300. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13301. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  13302. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13303. }
  13304. return $output;
  13305. }
  13306. protected function hasMetadataRepository($path)
  13307. {
  13308. return is_dir($path . '/.hg');
  13309. }
  13310. }
  13311. <?php
  13312. namespace Composer\Downloader;
  13313. class MaxFileSizeExceededException extends TransportException
  13314. {
  13315. }
  13316. <?php
  13317. namespace Composer\Downloader;
  13318. use Composer\Package\Archiver\ArchivableFilesFinder;
  13319. use Composer\Package\Dumper\ArrayDumper;
  13320. use Composer\Package\PackageInterface;
  13321. use Composer\Package\Version\VersionGuesser;
  13322. use Composer\Package\Version\VersionParser;
  13323. use Composer\Util\Platform;
  13324. use Composer\Util\Filesystem;
  13325. use Symfony\Component\Filesystem\Exception\IOException;
  13326. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  13327. use Composer\DependencyResolver\Operation\InstallOperation;
  13328. use Composer\DependencyResolver\Operation\UninstallOperation;
  13329. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  13330. {
  13331. const STRATEGY_SYMLINK = 10;
  13332. const STRATEGY_MIRROR = 20;
  13333. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13334. {
  13335. $path = Filesystem::trimTrailingSlash($path);
  13336. $url = $package->getDistUrl();
  13337. $realUrl = realpath($url);
  13338. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  13339. throw new \RuntimeException(sprintf(
  13340. 'Source path "%s" is not found for package %s',
  13341. $url,
  13342. $package->getName()
  13343. ));
  13344. }
  13345. if (realpath($path) === $realUrl) {
  13346. return;
  13347. }
  13348. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  13349. throw new \RuntimeException(sprintf(
  13350. 'Package %s cannot install to "%s" inside its source at "%s"',
  13351. $package->getName(),
  13352. realpath($path),
  13353. $realUrl
  13354. ));
  13355. }
  13356. }
  13357. public function install(PackageInterface $package, $path, $output = true)
  13358. {
  13359. $path = Filesystem::trimTrailingSlash($path);
  13360. $url = $package->getDistUrl();
  13361. $realUrl = realpath($url);
  13362. if (realpath($path) === $realUrl) {
  13363. if ($output) {
  13364. $this->io->writeError(" - " . InstallOperation::format($package).': Source already present');
  13365. } else {
  13366. $this->io->writeError('Source already present', false);
  13367. }
  13368. return;
  13369. }
  13370. $transportOptions = $package->getTransportOptions() + array('symlink' => null, 'relative' => true);
  13371. $currentStrategy = self::STRATEGY_SYMLINK;
  13372. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  13373. $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS');
  13374. if ($mirrorPathRepos) {
  13375. $currentStrategy = self::STRATEGY_MIRROR;
  13376. }
  13377. if (true === $transportOptions['symlink']) {
  13378. $currentStrategy = self::STRATEGY_SYMLINK;
  13379. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  13380. } elseif (false === $transportOptions['symlink']) {
  13381. $currentStrategy = self::STRATEGY_MIRROR;
  13382. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13383. }
  13384. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  13385. $currentStrategy = self::STRATEGY_MIRROR;
  13386. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13387. }
  13388. $symfonyFilesystem = new SymfonyFilesystem();
  13389. $this->filesystem->removeDirectory($path);
  13390. if ($output) {
  13391. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13392. }
  13393. $isFallback = false;
  13394. if (self::STRATEGY_SYMLINK == $currentStrategy) {
  13395. try {
  13396. if (Platform::isWindows()) {
  13397. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  13398. $this->filesystem->junction($realUrl, $path);
  13399. } else {
  13400. $absolutePath = $path;
  13401. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  13402. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  13403. }
  13404. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  13405. $path = rtrim($path, "/");
  13406. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  13407. if ($transportOptions['relative']) {
  13408. $symfonyFilesystem->symlink($shortestPath, $path);
  13409. } else {
  13410. $symfonyFilesystem->symlink($realUrl, $path);
  13411. }
  13412. }
  13413. } catch (IOException $e) {
  13414. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
  13415. $this->io->writeError('');
  13416. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  13417. $currentStrategy = self::STRATEGY_MIRROR;
  13418. $isFallback = true;
  13419. } else {
  13420. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  13421. }
  13422. }
  13423. }
  13424. if (self::STRATEGY_MIRROR == $currentStrategy) {
  13425. $realUrl = $this->filesystem->normalizePath($realUrl);
  13426. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  13427. $iterator = new ArchivableFilesFinder($realUrl, array());
  13428. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  13429. }
  13430. if ($output) {
  13431. $this->io->writeError('');
  13432. }
  13433. }
  13434. public function remove(PackageInterface $package, $path, $output = true)
  13435. {
  13436. $path = Filesystem::trimTrailingSlash($path);
  13437. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  13438. if ($output) {
  13439. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13440. }
  13441. if (!$this->filesystem->removeJunction($path)) {
  13442. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  13443. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  13444. }
  13445. } elseif (realpath($path) === realpath($package->getDistUrl())) {
  13446. if ($output) {
  13447. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13448. }
  13449. } else {
  13450. parent::remove($package, $path, $output);
  13451. }
  13452. }
  13453. public function getVcsReference(PackageInterface $package, $path)
  13454. {
  13455. $path = Filesystem::trimTrailingSlash($path);
  13456. $parser = new VersionParser;
  13457. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13458. $dumper = new ArrayDumper;
  13459. $packageConfig = $dumper->dump($package);
  13460. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13461. return $packageVersion['commit'];
  13462. }
  13463. }
  13464. private function safeJunctions()
  13465. {
  13466. return function_exists('proc_open') &&
  13467. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  13468. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  13469. }
  13470. }
  13471. <?php
  13472. namespace Composer\Downloader;
  13473. use Composer\Package\PackageInterface;
  13474. use Composer\Repository\VcsRepository;
  13475. use Composer\Util\Perforce;
  13476. class PerforceDownloader extends VcsDownloader
  13477. {
  13478. protected $perforce;
  13479. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13480. {
  13481. }
  13482. public function doInstall(PackageInterface $package, $path, $url)
  13483. {
  13484. $ref = $package->getSourceReference();
  13485. $label = $this->getLabelFromSourceReference($ref);
  13486. $this->io->writeError('Cloning ' . $ref);
  13487. $this->initPerforce($package, $path, $url);
  13488. $this->perforce->setStream($ref);
  13489. $this->perforce->p4Login();
  13490. $this->perforce->writeP4ClientSpec();
  13491. $this->perforce->connectClient();
  13492. $this->perforce->syncCodeBase($label);
  13493. $this->perforce->cleanupClientSpec();
  13494. }
  13495. private function getLabelFromSourceReference($ref)
  13496. {
  13497. $pos = strpos($ref, '@');
  13498. if (false !== $pos) {
  13499. return substr($ref, $pos + 1);
  13500. }
  13501. return null;
  13502. }
  13503. public function initPerforce(PackageInterface $package, $path, $url)
  13504. {
  13505. if (!empty($this->perforce)) {
  13506. $this->perforce->initializePath($path);
  13507. return;
  13508. }
  13509. $repository = $package->getRepository();
  13510. $repoConfig = null;
  13511. if ($repository instanceof VcsRepository) {
  13512. $repoConfig = $this->getRepoConfig($repository);
  13513. }
  13514. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  13515. }
  13516. private function getRepoConfig(VcsRepository $repository)
  13517. {
  13518. return $repository->getRepoConfig();
  13519. }
  13520. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13521. {
  13522. $this->doInstall($target, $path, $url);
  13523. }
  13524. public function getLocalChanges(PackageInterface $package, $path)
  13525. {
  13526. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  13527. }
  13528. protected function getCommitLogs($fromReference, $toReference, $path)
  13529. {
  13530. return $this->perforce->getCommitLogs($fromReference, $toReference);
  13531. }
  13532. public function setPerforce($perforce)
  13533. {
  13534. $this->perforce = $perforce;
  13535. }
  13536. protected function hasMetadataRepository($path)
  13537. {
  13538. return true;
  13539. }
  13540. }
  13541. <?php
  13542. namespace Composer\Downloader;
  13543. use Composer\Package\PackageInterface;
  13544. class PharDownloader extends ArchiveDownloader
  13545. {
  13546. protected function extract(PackageInterface $package, $file, $path)
  13547. {
  13548. $archive = new \Phar($file);
  13549. $archive->extractTo($path, null, true);
  13550. }
  13551. }
  13552. <?php
  13553. namespace Composer\Downloader;
  13554. use Composer\Util\IniHelper;
  13555. use Composer\Util\Platform;
  13556. use Composer\Util\ProcessExecutor;
  13557. use Composer\Package\PackageInterface;
  13558. use RarArchive;
  13559. class RarDownloader extends ArchiveDownloader
  13560. {
  13561. protected function extract(PackageInterface $package, $file, $path)
  13562. {
  13563. $processError = null;
  13564. if (!Platform::isWindows()) {
  13565. $command = 'unrar x -- ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  13566. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13567. return;
  13568. }
  13569. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13570. }
  13571. if (!class_exists('RarArchive')) {
  13572. $iniMessage = IniHelper::getMessage();
  13573. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  13574. . $iniMessage . "\n" . $processError;
  13575. if (!Platform::isWindows()) {
  13576. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  13577. }
  13578. throw new \RuntimeException($error);
  13579. }
  13580. $rarArchive = RarArchive::open($file);
  13581. if (false === $rarArchive) {
  13582. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  13583. }
  13584. $entries = $rarArchive->getEntries();
  13585. if (false === $entries) {
  13586. throw new \RuntimeException('Could not retrieve RAR archive entries');
  13587. }
  13588. foreach ($entries as $entry) {
  13589. if (false === $entry->extract($path)) {
  13590. throw new \RuntimeException('Could not extract entry');
  13591. }
  13592. }
  13593. $rarArchive->close();
  13594. }
  13595. }
  13596. <?php
  13597. namespace Composer\Downloader;
  13598. use Composer\Package\PackageInterface;
  13599. use Composer\Util\Svn as SvnUtil;
  13600. use Composer\Repository\VcsRepository;
  13601. use Composer\Util\ProcessExecutor;
  13602. class SvnDownloader extends VcsDownloader
  13603. {
  13604. protected $cacheCredentials = true;
  13605. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13606. {
  13607. SvnUtil::cleanEnv();
  13608. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  13609. if (null === $util->binaryVersion()) {
  13610. throw new \RuntimeException('svn was not found in your PATH, skipping source download');
  13611. }
  13612. }
  13613. protected function doInstall(PackageInterface $package, $path, $url)
  13614. {
  13615. SvnUtil::cleanEnv();
  13616. $ref = $package->getSourceReference();
  13617. $repo = $package->getRepository();
  13618. if ($repo instanceof VcsRepository) {
  13619. $repoConfig = $repo->getRepoConfig();
  13620. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  13621. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  13622. }
  13623. }
  13624. $this->io->writeError(" Checking out ".$package->getSourceReference());
  13625. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  13626. }
  13627. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13628. {
  13629. SvnUtil::cleanEnv();
  13630. $ref = $target->getSourceReference();
  13631. if (!$this->hasMetadataRepository($path)) {
  13632. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13633. }
  13634. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  13635. $flags = "";
  13636. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  13637. $flags .= ' --ignore-ancestry';
  13638. }
  13639. $this->io->writeError(" Checking out " . $ref);
  13640. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  13641. }
  13642. public function getLocalChanges(PackageInterface $package, $path)
  13643. {
  13644. if (!$this->hasMetadataRepository($path)) {
  13645. return null;
  13646. }
  13647. $this->process->execute('svn status --ignore-externals', $output, $path);
  13648. return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
  13649. }
  13650. protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
  13651. {
  13652. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13653. $util->setCacheCredentials($this->cacheCredentials);
  13654. try {
  13655. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  13656. } catch (\RuntimeException $e) {
  13657. throw new \RuntimeException(
  13658. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  13659. );
  13660. }
  13661. }
  13662. protected function cleanChanges(PackageInterface $package, $path, $update)
  13663. {
  13664. if (!$changes = $this->getLocalChanges($package, $path)) {
  13665. return;
  13666. }
  13667. if (!$this->io->isInteractive()) {
  13668. if (true === $this->config->get('discard-changes')) {
  13669. return $this->discardChanges($path);
  13670. }
  13671. return parent::cleanChanges($package, $path, $update);
  13672. }
  13673. $changes = array_map(function ($elem) {
  13674. return ' '.$elem;
  13675. }, preg_split('{\s*\r?\n\s*}', $changes));
  13676. $countChanges = count($changes);
  13677. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  13678. $this->io->writeError(array_slice($changes, 0, 10));
  13679. if ($countChanges > 10) {
  13680. $remainingChanges = $countChanges - 10;
  13681. $this->io->writeError(
  13682. sprintf(
  13683. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  13684. $remainingChanges === 1 ? '' : 's'
  13685. )
  13686. );
  13687. }
  13688. while (true) {
  13689. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  13690. case 'y':
  13691. $this->discardChanges($path);
  13692. break 2;
  13693. case 'n':
  13694. throw new \RuntimeException('Update aborted');
  13695. case 'v':
  13696. $this->io->writeError($changes);
  13697. break;
  13698. case '?':
  13699. default:
  13700. $this->io->writeError(array(
  13701. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13702. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13703. ' v - view modified files',
  13704. ' ? - print help',
  13705. ));
  13706. break;
  13707. }
  13708. }
  13709. }
  13710. protected function getCommitLogs($fromReference, $toReference, $path)
  13711. {
  13712. if (preg_match('{@(\d+)$}', $fromReference) && preg_match('{@(\d+)$}', $toReference)) {
  13713. $command = sprintf('svn info --non-interactive --xml -- %s', ProcessExecutor::escape($path));
  13714. if (0 !== $this->process->execute($command, $output, $path)) {
  13715. throw new \RuntimeException(
  13716. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  13717. );
  13718. }
  13719. $urlPattern = '#<url>(.*)</url>#';
  13720. if (preg_match($urlPattern, $output, $matches)) {
  13721. $baseUrl = $matches[1];
  13722. } else {
  13723. throw new \RuntimeException(
  13724. 'Unable to determine svn url for path '. $path
  13725. );
  13726. }
  13727. $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
  13728. $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
  13729. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  13730. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13731. $util->setCacheCredentials($this->cacheCredentials);
  13732. try {
  13733. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  13734. } catch (\RuntimeException $e) {
  13735. throw new \RuntimeException(
  13736. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  13737. );
  13738. }
  13739. }
  13740. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  13741. }
  13742. protected function discardChanges($path)
  13743. {
  13744. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  13745. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  13746. }
  13747. }
  13748. protected function hasMetadataRepository($path)
  13749. {
  13750. return is_dir($path.'/.svn');
  13751. }
  13752. }
  13753. <?php
  13754. namespace Composer\Downloader;
  13755. use Composer\Package\PackageInterface;
  13756. class TarDownloader extends ArchiveDownloader
  13757. {
  13758. protected function extract(PackageInterface $package, $file, $path)
  13759. {
  13760. $archive = new \PharData($file);
  13761. $archive->extractTo($path, null, true);
  13762. }
  13763. }
  13764. <?php
  13765. namespace Composer\Downloader;
  13766. class TransportException extends \RuntimeException
  13767. {
  13768. protected $headers;
  13769. protected $response;
  13770. protected $statusCode;
  13771. protected $responseInfo = array();
  13772. public function setHeaders($headers)
  13773. {
  13774. $this->headers = $headers;
  13775. }
  13776. public function getHeaders()
  13777. {
  13778. return $this->headers;
  13779. }
  13780. public function setResponse($response)
  13781. {
  13782. $this->response = $response;
  13783. }
  13784. public function getResponse()
  13785. {
  13786. return $this->response;
  13787. }
  13788. public function setStatusCode($statusCode)
  13789. {
  13790. $this->statusCode = $statusCode;
  13791. }
  13792. public function getStatusCode()
  13793. {
  13794. return $this->statusCode;
  13795. }
  13796. public function getResponseInfo()
  13797. {
  13798. return $this->responseInfo;
  13799. }
  13800. public function setResponseInfo(array $responseInfo)
  13801. {
  13802. $this->responseInfo = $responseInfo;
  13803. }
  13804. }
  13805. <?php
  13806. namespace Composer\Downloader;
  13807. use Composer\Package\PackageInterface;
  13808. interface VcsCapableDownloaderInterface
  13809. {
  13810. public function getVcsReference(PackageInterface $package, $path);
  13811. }
  13812. <?php
  13813. namespace Composer\Downloader;
  13814. use Composer\Config;
  13815. use Composer\Package\Dumper\ArrayDumper;
  13816. use Composer\Package\PackageInterface;
  13817. use Composer\Package\Version\VersionGuesser;
  13818. use Composer\Package\Version\VersionParser;
  13819. use Composer\Util\ProcessExecutor;
  13820. use Composer\IO\IOInterface;
  13821. use Composer\Util\Filesystem;
  13822. use React\Promise\PromiseInterface;
  13823. use Composer\DependencyResolver\Operation\UpdateOperation;
  13824. use Composer\DependencyResolver\Operation\InstallOperation;
  13825. use Composer\DependencyResolver\Operation\UninstallOperation;
  13826. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  13827. {
  13828. protected $io;
  13829. protected $config;
  13830. protected $process;
  13831. protected $filesystem;
  13832. protected $hasCleanedChanges = array();
  13833. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  13834. {
  13835. $this->io = $io;
  13836. $this->config = $config;
  13837. $this->process = $process ?: new ProcessExecutor($io);
  13838. $this->filesystem = $fs ?: new Filesystem($this->process);
  13839. }
  13840. public function getInstallationSource()
  13841. {
  13842. return 'source';
  13843. }
  13844. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13845. {
  13846. if (!$package->getSourceReference()) {
  13847. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13848. }
  13849. $urls = $this->prepareUrls($package->getSourceUrls());
  13850. while ($url = array_shift($urls)) {
  13851. try {
  13852. return $this->doDownload($package, $path, $url, $prevPackage);
  13853. } catch (\Exception $e) {
  13854. if ($e instanceof \PHPUnit\Framework\Exception) {
  13855. throw $e;
  13856. }
  13857. if ($this->io->isDebug()) {
  13858. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13859. } elseif (count($urls)) {
  13860. $this->io->writeError(' Failed, trying the next URL');
  13861. }
  13862. if (!count($urls)) {
  13863. throw $e;
  13864. }
  13865. }
  13866. }
  13867. }
  13868. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13869. {
  13870. if ($type === 'update') {
  13871. $this->cleanChanges($prevPackage, $path, true);
  13872. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  13873. } elseif ($type === 'install') {
  13874. $this->filesystem->emptyDirectory($path);
  13875. } elseif ($type === 'uninstall') {
  13876. $this->cleanChanges($package, $path, false);
  13877. }
  13878. }
  13879. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13880. {
  13881. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  13882. $this->reapplyChanges($path);
  13883. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  13884. }
  13885. }
  13886. public function install(PackageInterface $package, $path)
  13887. {
  13888. if (!$package->getSourceReference()) {
  13889. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13890. }
  13891. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13892. $urls = $this->prepareUrls($package->getSourceUrls());
  13893. while ($url = array_shift($urls)) {
  13894. try {
  13895. $this->doInstall($package, $path, $url);
  13896. break;
  13897. } catch (\Exception $e) {
  13898. if ($e instanceof \PHPUnit\Framework\Exception) {
  13899. throw $e;
  13900. }
  13901. if ($this->io->isDebug()) {
  13902. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13903. } elseif (count($urls)) {
  13904. $this->io->writeError(' Failed, trying the next URL');
  13905. }
  13906. if (!count($urls)) {
  13907. throw $e;
  13908. }
  13909. }
  13910. }
  13911. }
  13912. public function update(PackageInterface $initial, PackageInterface $target, $path)
  13913. {
  13914. if (!$target->getSourceReference()) {
  13915. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  13916. }
  13917. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  13918. $urls = $this->prepareUrls($target->getSourceUrls());
  13919. $exception = null;
  13920. while ($url = array_shift($urls)) {
  13921. try {
  13922. $this->doUpdate($initial, $target, $path, $url);
  13923. $exception = null;
  13924. break;
  13925. } catch (\Exception $exception) {
  13926. if ($exception instanceof \PHPUnit\Framework\Exception) {
  13927. throw $exception;
  13928. }
  13929. if ($this->io->isDebug()) {
  13930. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  13931. } elseif (count($urls)) {
  13932. $this->io->writeError(' Failed, trying the next URL');
  13933. }
  13934. }
  13935. }
  13936. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  13937. $message = 'Pulling in changes:';
  13938. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  13939. if (!trim($logs)) {
  13940. $message = 'Rolling back changes:';
  13941. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  13942. }
  13943. if (trim($logs)) {
  13944. $logs = implode("\n", array_map(function ($line) {
  13945. return ' ' . $line;
  13946. }, explode("\n", $logs)));
  13947. $logs = str_replace('<', '\<', $logs);
  13948. $this->io->writeError(' '.$message);
  13949. $this->io->writeError($logs);
  13950. }
  13951. }
  13952. if (!$urls && $exception) {
  13953. throw $exception;
  13954. }
  13955. }
  13956. public function remove(PackageInterface $package, $path)
  13957. {
  13958. $this->io->writeError(" - " . UninstallOperation::format($package));
  13959. if (!$this->filesystem->removeDirectory($path)) {
  13960. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  13961. }
  13962. }
  13963. public function getVcsReference(PackageInterface $package, $path)
  13964. {
  13965. $parser = new VersionParser;
  13966. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13967. $dumper = new ArrayDumper;
  13968. $packageConfig = $dumper->dump($package);
  13969. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13970. return $packageVersion['commit'];
  13971. }
  13972. }
  13973. protected function cleanChanges(PackageInterface $package, $path, $update)
  13974. {
  13975. if (null !== $this->getLocalChanges($package, $path)) {
  13976. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  13977. }
  13978. }
  13979. protected function reapplyChanges($path)
  13980. {
  13981. }
  13982. abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
  13983. abstract protected function doInstall(PackageInterface $package, $path, $url);
  13984. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  13985. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  13986. abstract protected function hasMetadataRepository($path);
  13987. private function prepareUrls(array $urls)
  13988. {
  13989. foreach ($urls as $index => $url) {
  13990. if (Filesystem::isLocalPath($url)) {
  13991. $fileProtocol = 'file://';
  13992. $isFileProtocol = false;
  13993. if (0 === strpos($url, $fileProtocol)) {
  13994. $url = substr($url, strlen($fileProtocol));
  13995. $isFileProtocol = true;
  13996. }
  13997. if (false !== strpos($url, '%')) {
  13998. $url = rawurldecode($url);
  13999. }
  14000. $urls[$index] = realpath($url);
  14001. if ($isFileProtocol) {
  14002. $urls[$index] = $fileProtocol . $urls[$index];
  14003. }
  14004. }
  14005. }
  14006. return $urls;
  14007. }
  14008. }
  14009. <?php
  14010. namespace Composer\Downloader;
  14011. use Composer\Package\PackageInterface;
  14012. use Composer\Util\ProcessExecutor;
  14013. class XzDownloader extends ArchiveDownloader
  14014. {
  14015. protected function extract(PackageInterface $package, $file, $path)
  14016. {
  14017. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  14018. if (0 === $this->process->execute($command, $ignoredOutput)) {
  14019. return;
  14020. }
  14021. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  14022. throw new \RuntimeException($processError);
  14023. }
  14024. }
  14025. <?php
  14026. namespace Composer\Downloader;
  14027. use Composer\Package\PackageInterface;
  14028. use Composer\Util\IniHelper;
  14029. use Composer\Util\Platform;
  14030. use Composer\Util\ProcessExecutor;
  14031. use Symfony\Component\Process\ExecutableFinder;
  14032. use ZipArchive;
  14033. class ZipDownloader extends ArchiveDownloader
  14034. {
  14035. protected static $hasSystemUnzip;
  14036. private static $hasZipArchive;
  14037. private static $isWindows;
  14038. private $zipArchiveObject;
  14039. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  14040. {
  14041. if (null === self::$hasSystemUnzip) {
  14042. $finder = new ExecutableFinder;
  14043. self::$hasSystemUnzip = (bool) $finder->find('unzip');
  14044. }
  14045. if (null === self::$hasZipArchive) {
  14046. self::$hasZipArchive = class_exists('ZipArchive');
  14047. }
  14048. if (!self::$hasZipArchive && !self::$hasSystemUnzip) {
  14049. $iniMessage = IniHelper::getMessage();
  14050. $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
  14051. throw new \RuntimeException($error);
  14052. }
  14053. if (null === self::$isWindows) {
  14054. self::$isWindows = Platform::isWindows();
  14055. if (!self::$isWindows && !self::$hasSystemUnzip) {
  14056. $this->io->writeError("<warning>As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  14057. $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>");
  14058. $this->io->writeError("<warning>Installing 'unzip' may remediate them.</warning>");
  14059. }
  14060. }
  14061. return parent::download($package, $path, $prevPackage, $output);
  14062. }
  14063. private function extractWithSystemUnzip(PackageInterface $package, $file, $path, $isLastChance, $async = false)
  14064. {
  14065. if (!self::$hasZipArchive) {
  14066. $isLastChance = true;
  14067. }
  14068. if (!self::$hasSystemUnzip && !$isLastChance) {
  14069. return $this->extractWithZipArchive($package, $file, $path, true);
  14070. }
  14071. $overwrite = $isLastChance ? '-o' : '';
  14072. $command = 'unzip -qq '.$overwrite.' '.ProcessExecutor::escape($file).' -d '.ProcessExecutor::escape($path);
  14073. if ($async) {
  14074. $self = $this;
  14075. $io = $this->io;
  14076. $tryFallback = function ($processError) use ($isLastChance, $io, $self, $file, $path, $package) {
  14077. if ($isLastChance) {
  14078. throw $processError;
  14079. }
  14080. if (!is_file($file)) {
  14081. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14082. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  14083. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  14084. } else {
  14085. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14086. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  14087. $io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  14088. }
  14089. return $self->extractWithZipArchive($package, $file, $path, true);
  14090. };
  14091. try {
  14092. $promise = $this->process->executeAsync($command);
  14093. return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) {
  14094. if (!$process->isSuccessful()) {
  14095. $output = $process->getErrorOutput();
  14096. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  14097. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  14098. }
  14099. });
  14100. } catch (\Exception $e) {
  14101. return $tryFallback($e);
  14102. } catch (\Throwable $e) {
  14103. return $tryFallback($e);
  14104. }
  14105. }
  14106. $processError = null;
  14107. try {
  14108. if (0 === $exitCode = $this->process->execute($command, $ignoredOutput)) {
  14109. return \React\Promise\resolve();
  14110. }
  14111. $processError = new \RuntimeException('Failed to execute ('.$exitCode.') '.$command."\n\n".$this->process->getErrorOutput());
  14112. } catch (\Exception $e) {
  14113. $processError = $e;
  14114. }
  14115. if ($isLastChance) {
  14116. throw $processError;
  14117. }
  14118. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14119. $this->io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  14120. $this->io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  14121. return $this->extractWithZipArchive($package, $file, $path, true);
  14122. }
  14123. public function extractWithZipArchive(PackageInterface $package, $file, $path, $isLastChance)
  14124. {
  14125. if (!self::$hasSystemUnzip) {
  14126. $isLastChance = true;
  14127. }
  14128. if (!self::$hasZipArchive && !$isLastChance) {
  14129. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14130. }
  14131. $processError = null;
  14132. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  14133. try {
  14134. if (true === ($retval = $zipArchive->open($file))) {
  14135. $extractResult = $zipArchive->extractTo($path);
  14136. if (true === $extractResult) {
  14137. $zipArchive->close();
  14138. return \React\Promise\resolve();
  14139. }
  14140. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  14141. } else {
  14142. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  14143. }
  14144. } catch (\ErrorException $e) {
  14145. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  14146. } catch (\Exception $e) {
  14147. $processError = $e;
  14148. } catch (\Throwable $e) {
  14149. $processError = $e;
  14150. }
  14151. if ($isLastChance) {
  14152. throw $processError;
  14153. }
  14154. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14155. $this->io->writeError(' Unzip with ZipArchive class failed, falling back to unzip command');
  14156. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14157. }
  14158. public function extract(PackageInterface $package, $file, $path)
  14159. {
  14160. if (self::$isWindows) {
  14161. return $this->extractWithZipArchive($package, $file, $path, false);
  14162. }
  14163. return $this->extractWithSystemUnzip($package, $file, $path, false, true);
  14164. }
  14165. protected function getErrorMessage($retval, $file)
  14166. {
  14167. switch ($retval) {
  14168. case ZipArchive::ER_EXISTS:
  14169. return sprintf("File '%s' already exists.", $file);
  14170. case ZipArchive::ER_INCONS:
  14171. return sprintf("Zip archive '%s' is inconsistent.", $file);
  14172. case ZipArchive::ER_INVAL:
  14173. return sprintf("Invalid argument (%s)", $file);
  14174. case ZipArchive::ER_MEMORY:
  14175. return sprintf("Malloc failure (%s)", $file);
  14176. case ZipArchive::ER_NOENT:
  14177. return sprintf("No such zip file: '%s'", $file);
  14178. case ZipArchive::ER_NOZIP:
  14179. return sprintf("'%s' is not a zip archive.", $file);
  14180. case ZipArchive::ER_OPEN:
  14181. return sprintf("Can't open zip file: %s", $file);
  14182. case ZipArchive::ER_READ:
  14183. return sprintf("Zip read error (%s)", $file);
  14184. case ZipArchive::ER_SEEK:
  14185. return sprintf("Zip seek error (%s)", $file);
  14186. default:
  14187. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  14188. }
  14189. }
  14190. }
  14191. <?php
  14192. namespace Composer\EventDispatcher;
  14193. class Event
  14194. {
  14195. protected $name;
  14196. protected $args;
  14197. protected $flags;
  14198. private $propagationStopped = false;
  14199. public function __construct($name, array $args = array(), array $flags = array())
  14200. {
  14201. $this->name = $name;
  14202. $this->args = $args;
  14203. $this->flags = $flags;
  14204. }
  14205. public function getName()
  14206. {
  14207. return $this->name;
  14208. }
  14209. public function getArguments()
  14210. {
  14211. return $this->args;
  14212. }
  14213. public function getFlags()
  14214. {
  14215. return $this->flags;
  14216. }
  14217. public function isPropagationStopped()
  14218. {
  14219. return $this->propagationStopped;
  14220. }
  14221. public function stopPropagation()
  14222. {
  14223. $this->propagationStopped = true;
  14224. }
  14225. }
  14226. <?php
  14227. namespace Composer\EventDispatcher;
  14228. use Composer\DependencyResolver\Transaction;
  14229. use Composer\Installer\InstallerEvent;
  14230. use Composer\IO\IOInterface;
  14231. use Composer\Composer;
  14232. use Composer\Util\Platform;
  14233. use Composer\DependencyResolver\Operation\OperationInterface;
  14234. use Composer\Repository\RepositoryInterface;
  14235. use Composer\Script;
  14236. use Composer\Installer\PackageEvent;
  14237. use Composer\Installer\BinaryInstaller;
  14238. use Composer\Util\ProcessExecutor;
  14239. use Composer\Script\Event as ScriptEvent;
  14240. use Composer\ClassLoader;
  14241. use Symfony\Component\Process\PhpExecutableFinder;
  14242. class EventDispatcher
  14243. {
  14244. protected $composer;
  14245. protected $io;
  14246. protected $loader;
  14247. protected $process;
  14248. protected $listeners = array();
  14249. private $eventStack;
  14250. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14251. {
  14252. $this->composer = $composer;
  14253. $this->io = $io;
  14254. $this->process = $process ?: new ProcessExecutor($io);
  14255. $this->eventStack = array();
  14256. }
  14257. public function dispatch($eventName, Event $event = null)
  14258. {
  14259. if (null === $event) {
  14260. $event = new Event($eventName);
  14261. }
  14262. return $this->doDispatch($event);
  14263. }
  14264. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  14265. {
  14266. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  14267. }
  14268. public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  14269. {
  14270. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  14271. }
  14272. public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
  14273. {
  14274. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  14275. }
  14276. protected function doDispatch(Event $event)
  14277. {
  14278. if (getenv('COMPOSER_DEBUG_EVENTS')) {
  14279. $details = null;
  14280. if ($event instanceof PackageEvent) {
  14281. $details = (string) $event->getOperation();
  14282. }
  14283. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  14284. }
  14285. $listeners = $this->getListeners($event);
  14286. $this->pushEvent($event);
  14287. $returnMax = 0;
  14288. foreach ($listeners as $callable) {
  14289. $return = 0;
  14290. $this->ensureBinDirIsInPath();
  14291. if (!is_string($callable)) {
  14292. if (!is_callable($callable)) {
  14293. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  14294. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  14295. }
  14296. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  14297. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  14298. }
  14299. $return = false === call_user_func($callable, $event) ? 1 : 0;
  14300. } elseif ($this->isComposerScript($callable)) {
  14301. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  14302. $script = explode(' ', substr($callable, 1));
  14303. $scriptName = $script[0];
  14304. unset($script[0]);
  14305. $args = array_merge($script, $event->getArguments());
  14306. $flags = $event->getFlags();
  14307. if (strpos($callable, '@composer ') === 0) {
  14308. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  14309. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14310. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14311. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14312. }
  14313. } else {
  14314. if (!$this->getListeners(new Event($scriptName))) {
  14315. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  14316. }
  14317. try {
  14318. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  14319. $scriptEvent->setOriginatingEvent($event);
  14320. $return = $this->dispatch($scriptName, $scriptEvent);
  14321. } catch (ScriptExecutionException $e) {
  14322. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14323. throw $e;
  14324. }
  14325. }
  14326. } elseif ($this->isPhpScript($callable)) {
  14327. $className = substr($callable, 0, strpos($callable, '::'));
  14328. $methodName = substr($callable, strpos($callable, '::') + 2);
  14329. if (!class_exists($className)) {
  14330. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14331. continue;
  14332. }
  14333. if (!is_callable($callable)) {
  14334. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14335. continue;
  14336. }
  14337. try {
  14338. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  14339. } catch (\Exception $e) {
  14340. $message = "Script %s handling the %s event terminated with an exception";
  14341. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  14342. throw $e;
  14343. }
  14344. } else {
  14345. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  14346. $exec = $callable . ($args === '' ? '' : ' '.$args);
  14347. if ($this->io->isVerbose()) {
  14348. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  14349. } elseif ($event->getName() !== '__exec_command') {
  14350. $this->io->writeError(sprintf('> %s', $exec));
  14351. }
  14352. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  14353. if ($possibleLocalBinaries) {
  14354. foreach ($possibleLocalBinaries as $localExec) {
  14355. if (preg_match('{\b'.preg_quote($callable).'$}', $localExec)) {
  14356. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  14357. $exec = preg_replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  14358. break;
  14359. }
  14360. }
  14361. }
  14362. if (strpos($exec, '@putenv ') === 0) {
  14363. putenv(substr($exec, 8));
  14364. list($var, $value) = explode('=', substr($exec, 8), 2);
  14365. $_SERVER[$var] = $value;
  14366. continue;
  14367. }
  14368. if (strpos($exec, '@php ') === 0) {
  14369. $pathAndArgs = substr($exec, 5);
  14370. if (Platform::isWindows()) {
  14371. $pathAndArgs = preg_replace_callback('{^\S+}', function ($path) {
  14372. return str_replace('/', '\\', $path[0]);
  14373. }, $pathAndArgs);
  14374. }
  14375. $exec = $this->getPhpExecCommand() . ' ' . $pathAndArgs;
  14376. } else {
  14377. $finder = new PhpExecutableFinder();
  14378. $phpPath = $finder->find(false);
  14379. if ($phpPath) {
  14380. $_SERVER['PHP_BINARY'] = $phpPath;
  14381. putenv('PHP_BINARY=' . $_SERVER['PHP_BINARY']);
  14382. }
  14383. if (Platform::isWindows()) {
  14384. $exec = preg_replace_callback('{^\S+}', function ($path) {
  14385. return str_replace('/', '\\', $path[0]);
  14386. }, $exec);
  14387. }
  14388. }
  14389. if (strpos($exec, 'composer ') === 0) {
  14390. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8);
  14391. }
  14392. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14393. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14394. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14395. }
  14396. }
  14397. $returnMax = max($returnMax, $return);
  14398. if ($event->isPropagationStopped()) {
  14399. break;
  14400. }
  14401. }
  14402. $this->popEvent();
  14403. return $returnMax;
  14404. }
  14405. protected function executeTty($exec)
  14406. {
  14407. if ($this->io->isInteractive()) {
  14408. return $this->process->executeTty($exec);
  14409. }
  14410. return $this->process->execute($exec);
  14411. }
  14412. protected function getPhpExecCommand()
  14413. {
  14414. $finder = new PhpExecutableFinder();
  14415. $phpPath = $finder->find(false);
  14416. if (!$phpPath) {
  14417. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  14418. }
  14419. $phpArgs = $finder->findArguments();
  14420. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  14421. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  14422. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  14423. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  14424. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  14425. }
  14426. protected function executeEventPhpScript($className, $methodName, Event $event)
  14427. {
  14428. if ($this->io->isVerbose()) {
  14429. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  14430. } else {
  14431. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  14432. }
  14433. return $className::$methodName($event);
  14434. }
  14435. public function addListener($eventName, $listener, $priority = 0)
  14436. {
  14437. $this->listeners[$eventName][$priority][] = $listener;
  14438. }
  14439. public function removeListener($listener)
  14440. {
  14441. foreach ($this->listeners as $eventName => $priorities) {
  14442. foreach ($priorities as $priority => $listeners) {
  14443. foreach ($listeners as $index => $candidate) {
  14444. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  14445. unset($this->listeners[$eventName][$priority][$index]);
  14446. }
  14447. }
  14448. }
  14449. }
  14450. }
  14451. public function addSubscriber(EventSubscriberInterface $subscriber)
  14452. {
  14453. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  14454. if (is_string($params)) {
  14455. $this->addListener($eventName, array($subscriber, $params));
  14456. } elseif (is_string($params[0])) {
  14457. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  14458. } else {
  14459. foreach ($params as $listener) {
  14460. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  14461. }
  14462. }
  14463. }
  14464. }
  14465. protected function getListeners(Event $event)
  14466. {
  14467. $scriptListeners = $this->getScriptListeners($event);
  14468. if (!isset($this->listeners[$event->getName()][0])) {
  14469. $this->listeners[$event->getName()][0] = array();
  14470. }
  14471. krsort($this->listeners[$event->getName()]);
  14472. $listeners = $this->listeners;
  14473. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  14474. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  14475. }
  14476. public function hasEventListeners(Event $event)
  14477. {
  14478. $listeners = $this->getListeners($event);
  14479. return count($listeners) > 0;
  14480. }
  14481. protected function getScriptListeners(Event $event)
  14482. {
  14483. $package = $this->composer->getPackage();
  14484. $scripts = $package->getScripts();
  14485. if (empty($scripts[$event->getName()])) {
  14486. return array();
  14487. }
  14488. if ($this->loader) {
  14489. $this->loader->unregister();
  14490. }
  14491. $generator = $this->composer->getAutoloadGenerator();
  14492. if ($event instanceof ScriptEvent) {
  14493. $generator->setDevMode($event->isDevMode());
  14494. }
  14495. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  14496. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  14497. $map = $generator->parseAutoloads($packageMap, $package);
  14498. $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  14499. $this->loader->register(false);
  14500. return $scripts[$event->getName()];
  14501. }
  14502. protected function isPhpScript($callable)
  14503. {
  14504. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  14505. }
  14506. protected function isComposerScript($callable)
  14507. {
  14508. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  14509. }
  14510. protected function pushEvent(Event $event)
  14511. {
  14512. $eventName = $event->getName();
  14513. if (in_array($eventName, $this->eventStack)) {
  14514. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  14515. }
  14516. return array_push($this->eventStack, $eventName);
  14517. }
  14518. protected function popEvent()
  14519. {
  14520. return array_pop($this->eventStack);
  14521. }
  14522. private function ensureBinDirIsInPath()
  14523. {
  14524. $pathStr = 'PATH';
  14525. if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
  14526. $pathStr = 'Path';
  14527. }
  14528. $binDir = $this->composer->getConfig()->get('bin-dir');
  14529. if (is_dir($binDir)) {
  14530. $binDir = realpath($binDir);
  14531. if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) {
  14532. $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
  14533. putenv($pathStr.'='.$_SERVER[$pathStr]);
  14534. }
  14535. }
  14536. }
  14537. }
  14538. <?php
  14539. namespace Composer\EventDispatcher;
  14540. interface EventSubscriberInterface
  14541. {
  14542. public static function getSubscribedEvents();
  14543. }
  14544. <?php
  14545. namespace Composer\EventDispatcher;
  14546. class ScriptExecutionException extends \RuntimeException
  14547. {
  14548. }
  14549. <?php
  14550. namespace Composer\Exception;
  14551. class IrrecoverableDownloadException extends \RuntimeException
  14552. {
  14553. }
  14554. <?php
  14555. namespace Composer\Exception;
  14556. class NoSslException extends \RuntimeException
  14557. {
  14558. }
  14559. <?php
  14560. namespace Composer;
  14561. use Composer\Config\JsonConfigSource;
  14562. use Composer\Json\JsonFile;
  14563. use Composer\IO\IOInterface;
  14564. use Composer\Package\Archiver;
  14565. use Composer\Package\Version\VersionGuesser;
  14566. use Composer\Package\RootPackageInterface;
  14567. use Composer\Repository\RepositoryManager;
  14568. use Composer\Repository\RepositoryFactory;
  14569. use Composer\Repository\WritableRepositoryInterface;
  14570. use Composer\Util\Filesystem;
  14571. use Composer\Util\Platform;
  14572. use Composer\Util\ProcessExecutor;
  14573. use Composer\Util\HttpDownloader;
  14574. use Composer\Util\Loop;
  14575. use Composer\Util\Silencer;
  14576. use Composer\Plugin\PluginEvents;
  14577. use Composer\EventDispatcher\Event;
  14578. use Seld\JsonLint\DuplicateKeyException;
  14579. use Symfony\Component\Console\Formatter\OutputFormatter;
  14580. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  14581. use Symfony\Component\Console\Output\ConsoleOutput;
  14582. use Composer\EventDispatcher\EventDispatcher;
  14583. use Composer\Autoload\AutoloadGenerator;
  14584. use Composer\Package\Version\VersionParser;
  14585. use Composer\Downloader\TransportException;
  14586. use Seld\JsonLint\JsonParser;
  14587. class Factory
  14588. {
  14589. protected static function getHomeDir()
  14590. {
  14591. $home = getenv('COMPOSER_HOME');
  14592. if ($home) {
  14593. return $home;
  14594. }
  14595. if (Platform::isWindows()) {
  14596. if (!getenv('APPDATA')) {
  14597. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14598. }
  14599. return rtrim(strtr(getenv('APPDATA'), '\\', '/'), '/') . '/Composer';
  14600. }
  14601. $userDir = self::getUserDir();
  14602. $dirs = array();
  14603. if (self::useXdg()) {
  14604. $xdgConfig = getenv('XDG_CONFIG_HOME');
  14605. if (!$xdgConfig) {
  14606. $xdgConfig = $userDir . '/.config';
  14607. }
  14608. $dirs[] = $xdgConfig . '/composer';
  14609. }
  14610. $dirs[] = $userDir . '/.composer';
  14611. foreach ($dirs as $dir) {
  14612. if (Silencer::call('is_dir', $dir)) {
  14613. return $dir;
  14614. }
  14615. }
  14616. return $dirs[0];
  14617. }
  14618. protected static function getCacheDir($home)
  14619. {
  14620. $cacheDir = getenv('COMPOSER_CACHE_DIR');
  14621. if ($cacheDir) {
  14622. return $cacheDir;
  14623. }
  14624. $homeEnv = getenv('COMPOSER_HOME');
  14625. if ($homeEnv) {
  14626. return $homeEnv . '/cache';
  14627. }
  14628. if (Platform::isWindows()) {
  14629. if ($cacheDir = getenv('LOCALAPPDATA')) {
  14630. $cacheDir .= '/Composer';
  14631. } else {
  14632. $cacheDir = $home . '/cache';
  14633. }
  14634. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  14635. }
  14636. $userDir = self::getUserDir();
  14637. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  14638. return $home . '/cache';
  14639. }
  14640. if (self::useXdg()) {
  14641. $xdgCache = getenv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  14642. return $xdgCache . '/composer';
  14643. }
  14644. return $home . '/cache';
  14645. }
  14646. protected static function getDataDir($home)
  14647. {
  14648. $homeEnv = getenv('COMPOSER_HOME');
  14649. if ($homeEnv) {
  14650. return $homeEnv;
  14651. }
  14652. if (Platform::isWindows()) {
  14653. return strtr($home, '\\', '/');
  14654. }
  14655. $userDir = self::getUserDir();
  14656. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  14657. $xdgData = getenv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  14658. return $xdgData . '/composer';
  14659. }
  14660. return $home;
  14661. }
  14662. public static function createConfig(IOInterface $io = null, $cwd = null)
  14663. {
  14664. $cwd = $cwd ?: getcwd();
  14665. $config = new Config(true, $cwd);
  14666. $home = self::getHomeDir();
  14667. $config->merge(array('config' => array(
  14668. 'home' => $home,
  14669. 'cache-dir' => self::getCacheDir($home),
  14670. 'data-dir' => self::getDataDir($home),
  14671. )));
  14672. $file = new JsonFile($config->get('home').'/config.json');
  14673. if ($file->exists()) {
  14674. if ($io && $io->isDebug()) {
  14675. $io->writeError('Loading config file ' . $file->getPath());
  14676. }
  14677. $config->merge($file->read());
  14678. }
  14679. $config->setConfigSource(new JsonConfigSource($file));
  14680. $htaccessProtect = (bool) $config->get('htaccess-protect');
  14681. if ($htaccessProtect) {
  14682. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  14683. foreach ($dirs as $dir) {
  14684. if (!file_exists($dir . '/.htaccess')) {
  14685. if (!is_dir($dir)) {
  14686. Silencer::call('mkdir', $dir, 0777, true);
  14687. }
  14688. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  14689. }
  14690. }
  14691. }
  14692. $file = new JsonFile($config->get('home').'/auth.json');
  14693. if ($file->exists()) {
  14694. if ($io && $io->isDebug()) {
  14695. $io->writeError('Loading config file ' . $file->getPath());
  14696. }
  14697. $config->merge(array('config' => $file->read()));
  14698. }
  14699. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  14700. if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
  14701. $authData = json_decode($composerAuthEnv, true);
  14702. if (null === $authData) {
  14703. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  14704. }
  14705. if ($io && $io->isDebug()) {
  14706. $io->writeError('Loading auth config from COMPOSER_AUTH');
  14707. }
  14708. $config->merge(array('config' => $authData));
  14709. }
  14710. return $config;
  14711. }
  14712. public static function getComposerFile()
  14713. {
  14714. return trim(getenv('COMPOSER')) ?: './composer.json';
  14715. }
  14716. public static function getLockFile($composerFile)
  14717. {
  14718. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  14719. ? substr($composerFile, 0, -4).'lock'
  14720. : $composerFile . '.lock';
  14721. }
  14722. public static function createAdditionalStyles()
  14723. {
  14724. return array(
  14725. 'highlight' => new OutputFormatterStyle('red'),
  14726. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  14727. );
  14728. }
  14729. public static function createOutput()
  14730. {
  14731. $styles = self::createAdditionalStyles();
  14732. $formatter = new OutputFormatter(false, $styles);
  14733. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  14734. }
  14735. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
  14736. {
  14737. $cwd = $cwd ?: getcwd();
  14738. if (null === $localConfig) {
  14739. $localConfig = static::getComposerFile();
  14740. }
  14741. if (is_string($localConfig)) {
  14742. $composerFile = $localConfig;
  14743. $file = new JsonFile($localConfig, null, $io);
  14744. if (!$file->exists()) {
  14745. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  14746. $message = 'Composer could not find a composer.json file in '.$cwd;
  14747. } else {
  14748. $message = 'Composer could not find the config file: '.$localConfig;
  14749. }
  14750. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section' : '';
  14751. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  14752. }
  14753. $file->validateSchema(JsonFile::LAX_SCHEMA);
  14754. $jsonParser = new JsonParser;
  14755. try {
  14756. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  14757. } catch (DuplicateKeyException $e) {
  14758. $details = $e->getDetails();
  14759. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  14760. }
  14761. $localConfig = $file->read();
  14762. }
  14763. $config = static::createConfig($io, $cwd);
  14764. $config->merge($localConfig);
  14765. if (isset($composerFile)) {
  14766. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  14767. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  14768. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  14769. if ($localAuthFile->exists()) {
  14770. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  14771. $config->merge(array('config' => $localAuthFile->read()));
  14772. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  14773. }
  14774. }
  14775. $vendorDir = $config->get('vendor-dir');
  14776. $composer = new Composer();
  14777. $composer->setConfig($config);
  14778. if ($fullLoad) {
  14779. $io->loadConfiguration($config);
  14780. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  14781. include $installedVersionsPath;
  14782. }
  14783. }
  14784. $httpDownloader = self::createHttpDownloader($io, $config);
  14785. $process = new ProcessExecutor($io);
  14786. $loop = new Loop($httpDownloader, $process);
  14787. $composer->setLoop($loop);
  14788. $dispatcher = new EventDispatcher($composer, $io, $process);
  14789. $composer->setEventDispatcher($dispatcher);
  14790. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  14791. $composer->setRepositoryManager($rm);
  14792. if (!$fullLoad && !isset($localConfig['version'])) {
  14793. $localConfig['version'] = '1.0.0';
  14794. }
  14795. $parser = new VersionParser;
  14796. $guesser = new VersionGuesser($config, $process, $parser);
  14797. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  14798. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  14799. $composer->setPackage($package);
  14800. $this->addLocalRepository($io, $rm, $vendorDir, $package);
  14801. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  14802. $composer->setInstallationManager($im);
  14803. if ($fullLoad) {
  14804. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  14805. $composer->setDownloadManager($dm);
  14806. $generator = new AutoloadGenerator($dispatcher, $io);
  14807. $composer->setAutoloadGenerator($generator);
  14808. $am = $this->createArchiveManager($config, $dm, $loop);
  14809. $composer->setArchiveManager($am);
  14810. }
  14811. $this->createDefaultInstallers($im, $composer, $io, $process);
  14812. if ($fullLoad) {
  14813. $globalComposer = null;
  14814. if (realpath($config->get('home')) !== $cwd) {
  14815. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
  14816. }
  14817. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  14818. $composer->setPluginManager($pm);
  14819. $pm->loadInstalledPlugins();
  14820. }
  14821. if ($fullLoad && isset($composerFile)) {
  14822. $lockFile = self::getLockFile($composerFile);
  14823. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
  14824. $composer->setLocker($locker);
  14825. }
  14826. if ($fullLoad) {
  14827. $initEvent = new Event(PluginEvents::INIT);
  14828. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  14829. if ($rm->getLocalRepository()) {
  14830. $this->purgePackages($rm->getLocalRepository(), $im);
  14831. }
  14832. }
  14833. return $composer;
  14834. }
  14835. public static function createGlobal(IOInterface $io, $disablePlugins = false)
  14836. {
  14837. $factory = new static();
  14838. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, true);
  14839. }
  14840. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage)
  14841. {
  14842. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage));
  14843. }
  14844. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
  14845. {
  14846. $composer = null;
  14847. try {
  14848. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad);
  14849. } catch (\Exception $e) {
  14850. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  14851. }
  14852. return $composer;
  14853. }
  14854. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null)
  14855. {
  14856. $cache = null;
  14857. if ($config->get('cache-files-ttl') > 0) {
  14858. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  14859. $cache->setReadOnly($config->get('cache-read-only'));
  14860. }
  14861. $fs = new Filesystem($process);
  14862. $dm = new Downloader\DownloadManager($io, false, $fs);
  14863. switch ($preferred = $config->get('preferred-install')) {
  14864. case 'dist':
  14865. $dm->setPreferDist(true);
  14866. break;
  14867. case 'source':
  14868. $dm->setPreferSource(true);
  14869. break;
  14870. case 'auto':
  14871. default:
  14872. break;
  14873. }
  14874. if (is_array($preferred)) {
  14875. $dm->setPreferences($preferred);
  14876. }
  14877. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  14878. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  14879. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  14880. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  14881. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  14882. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14883. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14884. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14885. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14886. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14887. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14888. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14889. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14890. return $dm;
  14891. }
  14892. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  14893. {
  14894. $am = new Archiver\ArchiveManager($dm, $loop);
  14895. $am->addArchiver(new Archiver\ZipArchiver);
  14896. $am->addArchiver(new Archiver\PharArchiver);
  14897. return $am;
  14898. }
  14899. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  14900. {
  14901. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  14902. }
  14903. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  14904. {
  14905. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  14906. }
  14907. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14908. {
  14909. $fs = new Filesystem($process);
  14910. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs);
  14911. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  14912. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  14913. $im->addInstaller(new Installer\MetapackageInstaller($io));
  14914. }
  14915. protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
  14916. {
  14917. foreach ($repo->getPackages() as $package) {
  14918. if (!$im->isPackageInstalled($repo, $package)) {
  14919. $repo->removePackage($package);
  14920. }
  14921. }
  14922. }
  14923. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
  14924. {
  14925. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  14926. }
  14927. public static function create(IOInterface $io, $config = null, $disablePlugins = false)
  14928. {
  14929. $factory = new static();
  14930. return $factory->createComposer($io, $config, $disablePlugins);
  14931. }
  14932. public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())
  14933. {
  14934. static $warned = false;
  14935. $disableTls = false;
  14936. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  14937. $warned = true;
  14938. $disableTls = !extension_loaded('openssl');
  14939. } elseif ($config && $config->get('disable-tls') === true) {
  14940. if (!$warned) {
  14941. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  14942. }
  14943. $warned = true;
  14944. $disableTls = true;
  14945. } elseif (!extension_loaded('openssl')) {
  14946. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  14947. . '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.');
  14948. }
  14949. $httpDownloaderOptions = array();
  14950. if ($disableTls === false) {
  14951. if ($config && $config->get('cafile')) {
  14952. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  14953. }
  14954. if ($config && $config->get('capath')) {
  14955. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  14956. }
  14957. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  14958. }
  14959. try {
  14960. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  14961. } catch (TransportException $e) {
  14962. if (false !== strpos($e->getMessage(), 'cafile')) {
  14963. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  14964. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  14965. if (PHP_VERSION_ID < 50600) {
  14966. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  14967. }
  14968. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  14969. }
  14970. throw $e;
  14971. }
  14972. return $httpDownloader;
  14973. }
  14974. private static function useXdg()
  14975. {
  14976. foreach (array_keys($_SERVER) as $key) {
  14977. if (strpos($key, 'XDG_') === 0) {
  14978. return true;
  14979. }
  14980. }
  14981. if (Silencer::call('is_dir', '/etc/xdg')) {
  14982. return true;
  14983. }
  14984. return false;
  14985. }
  14986. private static function getUserDir()
  14987. {
  14988. $home = getenv('HOME');
  14989. if (!$home) {
  14990. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14991. }
  14992. return rtrim(strtr($home, '\\', '/'), '/');
  14993. }
  14994. }
  14995. <?php
  14996. namespace Composer\IO;
  14997. use Composer\Config;
  14998. use Composer\Util\ProcessExecutor;
  14999. use Psr\Log\LogLevel;
  15000. abstract class BaseIO implements IOInterface
  15001. {
  15002. protected $authentications = array();
  15003. public function getAuthentications()
  15004. {
  15005. return $this->authentications;
  15006. }
  15007. public function resetAuthentications()
  15008. {
  15009. $this->authentications = array();
  15010. }
  15011. public function hasAuthentication($repositoryName)
  15012. {
  15013. return isset($this->authentications[$repositoryName]);
  15014. }
  15015. public function getAuthentication($repositoryName)
  15016. {
  15017. if (isset($this->authentications[$repositoryName])) {
  15018. return $this->authentications[$repositoryName];
  15019. }
  15020. return array('username' => null, 'password' => null);
  15021. }
  15022. public function setAuthentication($repositoryName, $username, $password = null)
  15023. {
  15024. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  15025. }
  15026. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15027. {
  15028. $this->write($messages, $newline, $verbosity);
  15029. }
  15030. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15031. {
  15032. $this->writeError($messages, $newline, $verbosity);
  15033. }
  15034. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  15035. {
  15036. if ($this->hasAuthentication($repositoryName)) {
  15037. $auth = $this->getAuthentication($repositoryName);
  15038. if ($auth['username'] === $username && $auth['password'] === $password) {
  15039. return;
  15040. }
  15041. $this->writeError(
  15042. sprintf(
  15043. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  15044. $repositoryName
  15045. )
  15046. );
  15047. }
  15048. $this->setAuthentication($repositoryName, $username, $password);
  15049. }
  15050. public function loadConfiguration(Config $config)
  15051. {
  15052. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  15053. $githubOauth = $config->get('github-oauth') ?: array();
  15054. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  15055. $gitlabToken = $config->get('gitlab-token') ?: array();
  15056. $httpBasic = $config->get('http-basic') ?: array();
  15057. $bearerToken = $config->get('bearer') ?: array();
  15058. foreach ($bitbucketOauth as $domain => $cred) {
  15059. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  15060. }
  15061. foreach ($githubOauth as $domain => $token) {
  15062. if (!preg_match('{^[.A-Za-z0-9_]+$}', $token)) {
  15063. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  15064. }
  15065. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  15066. }
  15067. foreach ($gitlabOauth as $domain => $token) {
  15068. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  15069. }
  15070. foreach ($gitlabToken as $domain => $token) {
  15071. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  15072. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  15073. $this->checkAndSetAuthentication($domain, $username, $password);
  15074. }
  15075. foreach ($httpBasic as $domain => $cred) {
  15076. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  15077. }
  15078. foreach ($bearerToken as $domain => $token) {
  15079. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  15080. }
  15081. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  15082. }
  15083. public function emergency($message, array $context = array())
  15084. {
  15085. return $this->log(LogLevel::EMERGENCY, $message, $context);
  15086. }
  15087. public function alert($message, array $context = array())
  15088. {
  15089. return $this->log(LogLevel::ALERT, $message, $context);
  15090. }
  15091. public function critical($message, array $context = array())
  15092. {
  15093. return $this->log(LogLevel::CRITICAL, $message, $context);
  15094. }
  15095. public function error($message, array $context = array())
  15096. {
  15097. return $this->log(LogLevel::ERROR, $message, $context);
  15098. }
  15099. public function warning($message, array $context = array())
  15100. {
  15101. return $this->log(LogLevel::WARNING, $message, $context);
  15102. }
  15103. public function notice($message, array $context = array())
  15104. {
  15105. return $this->log(LogLevel::NOTICE, $message, $context);
  15106. }
  15107. public function info($message, array $context = array())
  15108. {
  15109. return $this->log(LogLevel::INFO, $message, $context);
  15110. }
  15111. public function debug($message, array $context = array())
  15112. {
  15113. return $this->log(LogLevel::DEBUG, $message, $context);
  15114. }
  15115. public function log($level, $message, array $context = array())
  15116. {
  15117. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  15118. $this->writeError('<error>'.$message.'</error>');
  15119. } elseif ($level === LogLevel::WARNING) {
  15120. $this->writeError('<warning>'.$message.'</warning>');
  15121. } elseif ($level === LogLevel::NOTICE) {
  15122. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  15123. } elseif ($level === LogLevel::INFO) {
  15124. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  15125. } else {
  15126. $this->writeError($message, true, self::DEBUG);
  15127. }
  15128. }
  15129. }
  15130. <?php
  15131. namespace Composer\IO;
  15132. use Symfony\Component\Console\Helper\QuestionHelper;
  15133. use Symfony\Component\Console\Output\StreamOutput;
  15134. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  15135. use Symfony\Component\Console\Input\StreamableInputInterface;
  15136. use Symfony\Component\Console\Input\StringInput;
  15137. use Symfony\Component\Console\Helper\HelperSet;
  15138. class BufferIO extends ConsoleIO
  15139. {
  15140. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  15141. {
  15142. $input = new StringInput($input);
  15143. $input->setInteractive(false);
  15144. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  15145. parent::__construct($input, $output, new HelperSet(array(
  15146. new QuestionHelper(),
  15147. )));
  15148. }
  15149. public function getOutput()
  15150. {
  15151. fseek($this->output->getStream(), 0);
  15152. $output = stream_get_contents($this->output->getStream());
  15153. $output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  15154. $pre = strip_tags($matches[1]);
  15155. if (strlen($pre) === strlen($matches[2])) {
  15156. return '';
  15157. }
  15158. return rtrim($matches[1])."\n";
  15159. }, $output);
  15160. return $output;
  15161. }
  15162. public function setUserInputs(array $inputs)
  15163. {
  15164. if (!$this->input instanceof StreamableInputInterface) {
  15165. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  15166. }
  15167. $this->input->setStream($this->createStream($inputs));
  15168. $this->input->setInteractive(true);
  15169. }
  15170. private function createStream(array $inputs)
  15171. {
  15172. $stream = fopen('php://memory', 'r+');
  15173. foreach ($inputs as $input) {
  15174. fwrite($stream, $input.PHP_EOL);
  15175. }
  15176. rewind($stream);
  15177. return $stream;
  15178. }
  15179. }
  15180. <?php
  15181. namespace Composer\IO;
  15182. use Composer\Question\StrictConfirmationQuestion;
  15183. use Symfony\Component\Console\Helper\HelperSet;
  15184. use Symfony\Component\Console\Helper\ProgressBar;
  15185. use Symfony\Component\Console\Input\InputInterface;
  15186. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  15187. use Symfony\Component\Console\Output\OutputInterface;
  15188. use Symfony\Component\Console\Question\ChoiceQuestion;
  15189. use Symfony\Component\Console\Question\Question;
  15190. class ConsoleIO extends BaseIO
  15191. {
  15192. protected $input;
  15193. protected $output;
  15194. protected $helperSet;
  15195. protected $lastMessage;
  15196. protected $lastMessageErr;
  15197. private $startTime;
  15198. private $verbosityMap;
  15199. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  15200. {
  15201. $this->input = $input;
  15202. $this->output = $output;
  15203. $this->helperSet = $helperSet;
  15204. $this->verbosityMap = array(
  15205. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  15206. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  15207. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  15208. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  15209. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  15210. );
  15211. }
  15212. public function enableDebugging($startTime)
  15213. {
  15214. $this->startTime = $startTime;
  15215. }
  15216. public function isInteractive()
  15217. {
  15218. return $this->input->isInteractive();
  15219. }
  15220. public function isDecorated()
  15221. {
  15222. return $this->output->isDecorated();
  15223. }
  15224. public function isVerbose()
  15225. {
  15226. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  15227. }
  15228. public function isVeryVerbose()
  15229. {
  15230. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  15231. }
  15232. public function isDebug()
  15233. {
  15234. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  15235. }
  15236. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15237. {
  15238. $this->doWrite($messages, $newline, false, $verbosity);
  15239. }
  15240. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15241. {
  15242. $this->doWrite($messages, $newline, true, $verbosity);
  15243. }
  15244. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15245. {
  15246. $this->doWrite($messages, $newline, false, $verbosity, true);
  15247. }
  15248. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15249. {
  15250. $this->doWrite($messages, $newline, true, $verbosity, true);
  15251. }
  15252. private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
  15253. {
  15254. $sfVerbosity = $this->verbosityMap[$verbosity];
  15255. if ($sfVerbosity > $this->output->getVerbosity()) {
  15256. return;
  15257. }
  15258. if (OutputInterface::VERBOSITY_QUIET === 0) {
  15259. $sfVerbosity = OutputInterface::OUTPUT_NORMAL;
  15260. }
  15261. if ($raw) {
  15262. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  15263. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  15264. } else {
  15265. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  15266. }
  15267. }
  15268. if (null !== $this->startTime) {
  15269. $memoryUsage = memory_get_usage() / 1024 / 1024;
  15270. $timeSpent = microtime(true) - $this->startTime;
  15271. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  15272. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  15273. }, (array) $messages);
  15274. }
  15275. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  15276. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  15277. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  15278. return;
  15279. }
  15280. $this->output->write($messages, $newline, $sfVerbosity);
  15281. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  15282. }
  15283. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15284. {
  15285. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  15286. }
  15287. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15288. {
  15289. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  15290. }
  15291. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  15292. {
  15293. $messages = implode($newline ? "\n" : '', (array) $messages);
  15294. if (!isset($size)) {
  15295. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  15296. }
  15297. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  15298. $this->doWrite($messages, false, $stderr, $verbosity);
  15299. $fill = $size - strlen(strip_tags($messages));
  15300. if ($fill > 0) {
  15301. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  15302. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  15303. }
  15304. if ($newline) {
  15305. $this->doWrite('', true, $stderr, $verbosity);
  15306. }
  15307. if ($stderr) {
  15308. $this->lastMessageErr = $messages;
  15309. } else {
  15310. $this->lastMessage = $messages;
  15311. }
  15312. }
  15313. public function getProgressBar($max = 0)
  15314. {
  15315. return new ProgressBar($this->getErrorOutput(), $max);
  15316. }
  15317. public function ask($question, $default = null)
  15318. {
  15319. $helper = $this->helperSet->get('question');
  15320. $question = new Question($question, $default);
  15321. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15322. }
  15323. public function askConfirmation($question, $default = true)
  15324. {
  15325. $helper = $this->helperSet->get('question');
  15326. $question = new StrictConfirmationQuestion($question, $default);
  15327. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15328. }
  15329. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  15330. {
  15331. $helper = $this->helperSet->get('question');
  15332. $question = new Question($question, $default);
  15333. $question->setValidator($validator);
  15334. $question->setMaxAttempts($attempts);
  15335. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15336. }
  15337. public function askAndHideAnswer($question)
  15338. {
  15339. $helper = $this->helperSet->get('question');
  15340. $question = new Question($question);
  15341. $question->setHidden(true);
  15342. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15343. }
  15344. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15345. {
  15346. $helper = $this->helperSet->get('question');
  15347. $question = new ChoiceQuestion($question, $choices, $default);
  15348. $question->setMaxAttempts($attempts ?: null);
  15349. $question->setErrorMessage($errorMessage);
  15350. $question->setMultiselect($multiselect);
  15351. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  15352. if (!is_array($result)) {
  15353. return (string) array_search($result, $choices, true);
  15354. }
  15355. $results = array();
  15356. foreach ($choices as $index => $choice) {
  15357. if (in_array($choice, $result, true)) {
  15358. $results[] = (string) $index;
  15359. }
  15360. }
  15361. return $results;
  15362. }
  15363. private function getErrorOutput()
  15364. {
  15365. if ($this->output instanceof ConsoleOutputInterface) {
  15366. return $this->output->getErrorOutput();
  15367. }
  15368. return $this->output;
  15369. }
  15370. }
  15371. <?php
  15372. namespace Composer\IO;
  15373. use Composer\Config;
  15374. use Psr\Log\LoggerInterface;
  15375. interface IOInterface extends LoggerInterface
  15376. {
  15377. const QUIET = 1;
  15378. const NORMAL = 2;
  15379. const VERBOSE = 4;
  15380. const VERY_VERBOSE = 8;
  15381. const DEBUG = 16;
  15382. public function isInteractive();
  15383. public function isVerbose();
  15384. public function isVeryVerbose();
  15385. public function isDebug();
  15386. public function isDecorated();
  15387. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  15388. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  15389. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15390. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15391. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15392. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15393. public function ask($question, $default = null);
  15394. public function askConfirmation($question, $default = true);
  15395. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  15396. public function askAndHideAnswer($question);
  15397. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  15398. public function getAuthentications();
  15399. public function hasAuthentication($repositoryName);
  15400. public function getAuthentication($repositoryName);
  15401. public function setAuthentication($repositoryName, $username, $password = null);
  15402. public function loadConfiguration(Config $config);
  15403. }
  15404. <?php
  15405. namespace Composer\IO;
  15406. class NullIO extends BaseIO
  15407. {
  15408. public function isInteractive()
  15409. {
  15410. return false;
  15411. }
  15412. public function isVerbose()
  15413. {
  15414. return false;
  15415. }
  15416. public function isVeryVerbose()
  15417. {
  15418. return false;
  15419. }
  15420. public function isDebug()
  15421. {
  15422. return false;
  15423. }
  15424. public function isDecorated()
  15425. {
  15426. return false;
  15427. }
  15428. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15429. {
  15430. }
  15431. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15432. {
  15433. }
  15434. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15435. {
  15436. }
  15437. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15438. {
  15439. }
  15440. public function ask($question, $default = null)
  15441. {
  15442. return $default;
  15443. }
  15444. public function askConfirmation($question, $default = true)
  15445. {
  15446. return $default;
  15447. }
  15448. public function askAndValidate($question, $validator, $attempts = false, $default = null)
  15449. {
  15450. return $default;
  15451. }
  15452. public function askAndHideAnswer($question)
  15453. {
  15454. return null;
  15455. }
  15456. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15457. {
  15458. return $default;
  15459. }
  15460. }
  15461. <?php
  15462. namespace Composer;
  15463. use Composer\Autoload\ClassLoader;
  15464. use Composer\Semver\VersionParser;
  15465. class InstalledVersions
  15466. {
  15467. private static $installed;
  15468. private static $canGetVendors;
  15469. private static $installedByVendor = array();
  15470. public static function getInstalledPackages()
  15471. {
  15472. $packages = array();
  15473. foreach (self::getInstalled() as $installed) {
  15474. $packages[] = array_keys($installed['versions']);
  15475. }
  15476. if (1 === \count($packages)) {
  15477. return $packages[0];
  15478. }
  15479. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  15480. }
  15481. public static function isInstalled($packageName)
  15482. {
  15483. foreach (self::getInstalled() as $installed) {
  15484. if (isset($installed['versions'][$packageName])) {
  15485. return true;
  15486. }
  15487. }
  15488. return false;
  15489. }
  15490. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  15491. {
  15492. $constraint = $parser->parseConstraints($constraint);
  15493. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  15494. return $provided->matches($constraint);
  15495. }
  15496. public static function getVersionRanges($packageName)
  15497. {
  15498. foreach (self::getInstalled() as $installed) {
  15499. if (!isset($installed['versions'][$packageName])) {
  15500. continue;
  15501. }
  15502. $ranges = array();
  15503. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  15504. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  15505. }
  15506. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  15507. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  15508. }
  15509. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  15510. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  15511. }
  15512. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  15513. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  15514. }
  15515. return implode(' || ', $ranges);
  15516. }
  15517. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15518. }
  15519. public static function getVersion($packageName)
  15520. {
  15521. foreach (self::getInstalled() as $installed) {
  15522. if (!isset($installed['versions'][$packageName])) {
  15523. continue;
  15524. }
  15525. if (!isset($installed['versions'][$packageName]['version'])) {
  15526. return null;
  15527. }
  15528. return $installed['versions'][$packageName]['version'];
  15529. }
  15530. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15531. }
  15532. public static function getPrettyVersion($packageName)
  15533. {
  15534. foreach (self::getInstalled() as $installed) {
  15535. if (!isset($installed['versions'][$packageName])) {
  15536. continue;
  15537. }
  15538. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  15539. return null;
  15540. }
  15541. return $installed['versions'][$packageName]['pretty_version'];
  15542. }
  15543. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15544. }
  15545. public static function getReference($packageName)
  15546. {
  15547. foreach (self::getInstalled() as $installed) {
  15548. if (!isset($installed['versions'][$packageName])) {
  15549. continue;
  15550. }
  15551. if (!isset($installed['versions'][$packageName]['reference'])) {
  15552. return null;
  15553. }
  15554. return $installed['versions'][$packageName]['reference'];
  15555. }
  15556. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15557. }
  15558. public static function getRootPackage()
  15559. {
  15560. $installed = self::getInstalled();
  15561. return $installed[0]['root'];
  15562. }
  15563. public static function getRawData()
  15564. {
  15565. return self::$installed;
  15566. }
  15567. public static function reload($data)
  15568. {
  15569. self::$installed = $data;
  15570. self::$installedByVendor = array();
  15571. }
  15572. private static function getInstalled()
  15573. {
  15574. if (null === self::$canGetVendors) {
  15575. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  15576. }
  15577. $installed = array();
  15578. if (self::$canGetVendors) {
  15579. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  15580. if (isset(self::$installedByVendor[$vendorDir])) {
  15581. $installed[] = self::$installedByVendor[$vendorDir];
  15582. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  15583. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  15584. }
  15585. }
  15586. }
  15587. $installed[] = self::$installed;
  15588. return $installed;
  15589. }
  15590. }
  15591. <?php
  15592. namespace Composer;
  15593. use Composer\Autoload\AutoloadGenerator;
  15594. use Composer\Console\GithubActionError;
  15595. use Composer\DependencyResolver\DefaultPolicy;
  15596. use Composer\DependencyResolver\LocalRepoTransaction;
  15597. use Composer\DependencyResolver\LockTransaction;
  15598. use Composer\DependencyResolver\Operation\UpdateOperation;
  15599. use Composer\DependencyResolver\Operation\InstallOperation;
  15600. use Composer\DependencyResolver\Operation\UninstallOperation;
  15601. use Composer\DependencyResolver\Pool;
  15602. use Composer\DependencyResolver\Request;
  15603. use Composer\DependencyResolver\Solver;
  15604. use Composer\DependencyResolver\SolverProblemsException;
  15605. use Composer\DependencyResolver\PolicyInterface;
  15606. use Composer\Downloader\DownloadManager;
  15607. use Composer\EventDispatcher\EventDispatcher;
  15608. use Composer\Installer\InstallationManager;
  15609. use Composer\Installer\InstallerEvents;
  15610. use Composer\Installer\SuggestedPackagesReporter;
  15611. use Composer\IO\IOInterface;
  15612. use Composer\Package\AliasPackage;
  15613. use Composer\Package\RootAliasPackage;
  15614. use Composer\Package\BasePackage;
  15615. use Composer\Package\CompletePackage;
  15616. use Composer\Package\CompletePackageInterface;
  15617. use Composer\Package\Link;
  15618. use Composer\Package\Loader\ArrayLoader;
  15619. use Composer\Package\Dumper\ArrayDumper;
  15620. use Composer\Package\Version\VersionParser;
  15621. use Composer\Package\Package;
  15622. use Composer\Repository\ArrayRepository;
  15623. use Composer\Repository\RepositorySet;
  15624. use Composer\Repository\CompositeRepository;
  15625. use Composer\Semver\Constraint\Constraint;
  15626. use Composer\Package\Locker;
  15627. use Composer\Package\RootPackageInterface;
  15628. use Composer\Repository\InstalledArrayRepository;
  15629. use Composer\Repository\InstalledRepositoryInterface;
  15630. use Composer\Repository\InstalledRepository;
  15631. use Composer\Repository\FilterRepository;
  15632. use Composer\Repository\RootPackageRepository;
  15633. use Composer\Repository\PlatformRepository;
  15634. use Composer\Repository\RepositoryInterface;
  15635. use Composer\Repository\RepositoryManager;
  15636. use Composer\Repository\LockArrayRepository;
  15637. use Composer\Script\ScriptEvents;
  15638. class Installer
  15639. {
  15640. protected $io;
  15641. protected $config;
  15642. protected $package;
  15643. protected $fixedRootPackage;
  15644. protected $downloadManager;
  15645. protected $repositoryManager;
  15646. protected $locker;
  15647. protected $installationManager;
  15648. protected $eventDispatcher;
  15649. protected $autoloadGenerator;
  15650. protected $preferSource = false;
  15651. protected $preferDist = false;
  15652. protected $optimizeAutoloader = false;
  15653. protected $classMapAuthoritative = false;
  15654. protected $apcuAutoloader = false;
  15655. protected $apcuAutoloaderPrefix;
  15656. protected $devMode = false;
  15657. protected $dryRun = false;
  15658. protected $verbose = false;
  15659. protected $update = false;
  15660. protected $install = true;
  15661. protected $dumpAutoloader = true;
  15662. protected $runScripts = true;
  15663. protected $ignorePlatformReqs = false;
  15664. protected $preferStable = false;
  15665. protected $preferLowest = false;
  15666. protected $writeLock;
  15667. protected $executeOperations = true;
  15668. protected $updateMirrors = false;
  15669. protected $updateAllowList;
  15670. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  15671. protected $suggestedPackagesReporter;
  15672. protected $additionalFixedRepository;
  15673. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  15674. {
  15675. $this->io = $io;
  15676. $this->config = $config;
  15677. $this->package = $package;
  15678. $this->downloadManager = $downloadManager;
  15679. $this->repositoryManager = $repositoryManager;
  15680. $this->locker = $locker;
  15681. $this->installationManager = $installationManager;
  15682. $this->eventDispatcher = $eventDispatcher;
  15683. $this->autoloadGenerator = $autoloadGenerator;
  15684. $this->writeLock = $config->get('lock');
  15685. }
  15686. public function run()
  15687. {
  15688. gc_collect_cycles();
  15689. gc_disable();
  15690. if ($this->updateAllowList && $this->updateMirrors) {
  15691. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  15692. }
  15693. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  15694. if (!$this->update && !$this->locker->isLocked()) {
  15695. $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>');
  15696. $this->update = true;
  15697. }
  15698. if ($this->dryRun) {
  15699. $this->verbose = true;
  15700. $this->runScripts = false;
  15701. $this->executeOperations = false;
  15702. $this->writeLock = false;
  15703. $this->dumpAutoloader = false;
  15704. $this->mockLocalRepositories($this->repositoryManager);
  15705. }
  15706. if ($this->update && !$this->install) {
  15707. $this->dumpAutoloader = false;
  15708. }
  15709. if ($this->runScripts) {
  15710. $_SERVER['COMPOSER_DEV_MODE'] = $this->devMode ? '1' : '0';
  15711. putenv('COMPOSER_DEV_MODE='.$_SERVER['COMPOSER_DEV_MODE']);
  15712. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  15713. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15714. }
  15715. $this->downloadManager->setPreferSource($this->preferSource);
  15716. $this->downloadManager->setPreferDist($this->preferDist);
  15717. $localRepo = $this->repositoryManager->getLocalRepository();
  15718. if (!$this->suggestedPackagesReporter) {
  15719. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  15720. }
  15721. try {
  15722. if ($this->update) {
  15723. $res = $this->doUpdate($localRepo, $this->install);
  15724. } else {
  15725. $res = $this->doInstall($localRepo);
  15726. }
  15727. if ($res !== 0) {
  15728. return $res;
  15729. }
  15730. } catch (\Exception $e) {
  15731. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15732. $this->installationManager->notifyInstalls($this->io);
  15733. }
  15734. throw $e;
  15735. }
  15736. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15737. $this->installationManager->notifyInstalls($this->io);
  15738. }
  15739. if ($this->update) {
  15740. $installedRepo = new InstalledRepository(array(
  15741. $this->locker->getLockedRepository($this->devMode),
  15742. $this->createPlatformRepo(false),
  15743. new RootPackageRepository(clone $this->package),
  15744. ));
  15745. if ($isFreshInstall) {
  15746. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  15747. }
  15748. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  15749. }
  15750. $lockedRepository = $this->locker->getLockedRepository(true);
  15751. foreach ($lockedRepository->getPackages() as $package) {
  15752. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  15753. continue;
  15754. }
  15755. $replacement = is_string($package->getReplacementPackage())
  15756. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  15757. : 'No replacement was suggested';
  15758. $this->io->writeError(
  15759. sprintf(
  15760. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  15761. $package->getPrettyName(),
  15762. $replacement
  15763. )
  15764. );
  15765. }
  15766. if ($this->dumpAutoloader) {
  15767. if ($this->optimizeAutoloader) {
  15768. $this->io->writeError('<info>Generating optimized autoload files</info>');
  15769. } else {
  15770. $this->io->writeError('<info>Generating autoload files</info>');
  15771. }
  15772. $this->autoloadGenerator->setDevMode($this->devMode);
  15773. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  15774. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  15775. $this->autoloadGenerator->setRunScripts($this->runScripts);
  15776. $this->autoloadGenerator->setIgnorePlatformRequirements($this->ignorePlatformReqs);
  15777. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  15778. }
  15779. if ($this->install && $this->executeOperations) {
  15780. foreach ($localRepo->getPackages() as $package) {
  15781. $this->installationManager->ensureBinariesPresence($package);
  15782. }
  15783. }
  15784. $fundingCount = 0;
  15785. foreach ($localRepo->getPackages() as $package) {
  15786. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  15787. $fundingCount++;
  15788. }
  15789. }
  15790. if ($fundingCount) {
  15791. $this->io->writeError(array(
  15792. sprintf(
  15793. "<info>%d package%s you are using %s looking for funding.</info>",
  15794. $fundingCount,
  15795. 1 === $fundingCount ? '' : 's',
  15796. 1 === $fundingCount ? 'is' : 'are'
  15797. ),
  15798. '<info>Use the `composer fund` command to find out more!</info>',
  15799. ));
  15800. }
  15801. if ($this->runScripts) {
  15802. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  15803. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15804. }
  15805. if (!defined('HHVM_VERSION')) {
  15806. gc_enable();
  15807. }
  15808. return 0;
  15809. }
  15810. protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
  15811. {
  15812. $platformRepo = $this->createPlatformRepo(true);
  15813. $aliases = $this->getRootAliases(true);
  15814. $lockedRepository = null;
  15815. try {
  15816. if ($this->locker->isLocked()) {
  15817. $lockedRepository = $this->locker->getLockedRepository(true);
  15818. }
  15819. } catch (\Seld\JsonLint\ParsingException $e) {
  15820. if ($this->updateAllowList || $this->updateMirrors) {
  15821. throw $e;
  15822. }
  15823. }
  15824. if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
  15825. $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);
  15826. return 1;
  15827. }
  15828. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  15829. $policy = $this->createPolicy(true);
  15830. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15831. $repositories = $this->repositoryManager->getRepositories();
  15832. foreach ($repositories as $repository) {
  15833. $repositorySet->addRepository($repository);
  15834. }
  15835. if ($lockedRepository) {
  15836. $repositorySet->addRepository($lockedRepository);
  15837. }
  15838. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15839. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  15840. if ($this->updateAllowList) {
  15841. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  15842. }
  15843. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15844. $this->io->writeError('<info>Updating dependencies</info>');
  15845. $solver = new Solver($policy, $pool, $this->io);
  15846. try {
  15847. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15848. $ruleSetSize = $solver->getRuleSetSize();
  15849. $solver = null;
  15850. } catch (SolverProblemsException $e) {
  15851. $err = 'Your requirements could not be resolved to an installable set of packages.';
  15852. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15853. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15854. $this->io->writeError($prettyProblem);
  15855. if (!$this->devMode) {
  15856. $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);
  15857. }
  15858. $ghe = new GithubActionError($this->io);
  15859. $ghe->emit($err."\n".$prettyProblem);
  15860. return max(1, $e->getCode());
  15861. }
  15862. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  15863. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  15864. if (!$lockTransaction->getOperations()) {
  15865. $this->io->writeError('Nothing to modify in lock file');
  15866. }
  15867. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  15868. if ($exitCode !== 0) {
  15869. return $exitCode;
  15870. }
  15871. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  15872. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  15873. $installsUpdates = $uninstalls = array();
  15874. if ($lockTransaction->getOperations()) {
  15875. $installNames = $updateNames = $uninstallNames = array();
  15876. foreach ($lockTransaction->getOperations() as $operation) {
  15877. if ($operation instanceof InstallOperation) {
  15878. $installsUpdates[] = $operation;
  15879. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15880. } elseif ($operation instanceof UpdateOperation) {
  15881. if ($this->updateMirrors
  15882. && $operation->getInitialPackage()->getName() == $operation->getTargetPackage()->getName()
  15883. && $operation->getInitialPackage()->getVersion() == $operation->getTargetPackage()->getVersion()
  15884. ) {
  15885. continue;
  15886. }
  15887. $installsUpdates[] = $operation;
  15888. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15889. } elseif ($operation instanceof UninstallOperation) {
  15890. $uninstalls[] = $operation;
  15891. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  15892. }
  15893. }
  15894. $this->io->writeError(sprintf(
  15895. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  15896. count($installNames),
  15897. 1 === count($installNames) ? '' : 's',
  15898. count($updateNames),
  15899. 1 === count($updateNames) ? '' : 's',
  15900. count($uninstalls),
  15901. 1 === count($uninstalls) ? '' : 's'
  15902. ));
  15903. if ($installNames) {
  15904. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  15905. }
  15906. if ($updateNames) {
  15907. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  15908. }
  15909. if ($uninstalls) {
  15910. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  15911. }
  15912. }
  15913. $sortByName = function ($a, $b) {
  15914. if ($a instanceof UpdateOperation) {
  15915. $a = $a->getTargetPackage()->getName();
  15916. } else {
  15917. $a = $a->getPackage()->getName();
  15918. }
  15919. if ($b instanceof UpdateOperation) {
  15920. $b = $b->getTargetPackage()->getName();
  15921. } else {
  15922. $b = $b->getPackage()->getName();
  15923. }
  15924. return strcmp($a, $b);
  15925. };
  15926. usort($uninstalls, $sortByName);
  15927. usort($installsUpdates, $sortByName);
  15928. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  15929. if ($operation instanceof InstallOperation) {
  15930. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  15931. }
  15932. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  15933. $this->io->writeError(' - ' . $operation->show(true));
  15934. }
  15935. }
  15936. $updatedLock = $this->locker->setLockData(
  15937. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  15938. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  15939. $platformReqs,
  15940. $platformDevReqs,
  15941. $lockTransaction->getAliases($aliases),
  15942. $this->package->getMinimumStability(),
  15943. $this->package->getStabilityFlags(),
  15944. $this->preferStable || $this->package->getPreferStable(),
  15945. $this->preferLowest,
  15946. $this->config->get('platform') ?: array(),
  15947. $this->writeLock && $this->executeOperations
  15948. );
  15949. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  15950. $this->io->writeError('<info>Writing lock file</info>');
  15951. }
  15952. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  15953. $vendorDir = $this->config->get('vendor-dir');
  15954. if (is_dir($vendorDir)) {
  15955. @touch($vendorDir);
  15956. }
  15957. }
  15958. if ($doInstall) {
  15959. return $this->doInstall($localRepo, true);
  15960. }
  15961. return 0;
  15962. }
  15963. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null)
  15964. {
  15965. if (!$this->package->getDevRequires()) {
  15966. return 0;
  15967. }
  15968. $resultRepo = new ArrayRepository(array());
  15969. $loader = new ArrayLoader(null, true);
  15970. $dumper = new ArrayDumper();
  15971. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  15972. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  15973. }
  15974. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15975. $repositorySet->addRepository($resultRepo);
  15976. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  15977. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  15978. $pool = $repositorySet->createPoolWithAllPackages();
  15979. $solver = new Solver($policy, $pool, $this->io);
  15980. try {
  15981. $nonDevLockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15982. $solver = null;
  15983. } catch (SolverProblemsException $e) {
  15984. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  15985. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  15986. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15987. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  15988. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  15989. $this->io->writeError($prettyProblem);
  15990. $ghe = new GithubActionError($this->io);
  15991. $ghe->emit($err."\n".$prettyProblem);
  15992. return max(1, $e->getCode());
  15993. }
  15994. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  15995. return 0;
  15996. }
  15997. protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false)
  15998. {
  15999. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  16000. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  16001. if (!$alreadySolved) {
  16002. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  16003. $platformRepo = $this->createPlatformRepo(false);
  16004. $policy = $this->createPolicy(false);
  16005. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  16006. $repositorySet->addRepository($lockedRepository);
  16007. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  16008. if (!$this->locker->isFresh()) {
  16009. $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);
  16010. }
  16011. foreach ($lockedRepository->getPackages() as $package) {
  16012. $request->fixLockedPackage($package);
  16013. }
  16014. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  16015. $request->requireName($link->getTarget(), $link->getConstraint());
  16016. }
  16017. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  16018. $solver = new Solver($policy, $pool, $this->io);
  16019. try {
  16020. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  16021. $solver = null;
  16022. if (0 !== count($lockTransaction->getOperations())) {
  16023. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  16024. return 1;
  16025. }
  16026. } catch (SolverProblemsException $e) {
  16027. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  16028. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  16029. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  16030. $this->io->writeError($prettyProblem);
  16031. $ghe = new GithubActionError($this->io);
  16032. $ghe->emit($err."\n".$prettyProblem);
  16033. return max(1, $e->getCode());
  16034. }
  16035. }
  16036. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  16037. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  16038. if (!$localRepoTransaction->getOperations()) {
  16039. $this->io->writeError('Nothing to install, update or remove');
  16040. }
  16041. if ($localRepoTransaction->getOperations()) {
  16042. $installs = $updates = $uninstalls = array();
  16043. foreach ($localRepoTransaction->getOperations() as $operation) {
  16044. if ($operation instanceof InstallOperation) {
  16045. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  16046. } elseif ($operation instanceof UpdateOperation) {
  16047. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  16048. } elseif ($operation instanceof UninstallOperation) {
  16049. $uninstalls[] = $operation->getPackage()->getPrettyName();
  16050. }
  16051. }
  16052. $this->io->writeError(sprintf(
  16053. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  16054. count($installs),
  16055. 1 === count($installs) ? '' : 's',
  16056. count($updates),
  16057. 1 === count($updates) ? '' : 's',
  16058. count($uninstalls),
  16059. 1 === count($uninstalls) ? '' : 's'
  16060. ));
  16061. if ($installs) {
  16062. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  16063. }
  16064. if ($updates) {
  16065. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  16066. }
  16067. if ($uninstalls) {
  16068. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  16069. }
  16070. }
  16071. if ($this->executeOperations) {
  16072. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  16073. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  16074. } else {
  16075. foreach ($localRepoTransaction->getOperations() as $operation) {
  16076. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  16077. $this->io->writeError(' - ' . $operation->show(false));
  16078. }
  16079. }
  16080. }
  16081. return 0;
  16082. }
  16083. protected function createPlatformRepo($forUpdate)
  16084. {
  16085. if ($forUpdate) {
  16086. $platformOverrides = $this->config->get('platform') ?: array();
  16087. } else {
  16088. $platformOverrides = $this->locker->getPlatformOverrides();
  16089. }
  16090. return new PlatformRepository(array(), $platformOverrides);
  16091. }
  16092. private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
  16093. {
  16094. if ($forUpdate) {
  16095. $minimumStability = $this->package->getMinimumStability();
  16096. $stabilityFlags = $this->package->getStabilityFlags();
  16097. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  16098. } else {
  16099. $minimumStability = $this->locker->getMinimumStability();
  16100. $stabilityFlags = $this->locker->getStabilityFlags();
  16101. $requires = array();
  16102. foreach ($lockedRepository->getPackages() as $package) {
  16103. $constraint = new Constraint('=', $package->getVersion());
  16104. $constraint->setPrettyString($package->getPrettyVersion());
  16105. $requires[$package->getName()] = $constraint;
  16106. }
  16107. }
  16108. $rootRequires = array();
  16109. foreach ($requires as $req => $constraint) {
  16110. if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($req)) {
  16111. continue;
  16112. }
  16113. if ($constraint instanceof Link) {
  16114. $rootRequires[$req] = $constraint->getConstraint();
  16115. } else {
  16116. $rootRequires[$req] = $constraint;
  16117. }
  16118. }
  16119. $this->fixedRootPackage = clone $this->package;
  16120. $this->fixedRootPackage->setRequires(array());
  16121. $this->fixedRootPackage->setDevRequires(array());
  16122. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  16123. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  16124. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  16125. $repositorySet->addRepository($platformRepo);
  16126. if ($this->additionalFixedRepository) {
  16127. $additionalFixedRepositories = $this->additionalFixedRepository;
  16128. if ($additionalFixedRepositories instanceof CompositeRepository) {
  16129. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  16130. } else {
  16131. $additionalFixedRepositories = array($additionalFixedRepositories);
  16132. }
  16133. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  16134. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  16135. $repositorySet->allowInstalledRepositories();
  16136. break;
  16137. }
  16138. }
  16139. $repositorySet->addRepository($this->additionalFixedRepository);
  16140. }
  16141. return $repositorySet;
  16142. }
  16143. private function createPolicy($forUpdate)
  16144. {
  16145. $preferStable = null;
  16146. $preferLowest = null;
  16147. if (!$forUpdate) {
  16148. $preferStable = $this->locker->getPreferStable();
  16149. $preferLowest = $this->locker->getPreferLowest();
  16150. }
  16151. if (null === $preferStable) {
  16152. $preferStable = $this->preferStable || $this->package->getPreferStable();
  16153. }
  16154. if (null === $preferLowest) {
  16155. $preferLowest = $this->preferLowest;
  16156. }
  16157. return new DefaultPolicy($preferStable, $preferLowest);
  16158. }
  16159. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null)
  16160. {
  16161. $request = new Request($lockedRepository);
  16162. $request->fixPackage($rootPackage);
  16163. if ($rootPackage instanceof RootAliasPackage) {
  16164. $request->fixPackage($rootPackage->getAliasOf());
  16165. }
  16166. $fixedPackages = $platformRepo->getPackages();
  16167. if ($this->additionalFixedRepository) {
  16168. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  16169. }
  16170. $provided = $rootPackage->getProvides();
  16171. foreach ($fixedPackages as $package) {
  16172. if ($package->getRepository() !== $platformRepo
  16173. || !isset($provided[$package->getName()])
  16174. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  16175. ) {
  16176. $request->fixPackage($package);
  16177. }
  16178. }
  16179. return $request;
  16180. }
  16181. private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true)
  16182. {
  16183. if ($this->updateMirrors) {
  16184. $excludedPackages = array();
  16185. if (!$includeDevRequires) {
  16186. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  16187. }
  16188. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  16189. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  16190. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  16191. }
  16192. }
  16193. } else {
  16194. $links = $this->package->getRequires();
  16195. if ($includeDevRequires) {
  16196. $links = array_merge($links, $this->package->getDevRequires());
  16197. }
  16198. foreach ($links as $link) {
  16199. $request->requireName($link->getTarget(), $link->getConstraint());
  16200. }
  16201. }
  16202. }
  16203. private function getRootAliases($forUpdate)
  16204. {
  16205. if ($forUpdate) {
  16206. $aliases = $this->package->getAliases();
  16207. } else {
  16208. $aliases = $this->locker->getAliases();
  16209. }
  16210. return $aliases;
  16211. }
  16212. private function extractPlatformRequirements(array $links)
  16213. {
  16214. $platformReqs = array();
  16215. foreach ($links as $link) {
  16216. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  16217. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  16218. }
  16219. }
  16220. return $platformReqs;
  16221. }
  16222. private function mockLocalRepositories(RepositoryManager $rm)
  16223. {
  16224. $packages = array();
  16225. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  16226. $packages[(string) $package] = clone $package;
  16227. }
  16228. foreach ($packages as $key => $package) {
  16229. if ($package instanceof AliasPackage) {
  16230. $alias = (string) $package->getAliasOf();
  16231. $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  16232. }
  16233. }
  16234. $rm->setLocalRepository(
  16235. new InstalledArrayRepository($packages)
  16236. );
  16237. }
  16238. public static function create(IOInterface $io, Composer $composer)
  16239. {
  16240. return new static(
  16241. $io,
  16242. $composer->getConfig(),
  16243. $composer->getPackage(),
  16244. $composer->getDownloadManager(),
  16245. $composer->getRepositoryManager(),
  16246. $composer->getLocker(),
  16247. $composer->getInstallationManager(),
  16248. $composer->getEventDispatcher(),
  16249. $composer->getAutoloadGenerator()
  16250. );
  16251. }
  16252. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository)
  16253. {
  16254. $this->additionalFixedRepository = $additionalFixedRepository;
  16255. return $this;
  16256. }
  16257. public function setDryRun($dryRun = true)
  16258. {
  16259. $this->dryRun = (bool) $dryRun;
  16260. return $this;
  16261. }
  16262. public function isDryRun()
  16263. {
  16264. return $this->dryRun;
  16265. }
  16266. public function setPreferSource($preferSource = true)
  16267. {
  16268. $this->preferSource = (bool) $preferSource;
  16269. return $this;
  16270. }
  16271. public function setPreferDist($preferDist = true)
  16272. {
  16273. $this->preferDist = (bool) $preferDist;
  16274. return $this;
  16275. }
  16276. public function setOptimizeAutoloader($optimizeAutoloader)
  16277. {
  16278. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  16279. if (!$this->optimizeAutoloader) {
  16280. $this->setClassMapAuthoritative(false);
  16281. }
  16282. return $this;
  16283. }
  16284. public function setClassMapAuthoritative($classMapAuthoritative)
  16285. {
  16286. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  16287. if ($this->classMapAuthoritative) {
  16288. $this->setOptimizeAutoloader(true);
  16289. }
  16290. return $this;
  16291. }
  16292. public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
  16293. {
  16294. $this->apcuAutoloader = $apcuAutoloader;
  16295. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  16296. return $this;
  16297. }
  16298. public function setUpdate($update)
  16299. {
  16300. $this->update = (bool) $update;
  16301. return $this;
  16302. }
  16303. public function setInstall($install)
  16304. {
  16305. $this->install = (bool) $install;
  16306. return $this;
  16307. }
  16308. public function setDevMode($devMode = true)
  16309. {
  16310. $this->devMode = (bool) $devMode;
  16311. return $this;
  16312. }
  16313. public function setDumpAutoloader($dumpAutoloader = true)
  16314. {
  16315. $this->dumpAutoloader = (bool) $dumpAutoloader;
  16316. return $this;
  16317. }
  16318. public function setRunScripts($runScripts = true)
  16319. {
  16320. $this->runScripts = (bool) $runScripts;
  16321. return $this;
  16322. }
  16323. public function setConfig(Config $config)
  16324. {
  16325. $this->config = $config;
  16326. return $this;
  16327. }
  16328. public function setVerbose($verbose = true)
  16329. {
  16330. $this->verbose = (bool) $verbose;
  16331. return $this;
  16332. }
  16333. public function isVerbose()
  16334. {
  16335. return $this->verbose;
  16336. }
  16337. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  16338. {
  16339. if (is_array($ignorePlatformReqs)) {
  16340. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  16341. return PlatformRepository::isPlatformPackage($req);
  16342. });
  16343. } else {
  16344. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  16345. }
  16346. return $this;
  16347. }
  16348. public function setUpdateMirrors($updateMirrors)
  16349. {
  16350. $this->updateMirrors = $updateMirrors;
  16351. return $this;
  16352. }
  16353. public function setUpdateAllowList(array $packages)
  16354. {
  16355. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  16356. return $this;
  16357. }
  16358. public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  16359. {
  16360. 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)) {
  16361. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  16362. }
  16363. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  16364. return $this;
  16365. }
  16366. public function setPreferStable($preferStable = true)
  16367. {
  16368. $this->preferStable = (bool) $preferStable;
  16369. return $this;
  16370. }
  16371. public function setPreferLowest($preferLowest = true)
  16372. {
  16373. $this->preferLowest = (bool) $preferLowest;
  16374. return $this;
  16375. }
  16376. public function setWriteLock($writeLock = true)
  16377. {
  16378. $this->writeLock = (bool) $writeLock;
  16379. return $this;
  16380. }
  16381. public function setExecuteOperations($executeOperations = true)
  16382. {
  16383. $this->executeOperations = (bool) $executeOperations;
  16384. return $this;
  16385. }
  16386. public function disablePlugins()
  16387. {
  16388. $this->installationManager->disablePlugins();
  16389. return $this;
  16390. }
  16391. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  16392. {
  16393. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  16394. return $this;
  16395. }
  16396. }
  16397. <?php
  16398. namespace Composer\Installer;
  16399. use Composer\IO\IOInterface;
  16400. use Composer\Package\PackageInterface;
  16401. use Composer\Util\Filesystem;
  16402. use Composer\Util\Platform;
  16403. use Composer\Util\ProcessExecutor;
  16404. use Composer\Util\Silencer;
  16405. class BinaryInstaller
  16406. {
  16407. protected $binDir;
  16408. protected $binCompat;
  16409. protected $io;
  16410. protected $filesystem;
  16411. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
  16412. {
  16413. $this->binDir = $binDir;
  16414. $this->binCompat = $binCompat;
  16415. $this->io = $io;
  16416. $this->filesystem = $filesystem ?: new Filesystem();
  16417. }
  16418. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  16419. {
  16420. $binaries = $this->getBinaries($package);
  16421. if (!$binaries) {
  16422. return;
  16423. }
  16424. foreach ($binaries as $bin) {
  16425. $binPath = $installPath.'/'.$bin;
  16426. if (!file_exists($binPath)) {
  16427. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  16428. continue;
  16429. }
  16430. $binPath = realpath($binPath);
  16431. $this->initializeBinDir();
  16432. $link = $this->binDir.'/'.basename($bin);
  16433. if (file_exists($link)) {
  16434. if (is_link($link)) {
  16435. Silencer::call('chmod', $link, 0777 & ~umask());
  16436. }
  16437. if ($warnOnOverwrite) {
  16438. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  16439. }
  16440. continue;
  16441. }
  16442. if ($this->binCompat === "auto") {
  16443. if (Platform::isWindows()) {
  16444. $this->installFullBinaries($binPath, $link, $bin, $package);
  16445. } else {
  16446. $this->installSymlinkBinaries($binPath, $link);
  16447. }
  16448. } elseif ($this->binCompat === "full") {
  16449. $this->installFullBinaries($binPath, $link, $bin, $package);
  16450. }
  16451. Silencer::call('chmod', $link, 0777 & ~umask());
  16452. }
  16453. }
  16454. public function removeBinaries(PackageInterface $package)
  16455. {
  16456. $this->initializeBinDir();
  16457. $binaries = $this->getBinaries($package);
  16458. if (!$binaries) {
  16459. return;
  16460. }
  16461. foreach ($binaries as $bin) {
  16462. $link = $this->binDir.'/'.basename($bin);
  16463. if (is_link($link) || file_exists($link)) {
  16464. $this->filesystem->unlink($link);
  16465. }
  16466. if (file_exists($link.'.bat')) {
  16467. $this->filesystem->unlink($link.'.bat');
  16468. }
  16469. }
  16470. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  16471. Silencer::call('rmdir', $this->binDir);
  16472. }
  16473. }
  16474. public static function determineBinaryCaller($bin)
  16475. {
  16476. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  16477. return 'call';
  16478. }
  16479. $handle = fopen($bin, 'r');
  16480. $line = fgets($handle);
  16481. fclose($handle);
  16482. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  16483. return trim($match[1]);
  16484. }
  16485. return 'php';
  16486. }
  16487. protected function getBinaries(PackageInterface $package)
  16488. {
  16489. return $package->getBinaries();
  16490. }
  16491. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  16492. {
  16493. if ('.bat' !== substr($binPath, -4)) {
  16494. $this->installUnixyProxyBinaries($binPath, $link);
  16495. @chmod($link, 0777 & ~umask());
  16496. $link .= '.bat';
  16497. if (file_exists($link)) {
  16498. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  16499. }
  16500. }
  16501. if (!file_exists($link)) {
  16502. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  16503. }
  16504. }
  16505. protected function installSymlinkBinaries($binPath, $link)
  16506. {
  16507. if (!$this->filesystem->relativeSymlink($binPath, $link)) {
  16508. $this->installUnixyProxyBinaries($binPath, $link);
  16509. }
  16510. }
  16511. protected function installUnixyProxyBinaries($binPath, $link)
  16512. {
  16513. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  16514. }
  16515. protected function initializeBinDir()
  16516. {
  16517. $this->filesystem->ensureDirectoryExists($this->binDir);
  16518. $this->binDir = realpath($this->binDir);
  16519. }
  16520. protected function generateWindowsProxyCode($bin, $link)
  16521. {
  16522. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16523. $caller = self::determineBinaryCaller($bin);
  16524. return "@ECHO OFF\r\n".
  16525. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  16526. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  16527. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  16528. }
  16529. protected function generateUnixyProxyCode($bin, $link)
  16530. {
  16531. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16532. $binDir = ProcessExecutor::escape(dirname($binPath));
  16533. $binFile = basename($binPath);
  16534. $binContents = file_get_contents($bin);
  16535. if (preg_match('{^(?:#!(?:/usr)?/bin/env php|#!(?:/usr)?/bin/php|<?php)\r?\n}', $binContents, $match)) {
  16536. if (false === ($pos = strpos($binContents, '__HALT_COMPILER')) || false === strpos(substr($binContents, 0, $pos), 'Phar::mapPhar')) {
  16537. $proxyCode = trim($match[0]);
  16538. if ($proxyCode === "<?php") {
  16539. $proxyCode = "#!/usr/bin/env php";
  16540. }
  16541. $binPathExported = var_export($binPath, true);
  16542. return $proxyCode . "\n" . <<<PROXY
  16543. <?php
  16544. /**
  16545. * Proxy PHP file generated by Composer
  16546. *
  16547. * This file includes the referenced bin path ($binPath) using eval to remove the shebang if present
  16548. *
  16549. * @generated
  16550. */
  16551. \$binPath = realpath(__DIR__ . "/" . $binPathExported);
  16552. \$contents = file_get_contents(\$binPath);
  16553. \$contents = preg_replace('{^#!/.+\\r?\\n<\\?(php)?}', '', \$contents, 1, \$replaced);
  16554. if (\$replaced) {
  16555. \$contents = strtr(\$contents, array(
  16556. '__FILE__' => var_export(\$binPath, true),
  16557. '__DIR__' => var_export(dirname(\$binPath), true),
  16558. ));
  16559. eval(\$contents);
  16560. exit(0);
  16561. }
  16562. include \$binPath;
  16563. PROXY;
  16564. }
  16565. }
  16566. $proxyCode = <<<PROXY
  16567. #!/usr/bin/env sh
  16568. dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  16569. if [ -d /proc/cygdrive ]; then
  16570. case \$(which php) in
  16571. \$(readlink -n /proc/cygdrive)/*)
  16572. # We are in Cygwin using Windows php, so the path must be translated
  16573. dir=\$(cygpath -m "\$dir");
  16574. ;;
  16575. esac
  16576. fi
  16577. "\${dir}/$binFile" "\$@"
  16578. PROXY;
  16579. return $proxyCode;
  16580. }
  16581. }
  16582. <?php
  16583. namespace Composer\Installer;
  16584. use Composer\Package\PackageInterface;
  16585. interface BinaryPresenceInterface
  16586. {
  16587. public function ensureBinariesPresence(PackageInterface $package);
  16588. }
  16589. <?php
  16590. namespace Composer\Installer;
  16591. use Composer\IO\IOInterface;
  16592. use Composer\IO\ConsoleIO;
  16593. use Composer\Package\PackageInterface;
  16594. use Composer\Package\AliasPackage;
  16595. use Composer\Repository\RepositoryInterface;
  16596. use Composer\Repository\InstalledRepositoryInterface;
  16597. use Composer\DependencyResolver\Operation\OperationInterface;
  16598. use Composer\DependencyResolver\Operation\InstallOperation;
  16599. use Composer\DependencyResolver\Operation\UpdateOperation;
  16600. use Composer\DependencyResolver\Operation\UninstallOperation;
  16601. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  16602. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  16603. use Composer\EventDispatcher\EventDispatcher;
  16604. use Composer\Util\Loop;
  16605. use Composer\Util\Platform;
  16606. use React\Promise\PromiseInterface;
  16607. class InstallationManager
  16608. {
  16609. private $installers = array();
  16610. private $cache = array();
  16611. private $notifiablePackages = array();
  16612. private $loop;
  16613. private $io;
  16614. private $eventDispatcher;
  16615. private $outputProgress;
  16616. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  16617. {
  16618. $this->loop = $loop;
  16619. $this->io = $io;
  16620. $this->eventDispatcher = $eventDispatcher;
  16621. }
  16622. public function reset()
  16623. {
  16624. $this->notifiablePackages = array();
  16625. }
  16626. public function addInstaller(InstallerInterface $installer)
  16627. {
  16628. array_unshift($this->installers, $installer);
  16629. $this->cache = array();
  16630. }
  16631. public function removeInstaller(InstallerInterface $installer)
  16632. {
  16633. if (false !== ($key = array_search($installer, $this->installers, true))) {
  16634. array_splice($this->installers, $key, 1);
  16635. $this->cache = array();
  16636. }
  16637. }
  16638. public function disablePlugins()
  16639. {
  16640. foreach ($this->installers as $i => $installer) {
  16641. if (!$installer instanceof PluginInstaller) {
  16642. continue;
  16643. }
  16644. unset($this->installers[$i]);
  16645. }
  16646. }
  16647. public function getInstaller($type)
  16648. {
  16649. $type = strtolower($type);
  16650. if (isset($this->cache[$type])) {
  16651. return $this->cache[$type];
  16652. }
  16653. foreach ($this->installers as $installer) {
  16654. if ($installer->supports($type)) {
  16655. return $this->cache[$type] = $installer;
  16656. }
  16657. }
  16658. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  16659. }
  16660. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16661. {
  16662. if ($package instanceof AliasPackage) {
  16663. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  16664. }
  16665. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  16666. }
  16667. public function ensureBinariesPresence(PackageInterface $package)
  16668. {
  16669. try {
  16670. $installer = $this->getInstaller($package->getType());
  16671. } catch (\InvalidArgumentException $e) {
  16672. return;
  16673. }
  16674. if ($installer instanceof BinaryPresenceInterface) {
  16675. $installer->ensureBinariesPresence($package);
  16676. }
  16677. }
  16678. public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
  16679. {
  16680. $cleanupPromises = array();
  16681. $loop = $this->loop;
  16682. $io = $this->io;
  16683. $runCleanup = function () use (&$cleanupPromises, $loop) {
  16684. $promises = array();
  16685. $loop->abortJobs();
  16686. foreach ($cleanupPromises as $cleanup) {
  16687. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup) {
  16688. $promise = $cleanup();
  16689. if (!$promise instanceof PromiseInterface) {
  16690. $resolve();
  16691. } else {
  16692. $promise->then(function () use ($resolve) {
  16693. $resolve();
  16694. });
  16695. }
  16696. });
  16697. }
  16698. if (!empty($promises)) {
  16699. $loop->wait($promises);
  16700. }
  16701. };
  16702. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  16703. $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler') && PHP_SAPI === 'cli';
  16704. $prevHandler = null;
  16705. $windowsHandler = null;
  16706. if ($handleInterruptsUnix) {
  16707. pcntl_async_signals(true);
  16708. $prevHandler = pcntl_signal_get_handler(SIGINT);
  16709. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io) {
  16710. $io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);
  16711. $runCleanup();
  16712. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  16713. call_user_func($prevHandler, $sig);
  16714. }
  16715. exit(130);
  16716. });
  16717. }
  16718. if ($handleInterruptsWindows) {
  16719. $windowsHandler = function ($event) use ($runCleanup, $io) {
  16720. if ($event !== PHP_WINDOWS_EVENT_CTRL_C) {
  16721. return;
  16722. }
  16723. $io->writeError('Received CTRL+C, aborting', true, IOInterface::DEBUG);
  16724. $runCleanup();
  16725. exit(130);
  16726. };
  16727. sapi_windows_set_ctrl_handler($windowsHandler);
  16728. }
  16729. try {
  16730. $batches = array();
  16731. $batch = array();
  16732. foreach ($operations as $index => $operation) {
  16733. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16734. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16735. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  16736. if ($batch) {
  16737. $batches[] = $batch;
  16738. }
  16739. $batches[] = array($index => $operation);
  16740. $batch = array();
  16741. continue;
  16742. }
  16743. }
  16744. $batch[$index] = $operation;
  16745. }
  16746. if ($batch) {
  16747. $batches[] = $batch;
  16748. }
  16749. foreach ($batches as $batch) {
  16750. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  16751. }
  16752. } catch (\Exception $e) {
  16753. $runCleanup();
  16754. if ($handleInterruptsUnix) {
  16755. pcntl_signal(SIGINT, $prevHandler);
  16756. }
  16757. if ($handleInterruptsWindows) {
  16758. sapi_windows_set_ctrl_handler($prevHandler, false);
  16759. }
  16760. throw $e;
  16761. }
  16762. if ($handleInterruptsUnix) {
  16763. pcntl_signal(SIGINT, $prevHandler);
  16764. }
  16765. if ($handleInterruptsWindows) {
  16766. sapi_windows_set_ctrl_handler($prevHandler, false);
  16767. }
  16768. $repo->write($devMode, $this);
  16769. }
  16770. private function downloadAndExecuteBatch(RepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
  16771. {
  16772. $promises = array();
  16773. foreach ($operations as $index => $operation) {
  16774. $opType = $operation->getOperationType();
  16775. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16776. continue;
  16777. }
  16778. if ($opType === 'update') {
  16779. $package = $operation->getTargetPackage();
  16780. $initialPackage = $operation->getInitialPackage();
  16781. } else {
  16782. $package = $operation->getPackage();
  16783. $initialPackage = null;
  16784. }
  16785. $installer = $this->getInstaller($package->getType());
  16786. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  16787. if (!$package->getInstallationSource()) {
  16788. return;
  16789. }
  16790. return $installer->cleanup($opType, $package, $initialPackage);
  16791. };
  16792. if ($opType !== 'uninstall') {
  16793. $promise = $installer->download($package, $initialPackage);
  16794. if ($promise) {
  16795. $promises[] = $promise;
  16796. }
  16797. }
  16798. }
  16799. if (count($promises)) {
  16800. $this->waitOnPromises($promises);
  16801. }
  16802. $batches = array();
  16803. $batch = array();
  16804. foreach ($operations as $index => $operation) {
  16805. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16806. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16807. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  16808. if ($batch) {
  16809. $batches[] = $batch;
  16810. }
  16811. $batches[] = array($index => $operation);
  16812. $batch = array();
  16813. continue;
  16814. }
  16815. }
  16816. $batch[$index] = $operation;
  16817. }
  16818. if ($batch) {
  16819. $batches[] = $batch;
  16820. }
  16821. foreach ($batches as $batch) {
  16822. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  16823. }
  16824. }
  16825. private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
  16826. {
  16827. $promises = array();
  16828. $postExecCallbacks = array();
  16829. foreach ($operations as $index => $operation) {
  16830. $opType = $operation->getOperationType();
  16831. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16832. if ($this->io->isDebug()) {
  16833. $this->io->writeError(' - ' . $operation->show(false));
  16834. }
  16835. $this->$opType($repo, $operation);
  16836. continue;
  16837. }
  16838. if ($opType === 'update') {
  16839. $package = $operation->getTargetPackage();
  16840. $initialPackage = $operation->getInitialPackage();
  16841. } else {
  16842. $package = $operation->getPackage();
  16843. $initialPackage = null;
  16844. }
  16845. $installer = $this->getInstaller($package->getType());
  16846. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  16847. if (defined($event) && $runScripts && $this->eventDispatcher) {
  16848. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16849. }
  16850. $dispatcher = $this->eventDispatcher;
  16851. $installManager = $this;
  16852. $io = $this->io;
  16853. $promise = $installer->prepare($opType, $package, $initialPackage);
  16854. if (!$promise instanceof PromiseInterface) {
  16855. $promise = \React\Promise\resolve();
  16856. }
  16857. $promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
  16858. return $installManager->$opType($repo, $operation);
  16859. })->then($cleanupPromises[$index])
  16860. ->then(function () use ($installManager, $devMode, $repo) {
  16861. $repo->write($devMode, $installManager);
  16862. }, function ($e) use ($opType, $package, $io) {
  16863. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  16864. throw $e;
  16865. });
  16866. $postExecCallbacks[] = function () use ($opType, $runScripts, $dispatcher, $devMode, $repo, $allOperations, $operation) {
  16867. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  16868. if (defined($event) && $runScripts && $dispatcher) {
  16869. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16870. }
  16871. };
  16872. $promises[] = $promise;
  16873. }
  16874. if (count($promises)) {
  16875. $this->waitOnPromises($promises);
  16876. }
  16877. Platform::workaroundFilesystemIssues();
  16878. foreach ($postExecCallbacks as $cb) {
  16879. $cb();
  16880. }
  16881. }
  16882. private function waitOnPromises(array $promises)
  16883. {
  16884. $progress = null;
  16885. if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
  16886. $progress = $this->io->getProgressBar();
  16887. }
  16888. $this->loop->wait($promises, $progress);
  16889. if ($progress) {
  16890. $progress->clear();
  16891. }
  16892. }
  16893. public function install(RepositoryInterface $repo, InstallOperation $operation)
  16894. {
  16895. $package = $operation->getPackage();
  16896. $installer = $this->getInstaller($package->getType());
  16897. $promise = $installer->install($repo, $package);
  16898. $this->markForNotification($package);
  16899. return $promise;
  16900. }
  16901. public function update(RepositoryInterface $repo, UpdateOperation $operation)
  16902. {
  16903. $initial = $operation->getInitialPackage();
  16904. $target = $operation->getTargetPackage();
  16905. $initialType = $initial->getType();
  16906. $targetType = $target->getType();
  16907. if ($initialType === $targetType) {
  16908. $installer = $this->getInstaller($initialType);
  16909. $promise = $installer->update($repo, $initial, $target);
  16910. $this->markForNotification($target);
  16911. } else {
  16912. $promise = $this->getInstaller($initialType)->uninstall($repo, $initial);
  16913. if (!$promise instanceof PromiseInterface) {
  16914. $promise = \React\Promise\resolve();
  16915. }
  16916. $installer = $this->getInstaller($targetType);
  16917. $promise->then(function () use ($installer, $repo, $target) {
  16918. return $installer->install($repo, $target);
  16919. });
  16920. }
  16921. return $promise;
  16922. }
  16923. public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
  16924. {
  16925. $package = $operation->getPackage();
  16926. $installer = $this->getInstaller($package->getType());
  16927. return $installer->uninstall($repo, $package);
  16928. }
  16929. public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  16930. {
  16931. $package = $operation->getPackage();
  16932. if (!$repo->hasPackage($package)) {
  16933. $repo->addPackage(clone $package);
  16934. }
  16935. }
  16936. public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  16937. {
  16938. $package = $operation->getPackage();
  16939. $repo->removePackage($package);
  16940. }
  16941. public function getInstallPath(PackageInterface $package)
  16942. {
  16943. $installer = $this->getInstaller($package->getType());
  16944. return $installer->getInstallPath($package);
  16945. }
  16946. public function setOutputProgress($outputProgress)
  16947. {
  16948. $this->outputProgress = $outputProgress;
  16949. }
  16950. public function notifyInstalls(IOInterface $io)
  16951. {
  16952. $promises = array();
  16953. try {
  16954. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  16955. if (strpos($repoUrl, '%package%')) {
  16956. foreach ($packages as $package) {
  16957. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  16958. $params = array(
  16959. 'version' => $package->getPrettyVersion(),
  16960. 'version_normalized' => $package->getVersion(),
  16961. );
  16962. $opts = array(
  16963. 'retry-auth-failure' => false,
  16964. 'http' => array(
  16965. 'method' => 'POST',
  16966. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  16967. 'content' => http_build_query($params, '', '&'),
  16968. 'timeout' => 3,
  16969. ),
  16970. );
  16971. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  16972. }
  16973. continue;
  16974. }
  16975. $postData = array('downloads' => array());
  16976. foreach ($packages as $package) {
  16977. $postData['downloads'][] = array(
  16978. 'name' => $package->getPrettyName(),
  16979. 'version' => $package->getVersion(),
  16980. );
  16981. }
  16982. $opts = array(
  16983. 'retry-auth-failure' => false,
  16984. 'http' => array(
  16985. 'method' => 'POST',
  16986. 'header' => array('Content-Type: application/json'),
  16987. 'content' => json_encode($postData),
  16988. 'timeout' => 6,
  16989. ),
  16990. );
  16991. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  16992. }
  16993. $this->loop->wait($promises);
  16994. } catch (\Exception $e) {
  16995. }
  16996. $this->reset();
  16997. }
  16998. private function markForNotification(PackageInterface $package)
  16999. {
  17000. if ($package->getNotificationUrl()) {
  17001. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  17002. }
  17003. }
  17004. }
  17005. <?php
  17006. namespace Composer\Installer;
  17007. use Composer\Composer;
  17008. use Composer\DependencyResolver\Transaction;
  17009. use Composer\EventDispatcher\Event;
  17010. use Composer\IO\IOInterface;
  17011. class InstallerEvent extends Event
  17012. {
  17013. private $composer;
  17014. private $io;
  17015. private $devMode;
  17016. private $executeOperations;
  17017. private $transaction;
  17018. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
  17019. {
  17020. parent::__construct($eventName);
  17021. $this->composer = $composer;
  17022. $this->io = $io;
  17023. $this->devMode = $devMode;
  17024. $this->executeOperations = $executeOperations;
  17025. $this->transaction = $transaction;
  17026. }
  17027. public function getComposer()
  17028. {
  17029. return $this->composer;
  17030. }
  17031. public function getIO()
  17032. {
  17033. return $this->io;
  17034. }
  17035. public function isDevMode()
  17036. {
  17037. return $this->devMode;
  17038. }
  17039. public function isExecutingOperations()
  17040. {
  17041. return $this->executeOperations;
  17042. }
  17043. public function getTransaction()
  17044. {
  17045. return $this->transaction;
  17046. }
  17047. }
  17048. <?php
  17049. namespace Composer\Installer;
  17050. class InstallerEvents
  17051. {
  17052. const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  17053. }
  17054. <?php
  17055. namespace Composer\Installer;
  17056. use Composer\Package\PackageInterface;
  17057. use Composer\Repository\InstalledRepositoryInterface;
  17058. use InvalidArgumentException;
  17059. use React\Promise\PromiseInterface;
  17060. interface InstallerInterface
  17061. {
  17062. public function supports($packageType);
  17063. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  17064. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  17065. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
  17066. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  17067. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  17068. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  17069. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
  17070. public function getInstallPath(PackageInterface $package);
  17071. }
  17072. <?php
  17073. namespace Composer\Installer;
  17074. use Composer\Composer;
  17075. use Composer\IO\IOInterface;
  17076. use Composer\Repository\InstalledRepositoryInterface;
  17077. use Composer\Package\PackageInterface;
  17078. use Composer\Util\Filesystem;
  17079. use Composer\Util\Silencer;
  17080. use Composer\Util\Platform;
  17081. use React\Promise\PromiseInterface;
  17082. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  17083. {
  17084. protected $composer;
  17085. protected $vendorDir;
  17086. protected $binDir;
  17087. protected $downloadManager;
  17088. protected $io;
  17089. protected $type;
  17090. protected $filesystem;
  17091. protected $binCompat;
  17092. protected $binaryInstaller;
  17093. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  17094. {
  17095. $this->composer = $composer;
  17096. $this->downloadManager = $composer->getDownloadManager();
  17097. $this->io = $io;
  17098. $this->type = $type;
  17099. $this->filesystem = $filesystem ?: new Filesystem();
  17100. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  17101. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
  17102. }
  17103. public function supports($packageType)
  17104. {
  17105. return $packageType === $this->type || null === $this->type;
  17106. }
  17107. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17108. {
  17109. if (!$repo->hasPackage($package)) {
  17110. return false;
  17111. }
  17112. $installPath = $this->getInstallPath($package);
  17113. if (is_readable($installPath)) {
  17114. return true;
  17115. }
  17116. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  17117. }
  17118. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17119. {
  17120. $this->initializeVendorDir();
  17121. $downloadPath = $this->getInstallPath($package);
  17122. return $this->downloadManager->download($package, $downloadPath, $prevPackage);
  17123. }
  17124. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17125. {
  17126. $this->initializeVendorDir();
  17127. $downloadPath = $this->getInstallPath($package);
  17128. return $this->downloadManager->prepare($type, $package, $downloadPath, $prevPackage);
  17129. }
  17130. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17131. {
  17132. $this->initializeVendorDir();
  17133. $downloadPath = $this->getInstallPath($package);
  17134. return $this->downloadManager->cleanup($type, $package, $downloadPath, $prevPackage);
  17135. }
  17136. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17137. {
  17138. $this->initializeVendorDir();
  17139. $downloadPath = $this->getInstallPath($package);
  17140. if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
  17141. $this->binaryInstaller->removeBinaries($package);
  17142. }
  17143. $promise = $this->installCode($package);
  17144. if (!$promise instanceof PromiseInterface) {
  17145. $promise = \React\Promise\resolve();
  17146. }
  17147. $binaryInstaller = $this->binaryInstaller;
  17148. $installPath = $this->getInstallPath($package);
  17149. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
  17150. $binaryInstaller->installBinaries($package, $installPath);
  17151. if (!$repo->hasPackage($package)) {
  17152. $repo->addPackage(clone $package);
  17153. }
  17154. });
  17155. }
  17156. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17157. {
  17158. if (!$repo->hasPackage($initial)) {
  17159. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17160. }
  17161. $this->initializeVendorDir();
  17162. $this->binaryInstaller->removeBinaries($initial);
  17163. $promise = $this->updateCode($initial, $target);
  17164. if (!$promise instanceof PromiseInterface) {
  17165. $promise = \React\Promise\resolve();
  17166. }
  17167. $binaryInstaller = $this->binaryInstaller;
  17168. $installPath = $this->getInstallPath($target);
  17169. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
  17170. $binaryInstaller->installBinaries($target, $installPath);
  17171. $repo->removePackage($initial);
  17172. if (!$repo->hasPackage($target)) {
  17173. $repo->addPackage(clone $target);
  17174. }
  17175. });
  17176. }
  17177. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17178. {
  17179. if (!$repo->hasPackage($package)) {
  17180. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17181. }
  17182. $promise = $this->removeCode($package);
  17183. if (!$promise instanceof PromiseInterface) {
  17184. $promise = \React\Promise\resolve();
  17185. }
  17186. $binaryInstaller = $this->binaryInstaller;
  17187. $downloadPath = $this->getPackageBasePath($package);
  17188. $filesystem = $this->filesystem;
  17189. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
  17190. $binaryInstaller->removeBinaries($package);
  17191. $repo->removePackage($package);
  17192. if (strpos($package->getName(), '/')) {
  17193. $packageVendorDir = dirname($downloadPath);
  17194. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  17195. Silencer::call('rmdir', $packageVendorDir);
  17196. }
  17197. }
  17198. });
  17199. }
  17200. public function getInstallPath(PackageInterface $package)
  17201. {
  17202. $this->initializeVendorDir();
  17203. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  17204. $targetDir = $package->getTargetDir();
  17205. return $basePath . ($targetDir ? '/'.$targetDir : '');
  17206. }
  17207. public function ensureBinariesPresence(PackageInterface $package)
  17208. {
  17209. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  17210. }
  17211. protected function getPackageBasePath(PackageInterface $package)
  17212. {
  17213. $installPath = $this->getInstallPath($package);
  17214. $targetDir = $package->getTargetDir();
  17215. if ($targetDir) {
  17216. return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  17217. }
  17218. return $installPath;
  17219. }
  17220. protected function installCode(PackageInterface $package)
  17221. {
  17222. $downloadPath = $this->getInstallPath($package);
  17223. return $this->downloadManager->install($package, $downloadPath);
  17224. }
  17225. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  17226. {
  17227. $initialDownloadPath = $this->getInstallPath($initial);
  17228. $targetDownloadPath = $this->getInstallPath($target);
  17229. if ($targetDownloadPath !== $initialDownloadPath) {
  17230. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  17231. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  17232. ) {
  17233. $promise = $this->removeCode($initial);
  17234. if (!$promise instanceof PromiseInterface) {
  17235. $promise = \React\Promise\resolve();
  17236. }
  17237. $self = $this;
  17238. return $promise->then(function () use ($self, $target) {
  17239. $reflMethod = new \ReflectionMethod($self, 'installCode');
  17240. $reflMethod->setAccessible(true);
  17241. return $reflMethod->invoke($self, $target);
  17242. });
  17243. }
  17244. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  17245. }
  17246. return $this->downloadManager->update($initial, $target, $targetDownloadPath);
  17247. }
  17248. protected function removeCode(PackageInterface $package)
  17249. {
  17250. $downloadPath = $this->getPackageBasePath($package);
  17251. return $this->downloadManager->remove($package, $downloadPath);
  17252. }
  17253. protected function initializeVendorDir()
  17254. {
  17255. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  17256. $this->vendorDir = realpath($this->vendorDir);
  17257. }
  17258. }
  17259. <?php
  17260. namespace Composer\Installer;
  17261. use Composer\Repository\InstalledRepositoryInterface;
  17262. use Composer\Package\PackageInterface;
  17263. use Composer\IO\IOInterface;
  17264. use Composer\DependencyResolver\Operation\UpdateOperation;
  17265. use Composer\DependencyResolver\Operation\InstallOperation;
  17266. use Composer\DependencyResolver\Operation\UninstallOperation;
  17267. class MetapackageInstaller implements InstallerInterface
  17268. {
  17269. private $io;
  17270. public function __construct(IOInterface $io)
  17271. {
  17272. $this->io = $io;
  17273. }
  17274. public function supports($packageType)
  17275. {
  17276. return $packageType === 'metapackage';
  17277. }
  17278. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17279. {
  17280. return $repo->hasPackage($package);
  17281. }
  17282. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17283. {
  17284. }
  17285. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17286. {
  17287. }
  17288. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17289. {
  17290. }
  17291. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17292. {
  17293. $this->io->writeError(" - " . InstallOperation::format($package));
  17294. $repo->addPackage(clone $package);
  17295. }
  17296. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17297. {
  17298. if (!$repo->hasPackage($initial)) {
  17299. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17300. }
  17301. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  17302. $repo->removePackage($initial);
  17303. $repo->addPackage(clone $target);
  17304. }
  17305. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17306. {
  17307. if (!$repo->hasPackage($package)) {
  17308. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17309. }
  17310. $this->io->writeError(" - " . UninstallOperation::format($package));
  17311. $repo->removePackage($package);
  17312. }
  17313. public function getInstallPath(PackageInterface $package)
  17314. {
  17315. return '';
  17316. }
  17317. }
  17318. <?php
  17319. namespace Composer\Installer;
  17320. use Composer\Repository\InstalledRepositoryInterface;
  17321. use Composer\Package\PackageInterface;
  17322. class NoopInstaller implements InstallerInterface
  17323. {
  17324. public function supports($packageType)
  17325. {
  17326. return true;
  17327. }
  17328. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17329. {
  17330. return $repo->hasPackage($package);
  17331. }
  17332. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17333. {
  17334. }
  17335. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17336. {
  17337. }
  17338. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17339. {
  17340. }
  17341. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17342. {
  17343. if (!$repo->hasPackage($package)) {
  17344. $repo->addPackage(clone $package);
  17345. }
  17346. }
  17347. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17348. {
  17349. if (!$repo->hasPackage($initial)) {
  17350. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17351. }
  17352. $repo->removePackage($initial);
  17353. if (!$repo->hasPackage($target)) {
  17354. $repo->addPackage(clone $target);
  17355. }
  17356. }
  17357. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17358. {
  17359. if (!$repo->hasPackage($package)) {
  17360. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17361. }
  17362. $repo->removePackage($package);
  17363. }
  17364. public function getInstallPath(PackageInterface $package)
  17365. {
  17366. $targetDir = $package->getTargetDir();
  17367. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  17368. }
  17369. }
  17370. <?php
  17371. namespace Composer\Installer;
  17372. use Composer\Composer;
  17373. use Composer\IO\IOInterface;
  17374. use Composer\DependencyResolver\Operation\OperationInterface;
  17375. use Composer\Repository\RepositoryInterface;
  17376. use Composer\EventDispatcher\Event;
  17377. class PackageEvent extends Event
  17378. {
  17379. private $composer;
  17380. private $io;
  17381. private $devMode;
  17382. private $localRepo;
  17383. private $operations;
  17384. private $operation;
  17385. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  17386. {
  17387. parent::__construct($eventName);
  17388. $this->composer = $composer;
  17389. $this->io = $io;
  17390. $this->devMode = $devMode;
  17391. $this->localRepo = $localRepo;
  17392. $this->operations = $operations;
  17393. $this->operation = $operation;
  17394. }
  17395. public function getComposer()
  17396. {
  17397. return $this->composer;
  17398. }
  17399. public function getIO()
  17400. {
  17401. return $this->io;
  17402. }
  17403. public function isDevMode()
  17404. {
  17405. return $this->devMode;
  17406. }
  17407. public function getLocalRepo()
  17408. {
  17409. return $this->localRepo;
  17410. }
  17411. public function getOperations()
  17412. {
  17413. return $this->operations;
  17414. }
  17415. public function getOperation()
  17416. {
  17417. return $this->operation;
  17418. }
  17419. }
  17420. <?php
  17421. namespace Composer\Installer;
  17422. class PackageEvents
  17423. {
  17424. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  17425. const POST_PACKAGE_INSTALL = 'post-package-install';
  17426. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  17427. const POST_PACKAGE_UPDATE = 'post-package-update';
  17428. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  17429. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  17430. }
  17431. <?php
  17432. namespace Composer\Installer;
  17433. use Composer\Composer;
  17434. use Composer\IO\IOInterface;
  17435. use Composer\Repository\InstalledRepositoryInterface;
  17436. use Composer\Package\PackageInterface;
  17437. use Composer\Util\Filesystem;
  17438. use Composer\Installer\InstallationManager;
  17439. use Composer\Util\Platform;
  17440. use React\Promise\PromiseInterface;
  17441. class PluginInstaller extends LibraryInstaller
  17442. {
  17443. public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  17444. {
  17445. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  17446. }
  17447. public function supports($packageType)
  17448. {
  17449. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  17450. }
  17451. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17452. {
  17453. $extra = $package->getExtra();
  17454. if (empty($extra['class'])) {
  17455. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  17456. }
  17457. return parent::download($package, $prevPackage);
  17458. }
  17459. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17460. {
  17461. $promise = parent::install($repo, $package);
  17462. if (!$promise instanceof PromiseInterface) {
  17463. $promise = \React\Promise\resolve();
  17464. }
  17465. $pluginManager = $this->composer->getPluginManager();
  17466. $self = $this;
  17467. return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
  17468. try {
  17469. Platform::workaroundFilesystemIssues();
  17470. $pluginManager->registerPackage($package, true);
  17471. } catch (\Exception $e) {
  17472. $self->rollbackInstall($e, $repo, $package);
  17473. }
  17474. });
  17475. }
  17476. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17477. {
  17478. $promise = parent::update($repo, $initial, $target);
  17479. if (!$promise instanceof PromiseInterface) {
  17480. $promise = \React\Promise\resolve();
  17481. }
  17482. $pluginManager = $this->composer->getPluginManager();
  17483. $self = $this;
  17484. return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
  17485. try {
  17486. Platform::workaroundFilesystemIssues();
  17487. $pluginManager->deactivatePackage($initial, true);
  17488. $pluginManager->registerPackage($target, true);
  17489. } catch (\Exception $e) {
  17490. $self->rollbackInstall($e, $repo, $target);
  17491. }
  17492. });
  17493. }
  17494. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17495. {
  17496. $this->composer->getPluginManager()->uninstallPackage($package, true);
  17497. return parent::uninstall($repo, $package);
  17498. }
  17499. public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
  17500. {
  17501. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  17502. parent::uninstall($repo, $package);
  17503. throw $e;
  17504. }
  17505. }
  17506. <?php
  17507. namespace Composer\Installer;
  17508. use Composer\Package\PackageInterface;
  17509. use Composer\Downloader\DownloadManager;
  17510. use Composer\Repository\InstalledRepositoryInterface;
  17511. use Composer\Util\Filesystem;
  17512. class ProjectInstaller implements InstallerInterface
  17513. {
  17514. private $installPath;
  17515. private $downloadManager;
  17516. private $filesystem;
  17517. public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
  17518. {
  17519. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  17520. $this->downloadManager = $dm;
  17521. $this->filesystem = $fs;
  17522. }
  17523. public function supports($packageType)
  17524. {
  17525. return true;
  17526. }
  17527. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17528. {
  17529. return false;
  17530. }
  17531. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17532. {
  17533. $installPath = $this->installPath;
  17534. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  17535. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  17536. }
  17537. if (!is_dir($installPath)) {
  17538. mkdir($installPath, 0777, true);
  17539. }
  17540. return $this->downloadManager->download($package, $installPath, $prevPackage);
  17541. }
  17542. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17543. {
  17544. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  17545. }
  17546. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17547. {
  17548. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  17549. }
  17550. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17551. {
  17552. return $this->downloadManager->install($package, $this->installPath);
  17553. }
  17554. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17555. {
  17556. throw new \InvalidArgumentException("not supported");
  17557. }
  17558. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17559. {
  17560. throw new \InvalidArgumentException("not supported");
  17561. }
  17562. public function getInstallPath(PackageInterface $package)
  17563. {
  17564. return $this->installPath;
  17565. }
  17566. }
  17567. <?php
  17568. namespace Composer\Installer;
  17569. use Composer\IO\IOInterface;
  17570. use Composer\Package\PackageInterface;
  17571. use Composer\Repository\InstalledRepository;
  17572. use Symfony\Component\Console\Formatter\OutputFormatter;
  17573. class SuggestedPackagesReporter
  17574. {
  17575. const MODE_LIST = 1;
  17576. const MODE_BY_PACKAGE = 2;
  17577. const MODE_BY_SUGGESTION = 4;
  17578. protected $suggestedPackages = array();
  17579. private $io;
  17580. public function __construct(IOInterface $io)
  17581. {
  17582. $this->io = $io;
  17583. }
  17584. public function getPackages()
  17585. {
  17586. return $this->suggestedPackages;
  17587. }
  17588. public function addPackage($source, $target, $reason)
  17589. {
  17590. $this->suggestedPackages[] = array(
  17591. 'source' => $source,
  17592. 'target' => $target,
  17593. 'reason' => $reason,
  17594. );
  17595. return $this;
  17596. }
  17597. public function addSuggestionsFromPackage(PackageInterface $package)
  17598. {
  17599. $source = $package->getPrettyName();
  17600. foreach ($package->getSuggests() as $target => $reason) {
  17601. $this->addPackage(
  17602. $source,
  17603. $target,
  17604. $reason
  17605. );
  17606. }
  17607. return $this;
  17608. }
  17609. public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17610. {
  17611. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17612. $suggesters = array();
  17613. $suggested = array();
  17614. foreach ($suggestedPackages as $suggestion) {
  17615. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  17616. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  17617. }
  17618. ksort($suggesters);
  17619. ksort($suggested);
  17620. if ($mode & self::MODE_LIST) {
  17621. foreach (array_keys($suggested) as $name) {
  17622. $this->io->write(sprintf('<info>%s</info>', $name));
  17623. }
  17624. return 0;
  17625. }
  17626. if ($mode & self::MODE_BY_PACKAGE) {
  17627. foreach ($suggesters as $suggester => $suggestions) {
  17628. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  17629. foreach ($suggestions as $suggestion => $reason) {
  17630. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  17631. }
  17632. $this->io->write('');
  17633. }
  17634. }
  17635. if ($mode & self::MODE_BY_SUGGESTION) {
  17636. if ($mode & self::MODE_BY_PACKAGE) {
  17637. $this->io->write(str_repeat('-', 78));
  17638. }
  17639. foreach ($suggested as $suggestion => $suggesters) {
  17640. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  17641. foreach ($suggesters as $suggester => $reason) {
  17642. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  17643. }
  17644. $this->io->write('');
  17645. }
  17646. }
  17647. if ($onlyDependentsOf) {
  17648. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  17649. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  17650. if ($diff) {
  17651. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  17652. }
  17653. }
  17654. return $this;
  17655. }
  17656. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17657. {
  17658. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17659. if ($suggestedPackages) {
  17660. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  17661. }
  17662. return $this;
  17663. }
  17664. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17665. {
  17666. $suggestedPackages = $this->getPackages();
  17667. $installedNames = array();
  17668. if (null !== $installedRepo && !empty($suggestedPackages)) {
  17669. foreach ($installedRepo->getPackages() as $package) {
  17670. $installedNames = array_merge(
  17671. $installedNames,
  17672. $package->getNames()
  17673. );
  17674. }
  17675. }
  17676. $sourceFilter = array();
  17677. if ($onlyDependentsOf) {
  17678. $sourceFilter = array_map(function ($link) {
  17679. return $link->getTarget();
  17680. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  17681. $sourceFilter[] = $onlyDependentsOf->getName();
  17682. }
  17683. $suggestions = array();
  17684. foreach ($suggestedPackages as $suggestion) {
  17685. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  17686. continue;
  17687. }
  17688. $suggestions[] = $suggestion;
  17689. }
  17690. return $suggestions;
  17691. }
  17692. private function escapeOutput($string)
  17693. {
  17694. return OutputFormatter::escape(
  17695. $this->removeControlCharacters($string)
  17696. );
  17697. }
  17698. private function removeControlCharacters($string)
  17699. {
  17700. return preg_replace(
  17701. '/[[:cntrl:]]/',
  17702. '',
  17703. str_replace("\n", ' ', $string)
  17704. );
  17705. }
  17706. }
  17707. <?php
  17708. namespace Composer\Json;
  17709. use JsonSchema\Validator;
  17710. use Seld\JsonLint\JsonParser;
  17711. use Seld\JsonLint\ParsingException;
  17712. use Composer\Util\HttpDownloader;
  17713. use Composer\IO\IOInterface;
  17714. use Composer\Downloader\TransportException;
  17715. class JsonFile
  17716. {
  17717. const LAX_SCHEMA = 1;
  17718. const STRICT_SCHEMA = 2;
  17719. const JSON_UNESCAPED_SLASHES = 64;
  17720. const JSON_PRETTY_PRINT = 128;
  17721. const JSON_UNESCAPED_UNICODE = 256;
  17722. const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
  17723. private $path;
  17724. private $httpDownloader;
  17725. private $io;
  17726. public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  17727. {
  17728. $this->path = $path;
  17729. if (null === $httpDownloader && preg_match('{^https?://}i', $path)) {
  17730. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  17731. }
  17732. $this->httpDownloader = $httpDownloader;
  17733. $this->io = $io;
  17734. }
  17735. public function getPath()
  17736. {
  17737. return $this->path;
  17738. }
  17739. public function exists()
  17740. {
  17741. return is_file($this->path);
  17742. }
  17743. public function read()
  17744. {
  17745. try {
  17746. if ($this->httpDownloader) {
  17747. $json = $this->httpDownloader->get($this->path)->getBody();
  17748. } else {
  17749. if ($this->io && $this->io->isDebug()) {
  17750. $realpathInfo = '';
  17751. $realpath = realpath($this->path);
  17752. if (false !== $realpath && $realpath !== $this->path) {
  17753. $realpathInfo = ' (' . $realpath . ')';
  17754. }
  17755. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  17756. }
  17757. $json = file_get_contents($this->path);
  17758. }
  17759. } catch (TransportException $e) {
  17760. throw new \RuntimeException($e->getMessage(), 0, $e);
  17761. } catch (\Exception $e) {
  17762. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  17763. }
  17764. return static::parseJson($json, $this->path);
  17765. }
  17766. public function write(array $hash, $options = 448)
  17767. {
  17768. if ($this->path === 'php://memory') {
  17769. file_put_contents($this->path, static::encode($hash, $options));
  17770. return;
  17771. }
  17772. $dir = dirname($this->path);
  17773. if (!is_dir($dir)) {
  17774. if (file_exists($dir)) {
  17775. throw new \UnexpectedValueException(
  17776. realpath($dir).' exists and is not a directory.'
  17777. );
  17778. }
  17779. if (!@mkdir($dir, 0777, true)) {
  17780. throw new \UnexpectedValueException(
  17781. $dir.' does not exist and could not be created.'
  17782. );
  17783. }
  17784. }
  17785. $retries = 3;
  17786. while ($retries--) {
  17787. try {
  17788. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  17789. break;
  17790. } catch (\Exception $e) {
  17791. if ($retries) {
  17792. usleep(500000);
  17793. continue;
  17794. }
  17795. throw $e;
  17796. }
  17797. }
  17798. }
  17799. private function filePutContentsIfModified($path, $content)
  17800. {
  17801. $currentContent = @file_get_contents($path);
  17802. if (!$currentContent || ($currentContent != $content)) {
  17803. return file_put_contents($path, $content);
  17804. }
  17805. return 0;
  17806. }
  17807. public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
  17808. {
  17809. $content = file_get_contents($this->path);
  17810. $data = json_decode($content);
  17811. if (null === $data && 'null' !== $content) {
  17812. self::validateSyntax($content, $this->path);
  17813. }
  17814. if (null === $schemaFile) {
  17815. $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
  17816. }
  17817. if (false === strpos($schemaFile, '://')) {
  17818. $schemaFile = 'file://' . $schemaFile;
  17819. }
  17820. $schemaData = (object) array('$ref' => $schemaFile);
  17821. if ($schema === self::LAX_SCHEMA) {
  17822. $schemaData->additionalProperties = true;
  17823. $schemaData->required = array();
  17824. }
  17825. $validator = new Validator();
  17826. $validator->check($data, $schemaData);
  17827. if (!$validator->isValid()) {
  17828. $errors = array();
  17829. foreach ((array) $validator->getErrors() as $error) {
  17830. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  17831. }
  17832. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  17833. }
  17834. return true;
  17835. }
  17836. public static function encode($data, $options = 448)
  17837. {
  17838. if (PHP_VERSION_ID >= 50400) {
  17839. $json = json_encode($data, $options);
  17840. if (false === $json) {
  17841. self::throwEncodeError(json_last_error());
  17842. }
  17843. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  17844. $json = preg_replace('/\[\s+\]/', '[]', $json);
  17845. $json = preg_replace('/\{\s+\}/', '{}', $json);
  17846. }
  17847. return $json;
  17848. }
  17849. $json = json_encode($data);
  17850. if (false === $json) {
  17851. self::throwEncodeError(json_last_error());
  17852. }
  17853. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  17854. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  17855. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  17856. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  17857. return $json;
  17858. }
  17859. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  17860. }
  17861. private static function throwEncodeError($code)
  17862. {
  17863. switch ($code) {
  17864. case JSON_ERROR_DEPTH:
  17865. $msg = 'Maximum stack depth exceeded';
  17866. break;
  17867. case JSON_ERROR_STATE_MISMATCH:
  17868. $msg = 'Underflow or the modes mismatch';
  17869. break;
  17870. case JSON_ERROR_CTRL_CHAR:
  17871. $msg = 'Unexpected control character found';
  17872. break;
  17873. case JSON_ERROR_UTF8:
  17874. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  17875. break;
  17876. default:
  17877. $msg = 'Unknown error';
  17878. }
  17879. throw new \RuntimeException('JSON encoding failed: '.$msg);
  17880. }
  17881. public static function parseJson($json, $file = null)
  17882. {
  17883. if (null === $json) {
  17884. return;
  17885. }
  17886. $data = json_decode($json, true);
  17887. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  17888. self::validateSyntax($json, $file);
  17889. }
  17890. return $data;
  17891. }
  17892. protected static function validateSyntax($json, $file = null)
  17893. {
  17894. $parser = new JsonParser();
  17895. $result = $parser->lint($json);
  17896. if (null === $result) {
  17897. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  17898. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  17899. }
  17900. return true;
  17901. }
  17902. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  17903. }
  17904. }
  17905. <?php
  17906. namespace Composer\Json;
  17907. class JsonFormatter
  17908. {
  17909. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  17910. {
  17911. $result = '';
  17912. $pos = 0;
  17913. $strLen = strlen($json);
  17914. $indentStr = ' ';
  17915. $newLine = "\n";
  17916. $outOfQuotes = true;
  17917. $buffer = '';
  17918. $noescape = true;
  17919. for ($i = 0; $i < $strLen; $i++) {
  17920. $char = substr($json, $i, 1);
  17921. if ('"' === $char && $noescape) {
  17922. $outOfQuotes = !$outOfQuotes;
  17923. }
  17924. if (!$outOfQuotes) {
  17925. $buffer .= $char;
  17926. $noescape = '\\' === $char ? !$noescape : true;
  17927. continue;
  17928. }
  17929. if ('' !== $buffer) {
  17930. if ($unescapeSlashes) {
  17931. $buffer = str_replace('\\/', '/', $buffer);
  17932. }
  17933. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  17934. $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  17935. $l = strlen($match[1]);
  17936. if ($l % 2) {
  17937. $code = hexdec($match[2]);
  17938. if (0xD800 <= $code && 0xDFFF >= $code) {
  17939. return $match[0];
  17940. }
  17941. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  17942. pack('H*', $match[2]),
  17943. 'UTF-8',
  17944. 'UCS-2BE'
  17945. );
  17946. }
  17947. return $match[0];
  17948. }, $buffer);
  17949. }
  17950. $result .= $buffer.$char;
  17951. $buffer = '';
  17952. continue;
  17953. }
  17954. if (':' === $char) {
  17955. $char .= ' ';
  17956. } elseif ('}' === $char || ']' === $char) {
  17957. $pos--;
  17958. $prevChar = substr($json, $i - 1, 1);
  17959. if ('{' !== $prevChar && '[' !== $prevChar) {
  17960. $result .= $newLine;
  17961. for ($j = 0; $j < $pos; $j++) {
  17962. $result .= $indentStr;
  17963. }
  17964. } else {
  17965. $result = rtrim($result);
  17966. }
  17967. }
  17968. $result .= $char;
  17969. if (',' === $char || '{' === $char || '[' === $char) {
  17970. $result .= $newLine;
  17971. if ('{' === $char || '[' === $char) {
  17972. $pos++;
  17973. }
  17974. for ($j = 0; $j < $pos; $j++) {
  17975. $result .= $indentStr;
  17976. }
  17977. }
  17978. }
  17979. return $result;
  17980. }
  17981. }
  17982. <?php
  17983. namespace Composer\Json;
  17984. use Composer\Repository\PlatformRepository;
  17985. class JsonManipulator
  17986. {
  17987. private static $DEFINES = '(?(DEFINE)
  17988. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? )
  17989. (?<boolean> true | false | null )
  17990. (?<string> " ([^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  17991. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  17992. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  17993. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  17994. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  17995. )';
  17996. private $contents;
  17997. private $newline;
  17998. private $indent;
  17999. public function __construct($contents)
  18000. {
  18001. $contents = trim($contents);
  18002. if ($contents === '') {
  18003. $contents = '{}';
  18004. }
  18005. if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
  18006. throw new \InvalidArgumentException('The json file must be an object ({})');
  18007. }
  18008. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  18009. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  18010. $this->detectIndenting();
  18011. }
  18012. public function getContents()
  18013. {
  18014. return $this->contents . $this->newline;
  18015. }
  18016. public function addLink($type, $package, $constraint, $sortPackages = false)
  18017. {
  18018. $decoded = JsonFile::parseJson($this->contents);
  18019. if (!isset($decoded[$type])) {
  18020. return $this->addMainKey($type, array($package => $constraint));
  18021. }
  18022. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18023. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  18024. if (!$this->pregMatch($regex, $this->contents, $matches)) {
  18025. return false;
  18026. }
  18027. $links = $matches['value'];
  18028. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  18029. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  18030. if ($this->pregMatch($regex, $links, $packageMatches)) {
  18031. $existingPackage = $packageMatches['package'];
  18032. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  18033. $links = preg_replace_callback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  18034. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  18035. }, $links);
  18036. } else {
  18037. if ($this->pregMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  18038. $links = preg_replace(
  18039. '{'.preg_quote($match[1]).'$}',
  18040. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  18041. $links
  18042. );
  18043. } else {
  18044. $links = '{' . $this->newline .
  18045. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  18046. $this->indent . '}';
  18047. }
  18048. }
  18049. if (true === $sortPackages) {
  18050. $requirements = json_decode($links, true);
  18051. $this->sortPackages($requirements);
  18052. $links = $this->format($requirements);
  18053. }
  18054. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  18055. return true;
  18056. }
  18057. private function sortPackages(array &$packages = array())
  18058. {
  18059. $prefix = function ($requirement) {
  18060. if (PlatformRepository::isPlatformPackage($requirement)) {
  18061. return preg_replace(
  18062. array(
  18063. '/^php/',
  18064. '/^hhvm/',
  18065. '/^ext/',
  18066. '/^lib/',
  18067. '/^\D/',
  18068. ),
  18069. array(
  18070. '0-$0',
  18071. '1-$0',
  18072. '2-$0',
  18073. '3-$0',
  18074. '4-$0',
  18075. ),
  18076. $requirement
  18077. );
  18078. }
  18079. return '5-'.$requirement;
  18080. };
  18081. uksort($packages, function ($a, $b) use ($prefix) {
  18082. return strnatcmp($prefix($a), $prefix($b));
  18083. });
  18084. }
  18085. public function addRepository($name, $config, $append = true)
  18086. {
  18087. return $this->addSubNode('repositories', $name, $config, $append);
  18088. }
  18089. public function removeRepository($name)
  18090. {
  18091. return $this->removeSubNode('repositories', $name);
  18092. }
  18093. public function addConfigSetting($name, $value)
  18094. {
  18095. return $this->addSubNode('config', $name, $value);
  18096. }
  18097. public function removeConfigSetting($name)
  18098. {
  18099. return $this->removeSubNode('config', $name);
  18100. }
  18101. public function addProperty($name, $value)
  18102. {
  18103. if (strpos($name, 'suggest.') === 0) {
  18104. return $this->addSubNode('suggest', substr($name, 8), $value);
  18105. }
  18106. if (strpos($name, 'extra.') === 0) {
  18107. return $this->addSubNode('extra', substr($name, 6), $value);
  18108. }
  18109. if (strpos($name, 'scripts.') === 0) {
  18110. return $this->addSubNode('scripts', substr($name, 8), $value);
  18111. }
  18112. return $this->addMainKey($name, $value);
  18113. }
  18114. public function removeProperty($name)
  18115. {
  18116. if (strpos($name, 'suggest.') === 0) {
  18117. return $this->removeSubNode('suggest', substr($name, 8));
  18118. }
  18119. if (strpos($name, 'extra.') === 0) {
  18120. return $this->removeSubNode('extra', substr($name, 6));
  18121. }
  18122. if (strpos($name, 'scripts.') === 0) {
  18123. return $this->removeSubNode('scripts', substr($name, 8));
  18124. }
  18125. return $this->removeMainKey($name);
  18126. }
  18127. public function addSubNode($mainNode, $name, $value, $append = true)
  18128. {
  18129. $decoded = JsonFile::parseJson($this->contents);
  18130. $subName = null;
  18131. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  18132. list($name, $subName) = explode('.', $name, 2);
  18133. }
  18134. if (!isset($decoded[$mainNode])) {
  18135. if ($subName !== null) {
  18136. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  18137. } else {
  18138. $this->addMainKey($mainNode, array($name => $value));
  18139. }
  18140. return true;
  18141. }
  18142. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  18143. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  18144. try {
  18145. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  18146. return false;
  18147. }
  18148. } catch (\RuntimeException $e) {
  18149. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  18150. return false;
  18151. }
  18152. throw $e;
  18153. }
  18154. $children = $match['content'];
  18155. if (!@json_decode($children)) {
  18156. return false;
  18157. }
  18158. $that = $this;
  18159. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  18160. if ($this->pregMatch($childRegex, $children, $matches)) {
  18161. $children = preg_replace_callback($childRegex, function ($matches) use ($subName, $value, $that) {
  18162. if ($subName !== null) {
  18163. $curVal = json_decode($matches['content'], true);
  18164. if (!is_array($curVal)) {
  18165. $curVal = array();
  18166. }
  18167. $curVal[$subName] = $value;
  18168. $value = $curVal;
  18169. }
  18170. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  18171. }, $children);
  18172. } else {
  18173. $this->pregMatch('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  18174. $whitespace = '';
  18175. if (!empty($match['trailingspace'])) {
  18176. $whitespace = $match['trailingspace'];
  18177. }
  18178. if (!empty($match['content'])) {
  18179. if ($subName !== null) {
  18180. $value = array($subName => $value);
  18181. }
  18182. if ($append) {
  18183. $children = preg_replace(
  18184. '#'.$whitespace.'}$#',
  18185. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  18186. $children
  18187. );
  18188. } else {
  18189. $whitespace = '';
  18190. if (!empty($match['leadingspace'])) {
  18191. $whitespace = $match['leadingspace'];
  18192. }
  18193. $children = preg_replace(
  18194. '#^{'.$whitespace.'#',
  18195. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  18196. $children
  18197. );
  18198. }
  18199. } else {
  18200. if ($subName !== null) {
  18201. $value = array($subName => $value);
  18202. }
  18203. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  18204. }
  18205. }
  18206. $this->contents = preg_replace_callback($nodeRegex, function ($m) use ($children) {
  18207. return $m['start'] . $children . $m['end'];
  18208. }, $this->contents);
  18209. return true;
  18210. }
  18211. public function removeSubNode($mainNode, $name)
  18212. {
  18213. $decoded = JsonFile::parseJson($this->contents);
  18214. if (empty($decoded[$mainNode])) {
  18215. return true;
  18216. }
  18217. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  18218. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  18219. try {
  18220. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  18221. return false;
  18222. }
  18223. } catch (\RuntimeException $e) {
  18224. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  18225. return false;
  18226. }
  18227. throw $e;
  18228. }
  18229. $children = $match['content'];
  18230. if (!@json_decode($children, true)) {
  18231. return false;
  18232. }
  18233. $subName = null;
  18234. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  18235. list($name, $subName) = explode('.', $name, 2);
  18236. }
  18237. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  18238. return true;
  18239. }
  18240. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  18241. if ($this->pregMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  18242. if (preg_match_all('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  18243. $bestMatch = '';
  18244. foreach ($matches[0] as $match) {
  18245. if (strlen($bestMatch) < strlen($match)) {
  18246. $bestMatch = $match;
  18247. }
  18248. }
  18249. $childrenClean = preg_replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  18250. if (1 !== $count) {
  18251. $childrenClean = preg_replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  18252. if (1 !== $count) {
  18253. return false;
  18254. }
  18255. }
  18256. }
  18257. } else {
  18258. $childrenClean = $children;
  18259. }
  18260. if (!isset($childrenClean)) {
  18261. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  18262. }
  18263. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  18264. if (empty($match['content'])) {
  18265. $newline = $this->newline;
  18266. $indent = $this->indent;
  18267. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($indent, $newline) {
  18268. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  18269. }, $this->contents);
  18270. if ($subName !== null) {
  18271. $curVal = json_decode($children, true);
  18272. unset($curVal[$name][$subName]);
  18273. $this->addSubNode($mainNode, $name, $curVal[$name]);
  18274. }
  18275. return true;
  18276. }
  18277. $that = $this;
  18278. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  18279. if ($subName !== null) {
  18280. $curVal = json_decode($matches['content'], true);
  18281. unset($curVal[$name][$subName]);
  18282. $childrenClean = $that->format($curVal);
  18283. }
  18284. return $matches['start'] . $childrenClean . $matches['end'];
  18285. }, $this->contents);
  18286. return true;
  18287. }
  18288. public function addMainKey($key, $content)
  18289. {
  18290. $decoded = JsonFile::parseJson($this->contents);
  18291. $content = $this->format($content);
  18292. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18293. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  18294. if (isset($decoded[$key]) && $this->pregMatch($regex, $this->contents, $matches)) {
  18295. if (!@json_decode('{'.$matches['key'].'}')) {
  18296. return false;
  18297. }
  18298. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  18299. return true;
  18300. }
  18301. if ($this->pregMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  18302. $this->contents = preg_replace(
  18303. '#'.$match[1].'\}$#',
  18304. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  18305. $this->contents
  18306. );
  18307. return true;
  18308. }
  18309. $this->contents = preg_replace(
  18310. '#\}$#',
  18311. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  18312. $this->contents
  18313. );
  18314. return true;
  18315. }
  18316. public function removeMainKey($key)
  18317. {
  18318. $decoded = JsonFile::parseJson($this->contents);
  18319. if (!array_key_exists($key, $decoded)) {
  18320. return true;
  18321. }
  18322. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18323. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  18324. if ($this->pregMatch($regex, $this->contents, $matches)) {
  18325. if (!@json_decode('{'.$matches['removal'].'}')) {
  18326. return false;
  18327. }
  18328. if (preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
  18329. $matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  18330. }
  18331. $this->contents = $matches['start'] . $matches['end'];
  18332. if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
  18333. $this->contents = "{\n}";
  18334. }
  18335. return true;
  18336. }
  18337. return false;
  18338. }
  18339. public function removeMainKeyIfEmpty($key)
  18340. {
  18341. $decoded = JsonFile::parseJson($this->contents);
  18342. if (!array_key_exists($key, $decoded)) {
  18343. return true;
  18344. }
  18345. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  18346. return $this->removeMainKey($key);
  18347. }
  18348. return true;
  18349. }
  18350. public function format($data, $depth = 0)
  18351. {
  18352. if (is_array($data)) {
  18353. reset($data);
  18354. if (is_numeric(key($data))) {
  18355. foreach ($data as $key => $val) {
  18356. $data[$key] = $this->format($val, $depth + 1);
  18357. }
  18358. return '['.implode(', ', $data).']';
  18359. }
  18360. $out = '{' . $this->newline;
  18361. $elems = array();
  18362. foreach ($data as $key => $val) {
  18363. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  18364. }
  18365. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  18366. }
  18367. return JsonFile::encode($data);
  18368. }
  18369. protected function detectIndenting()
  18370. {
  18371. if ($this->pregMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  18372. $this->indent = $match[1];
  18373. } else {
  18374. $this->indent = ' ';
  18375. }
  18376. }
  18377. protected function pregMatch($re, $str, &$matches = array())
  18378. {
  18379. $count = preg_match($re, $str, $matches);
  18380. if ($count === false) {
  18381. switch (preg_last_error()) {
  18382. case PREG_NO_ERROR:
  18383. throw new \RuntimeException('Failed to execute regex: PREG_NO_ERROR', PREG_NO_ERROR);
  18384. case PREG_INTERNAL_ERROR:
  18385. throw new \RuntimeException('Failed to execute regex: PREG_INTERNAL_ERROR', PREG_INTERNAL_ERROR);
  18386. case PREG_BACKTRACK_LIMIT_ERROR:
  18387. throw new \RuntimeException('Failed to execute regex: PREG_BACKTRACK_LIMIT_ERROR', PREG_BACKTRACK_LIMIT_ERROR);
  18388. case PREG_RECURSION_LIMIT_ERROR:
  18389. throw new \RuntimeException('Failed to execute regex: PREG_RECURSION_LIMIT_ERROR', PREG_RECURSION_LIMIT_ERROR);
  18390. case PREG_BAD_UTF8_ERROR:
  18391. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_ERROR);
  18392. case PREG_BAD_UTF8_OFFSET_ERROR:
  18393. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_OFFSET_ERROR', PREG_BAD_UTF8_OFFSET_ERROR);
  18394. case 6:
  18395. if (PHP_VERSION_ID > 70000) {
  18396. throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6);
  18397. }
  18398. default:
  18399. throw new \RuntimeException('Failed to execute regex: Unknown error');
  18400. }
  18401. }
  18402. return $count;
  18403. }
  18404. }
  18405. <?php
  18406. namespace Composer\Json;
  18407. use Exception;
  18408. class JsonValidationException extends Exception
  18409. {
  18410. protected $errors;
  18411. public function __construct($message, $errors = array(), Exception $previous = null)
  18412. {
  18413. $this->errors = $errors;
  18414. parent::__construct($message, 0, $previous);
  18415. }
  18416. public function getErrors()
  18417. {
  18418. return $this->errors;
  18419. }
  18420. }
  18421. <?php
  18422. namespace Composer\Package;
  18423. use Composer\Semver\Constraint\Constraint;
  18424. use Composer\Package\Version\VersionParser;
  18425. class AliasPackage extends BasePackage implements CompletePackageInterface
  18426. {
  18427. protected $version;
  18428. protected $prettyVersion;
  18429. protected $dev;
  18430. protected $rootPackageAlias = false;
  18431. protected $stability;
  18432. protected $hasSelfVersionRequires = false;
  18433. protected $aliasOf;
  18434. protected $requires;
  18435. protected $devRequires;
  18436. protected $conflicts;
  18437. protected $provides;
  18438. protected $replaces;
  18439. public function __construct(PackageInterface $aliasOf, $version, $prettyVersion)
  18440. {
  18441. parent::__construct($aliasOf->getName());
  18442. $this->version = $version;
  18443. $this->prettyVersion = $prettyVersion;
  18444. $this->aliasOf = $aliasOf;
  18445. $this->stability = VersionParser::parseStability($version);
  18446. $this->dev = $this->stability === 'dev';
  18447. foreach (Link::$TYPES as $type) {
  18448. $links = $aliasOf->{'get' . ucfirst($type)}();
  18449. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  18450. }
  18451. }
  18452. public function getAliasOf()
  18453. {
  18454. return $this->aliasOf;
  18455. }
  18456. public function getVersion()
  18457. {
  18458. return $this->version;
  18459. }
  18460. public function getStability()
  18461. {
  18462. return $this->stability;
  18463. }
  18464. public function getPrettyVersion()
  18465. {
  18466. return $this->prettyVersion;
  18467. }
  18468. public function isDev()
  18469. {
  18470. return $this->dev;
  18471. }
  18472. public function getRequires()
  18473. {
  18474. return $this->requires;
  18475. }
  18476. public function getConflicts()
  18477. {
  18478. return $this->conflicts;
  18479. }
  18480. public function getProvides()
  18481. {
  18482. return $this->provides;
  18483. }
  18484. public function getReplaces()
  18485. {
  18486. return $this->replaces;
  18487. }
  18488. public function getDevRequires()
  18489. {
  18490. return $this->devRequires;
  18491. }
  18492. public function setRootPackageAlias($value)
  18493. {
  18494. return $this->rootPackageAlias = $value;
  18495. }
  18496. public function isRootPackageAlias()
  18497. {
  18498. return $this->rootPackageAlias;
  18499. }
  18500. protected function replaceSelfVersionDependencies(array $links, $linkType)
  18501. {
  18502. $prettyVersion = $this->prettyVersion;
  18503. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  18504. $prettyVersion = $this->aliasOf->getPrettyVersion();
  18505. }
  18506. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  18507. $newLinks = array();
  18508. foreach ($links as $link) {
  18509. if ('self.version' === $link->getPrettyConstraint()) {
  18510. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18511. $constraint->setPrettyString($prettyVersion);
  18512. }
  18513. }
  18514. $links = array_merge($links, $newLinks);
  18515. } else {
  18516. foreach ($links as $index => $link) {
  18517. if ('self.version' === $link->getPrettyConstraint()) {
  18518. if ($linkType === Link::TYPE_REQUIRE) {
  18519. $this->hasSelfVersionRequires = true;
  18520. }
  18521. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18522. $constraint->setPrettyString($prettyVersion);
  18523. }
  18524. }
  18525. }
  18526. return $links;
  18527. }
  18528. public function hasSelfVersionRequires()
  18529. {
  18530. return $this->hasSelfVersionRequires;
  18531. }
  18532. public function getType()
  18533. {
  18534. return $this->aliasOf->getType();
  18535. }
  18536. public function getTargetDir()
  18537. {
  18538. return $this->aliasOf->getTargetDir();
  18539. }
  18540. public function getExtra()
  18541. {
  18542. return $this->aliasOf->getExtra();
  18543. }
  18544. public function setInstallationSource($type)
  18545. {
  18546. $this->aliasOf->setInstallationSource($type);
  18547. }
  18548. public function getInstallationSource()
  18549. {
  18550. return $this->aliasOf->getInstallationSource();
  18551. }
  18552. public function getSourceType()
  18553. {
  18554. return $this->aliasOf->getSourceType();
  18555. }
  18556. public function getSourceUrl()
  18557. {
  18558. return $this->aliasOf->getSourceUrl();
  18559. }
  18560. public function getSourceUrls()
  18561. {
  18562. return $this->aliasOf->getSourceUrls();
  18563. }
  18564. public function getSourceReference()
  18565. {
  18566. return $this->aliasOf->getSourceReference();
  18567. }
  18568. public function setSourceReference($reference)
  18569. {
  18570. return $this->aliasOf->setSourceReference($reference);
  18571. }
  18572. public function setSourceMirrors($mirrors)
  18573. {
  18574. return $this->aliasOf->setSourceMirrors($mirrors);
  18575. }
  18576. public function getSourceMirrors()
  18577. {
  18578. return $this->aliasOf->getSourceMirrors();
  18579. }
  18580. public function getDistType()
  18581. {
  18582. return $this->aliasOf->getDistType();
  18583. }
  18584. public function getDistUrl()
  18585. {
  18586. return $this->aliasOf->getDistUrl();
  18587. }
  18588. public function getDistUrls()
  18589. {
  18590. return $this->aliasOf->getDistUrls();
  18591. }
  18592. public function getDistReference()
  18593. {
  18594. return $this->aliasOf->getDistReference();
  18595. }
  18596. public function setDistReference($reference)
  18597. {
  18598. return $this->aliasOf->setDistReference($reference);
  18599. }
  18600. public function getDistSha1Checksum()
  18601. {
  18602. return $this->aliasOf->getDistSha1Checksum();
  18603. }
  18604. public function setTransportOptions(array $options)
  18605. {
  18606. return $this->aliasOf->setTransportOptions($options);
  18607. }
  18608. public function getTransportOptions()
  18609. {
  18610. return $this->aliasOf->getTransportOptions();
  18611. }
  18612. public function setDistMirrors($mirrors)
  18613. {
  18614. return $this->aliasOf->setDistMirrors($mirrors);
  18615. }
  18616. public function getDistMirrors()
  18617. {
  18618. return $this->aliasOf->getDistMirrors();
  18619. }
  18620. public function getScripts()
  18621. {
  18622. return $this->aliasOf->getScripts();
  18623. }
  18624. public function getLicense()
  18625. {
  18626. return $this->aliasOf->getLicense();
  18627. }
  18628. public function getAutoload()
  18629. {
  18630. return $this->aliasOf->getAutoload();
  18631. }
  18632. public function getDevAutoload()
  18633. {
  18634. return $this->aliasOf->getDevAutoload();
  18635. }
  18636. public function getIncludePaths()
  18637. {
  18638. return $this->aliasOf->getIncludePaths();
  18639. }
  18640. public function getRepositories()
  18641. {
  18642. return $this->aliasOf->getRepositories();
  18643. }
  18644. public function getReleaseDate()
  18645. {
  18646. return $this->aliasOf->getReleaseDate();
  18647. }
  18648. public function getBinaries()
  18649. {
  18650. return $this->aliasOf->getBinaries();
  18651. }
  18652. public function getKeywords()
  18653. {
  18654. return $this->aliasOf->getKeywords();
  18655. }
  18656. public function getDescription()
  18657. {
  18658. return $this->aliasOf->getDescription();
  18659. }
  18660. public function getHomepage()
  18661. {
  18662. return $this->aliasOf->getHomepage();
  18663. }
  18664. public function getSuggests()
  18665. {
  18666. return $this->aliasOf->getSuggests();
  18667. }
  18668. public function getAuthors()
  18669. {
  18670. return $this->aliasOf->getAuthors();
  18671. }
  18672. public function getSupport()
  18673. {
  18674. return $this->aliasOf->getSupport();
  18675. }
  18676. public function getFunding()
  18677. {
  18678. return $this->aliasOf->getFunding();
  18679. }
  18680. public function getNotificationUrl()
  18681. {
  18682. return $this->aliasOf->getNotificationUrl();
  18683. }
  18684. public function getArchiveName()
  18685. {
  18686. return $this->aliasOf->getArchiveName();
  18687. }
  18688. public function getArchiveExcludes()
  18689. {
  18690. return $this->aliasOf->getArchiveExcludes();
  18691. }
  18692. public function isDefaultBranch()
  18693. {
  18694. return $this->aliasOf->isDefaultBranch();
  18695. }
  18696. public function isAbandoned()
  18697. {
  18698. return $this->aliasOf->isAbandoned();
  18699. }
  18700. public function getReplacementPackage()
  18701. {
  18702. return $this->aliasOf->getReplacementPackage();
  18703. }
  18704. public function __toString()
  18705. {
  18706. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  18707. }
  18708. public function setDistUrl($url)
  18709. {
  18710. return $this->aliasOf->setDistUrl($url);
  18711. }
  18712. public function setDistType($type)
  18713. {
  18714. return $this->aliasOf->setDistType($type);
  18715. }
  18716. public function setSourceDistReferences($reference)
  18717. {
  18718. return $this->aliasOf->setSourceDistReferences($reference);
  18719. }
  18720. }
  18721. <?php
  18722. namespace Composer\Package\Archiver;
  18723. use FilterIterator;
  18724. use PharData;
  18725. class ArchivableFilesFilter extends FilterIterator
  18726. {
  18727. private $dirs = array();
  18728. public function accept()
  18729. {
  18730. $file = $this->getInnerIterator()->current();
  18731. if ($file->isDir()) {
  18732. $this->dirs[] = (string) $file;
  18733. return false;
  18734. }
  18735. return true;
  18736. }
  18737. public function addEmptyDir(PharData $phar, $sources)
  18738. {
  18739. foreach ($this->dirs as $filepath) {
  18740. $localname = str_replace($sources . "/", '', $filepath);
  18741. $phar->addEmptyDir($localname);
  18742. }
  18743. }
  18744. }
  18745. <?php
  18746. namespace Composer\Package\Archiver;
  18747. use Composer\Util\Filesystem;
  18748. use FilesystemIterator;
  18749. use Symfony\Component\Finder\Finder;
  18750. use Symfony\Component\Finder\SplFileInfo;
  18751. class ArchivableFilesFinder extends \FilterIterator
  18752. {
  18753. protected $finder;
  18754. public function __construct($sources, array $excludes, $ignoreFilters = false)
  18755. {
  18756. $fs = new Filesystem();
  18757. $sources = $fs->normalizePath(realpath($sources));
  18758. if ($ignoreFilters) {
  18759. $filters = array();
  18760. } else {
  18761. $filters = array(
  18762. new HgExcludeFilter($sources),
  18763. new GitExcludeFilter($sources),
  18764. new ComposerExcludeFilter($sources, $excludes),
  18765. );
  18766. }
  18767. $this->finder = new Finder();
  18768. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  18769. if ($file->isLink() && strpos($file->getRealPath(), $sources) !== 0) {
  18770. return false;
  18771. }
  18772. $relativePath = preg_replace(
  18773. '#^'.preg_quote($sources, '#').'#',
  18774. '',
  18775. $fs->normalizePath($file->getRealPath())
  18776. );
  18777. $exclude = false;
  18778. foreach ($filters as $filter) {
  18779. $exclude = $filter->filter($relativePath, $exclude);
  18780. }
  18781. return !$exclude;
  18782. };
  18783. if (method_exists($filter, 'bindTo')) {
  18784. $filter = $filter->bindTo(null);
  18785. }
  18786. $this->finder
  18787. ->in($sources)
  18788. ->filter($filter)
  18789. ->ignoreVCS(true)
  18790. ->ignoreDotFiles(false);
  18791. parent::__construct($this->finder->getIterator());
  18792. }
  18793. public function accept()
  18794. {
  18795. $current = $this->getInnerIterator()->current();
  18796. if (!$current->isDir()) {
  18797. return true;
  18798. }
  18799. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  18800. return !$iterator->valid();
  18801. }
  18802. }
  18803. <?php
  18804. namespace Composer\Package\Archiver;
  18805. use Composer\Downloader\DownloadManager;
  18806. use Composer\Package\PackageInterface;
  18807. use Composer\Package\RootPackageInterface;
  18808. use Composer\Util\Filesystem;
  18809. use Composer\Util\Loop;
  18810. use Composer\Json\JsonFile;
  18811. class ArchiveManager
  18812. {
  18813. protected $downloadManager;
  18814. protected $loop;
  18815. protected $archivers = array();
  18816. protected $overwriteFiles = true;
  18817. public function __construct(DownloadManager $downloadManager, Loop $loop)
  18818. {
  18819. $this->downloadManager = $downloadManager;
  18820. $this->loop = $loop;
  18821. }
  18822. public function addArchiver(ArchiverInterface $archiver)
  18823. {
  18824. $this->archivers[] = $archiver;
  18825. }
  18826. public function setOverwriteFiles($overwriteFiles)
  18827. {
  18828. $this->overwriteFiles = $overwriteFiles;
  18829. return $this;
  18830. }
  18831. public function getPackageFilename(PackageInterface $package)
  18832. {
  18833. if ($package->getArchiveName()) {
  18834. $baseName = $package->getArchiveName();
  18835. } else {
  18836. $baseName = preg_replace('#[^a-z0-9-_]#i', '-', $package->getName());
  18837. }
  18838. $nameParts = array($baseName);
  18839. if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  18840. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  18841. } else {
  18842. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  18843. }
  18844. if ($package->getSourceReference()) {
  18845. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  18846. }
  18847. $name = implode('-', array_filter($nameParts, function ($p) {
  18848. return !empty($p);
  18849. }));
  18850. return str_replace('/', '-', $name);
  18851. }
  18852. public function archive(PackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  18853. {
  18854. if (empty($format)) {
  18855. throw new \InvalidArgumentException('Format must be specified');
  18856. }
  18857. $usableArchiver = null;
  18858. foreach ($this->archivers as $archiver) {
  18859. if ($archiver->supports($format, $package->getSourceType())) {
  18860. $usableArchiver = $archiver;
  18861. break;
  18862. }
  18863. }
  18864. if (null === $usableArchiver) {
  18865. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  18866. }
  18867. $filesystem = new Filesystem();
  18868. if ($package instanceof RootPackageInterface) {
  18869. $sourcePath = realpath('.');
  18870. } else {
  18871. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  18872. $filesystem->ensureDirectoryExists($sourcePath);
  18873. try {
  18874. $promise = $this->downloadManager->download($package, $sourcePath);
  18875. $this->loop->wait(array($promise));
  18876. $this->downloadManager->install($package, $sourcePath);
  18877. } catch (\Exception $e) {
  18878. $filesystem->removeDirectory($sourcePath);
  18879. throw $e;
  18880. }
  18881. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  18882. $jsonFile = new JsonFile($composerJsonPath);
  18883. $jsonData = $jsonFile->read();
  18884. if (!empty($jsonData['archive']['name'])) {
  18885. $package->setArchiveName($jsonData['archive']['name']);
  18886. }
  18887. if (!empty($jsonData['archive']['exclude'])) {
  18888. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  18889. }
  18890. }
  18891. }
  18892. if (null === $fileName) {
  18893. $packageName = $this->getPackageFilename($package);
  18894. } else {
  18895. $packageName = $fileName;
  18896. }
  18897. $filesystem->ensureDirectoryExists($targetDir);
  18898. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  18899. $filesystem->ensureDirectoryExists(dirname($target));
  18900. if (!$this->overwriteFiles && file_exists($target)) {
  18901. return $target;
  18902. }
  18903. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  18904. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  18905. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  18906. $filesystem->rename($archivePath, $target);
  18907. if (!$package instanceof RootPackageInterface) {
  18908. $filesystem->removeDirectory($sourcePath);
  18909. }
  18910. $filesystem->remove($tempTarget);
  18911. return $target;
  18912. }
  18913. }
  18914. <?php
  18915. namespace Composer\Package\Archiver;
  18916. interface ArchiverInterface
  18917. {
  18918. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  18919. public function supports($format, $sourceType);
  18920. }
  18921. <?php
  18922. namespace Composer\Package\Archiver;
  18923. use Symfony\Component\Finder;
  18924. abstract class BaseExcludeFilter
  18925. {
  18926. protected $sourcePath;
  18927. protected $excludePatterns;
  18928. public function __construct($sourcePath)
  18929. {
  18930. $this->sourcePath = $sourcePath;
  18931. $this->excludePatterns = array();
  18932. }
  18933. public function filter($relativePath, $exclude)
  18934. {
  18935. foreach ($this->excludePatterns as $patternData) {
  18936. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  18937. if ($stripLeadingSlash) {
  18938. $path = substr($relativePath, 1);
  18939. } else {
  18940. $path = $relativePath;
  18941. }
  18942. if (@preg_match($pattern, $path)) {
  18943. $exclude = !$negate;
  18944. }
  18945. }
  18946. return $exclude;
  18947. }
  18948. protected function parseLines(array $lines, $lineParser)
  18949. {
  18950. return array_filter(
  18951. array_map(
  18952. function ($line) use ($lineParser) {
  18953. $line = trim($line);
  18954. if (!$line || 0 === strpos($line, '#')) {
  18955. return null;
  18956. }
  18957. return call_user_func($lineParser, $line);
  18958. },
  18959. $lines
  18960. ),
  18961. function ($pattern) {
  18962. return $pattern !== null;
  18963. }
  18964. );
  18965. }
  18966. protected function generatePatterns($rules)
  18967. {
  18968. $patterns = array();
  18969. foreach ($rules as $rule) {
  18970. $patterns[] = $this->generatePattern($rule);
  18971. }
  18972. return $patterns;
  18973. }
  18974. protected function generatePattern($rule)
  18975. {
  18976. $negate = false;
  18977. $pattern = '';
  18978. if ($rule !== '' && $rule[0] === '!') {
  18979. $negate = true;
  18980. $rule = ltrim($rule, '!');
  18981. }
  18982. $firstSlashPosition = strpos($rule, '/');
  18983. if (0 === $firstSlashPosition) {
  18984. $pattern = '^/';
  18985. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  18986. $pattern = '/';
  18987. }
  18988. $rule = trim($rule, '/');
  18989. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  18990. return array('{'.$pattern.$rule.'(?=$|/)}', $negate, false);
  18991. }
  18992. }
  18993. <?php
  18994. namespace Composer\Package\Archiver;
  18995. class ComposerExcludeFilter extends BaseExcludeFilter
  18996. {
  18997. public function __construct($sourcePath, array $excludeRules)
  18998. {
  18999. parent::__construct($sourcePath);
  19000. $this->excludePatterns = $this->generatePatterns($excludeRules);
  19001. }
  19002. }
  19003. <?php
  19004. namespace Composer\Package\Archiver;
  19005. class GitExcludeFilter extends BaseExcludeFilter
  19006. {
  19007. public function __construct($sourcePath)
  19008. {
  19009. parent::__construct($sourcePath);
  19010. if (file_exists($sourcePath.'/.gitignore')) {
  19011. $this->excludePatterns = $this->parseLines(
  19012. file($sourcePath.'/.gitignore'),
  19013. array($this, 'parseGitIgnoreLine')
  19014. );
  19015. }
  19016. if (file_exists($sourcePath.'/.gitattributes')) {
  19017. $this->excludePatterns = array_merge(
  19018. $this->excludePatterns,
  19019. $this->parseLines(
  19020. file($sourcePath.'/.gitattributes'),
  19021. array($this, 'parseGitAttributesLine')
  19022. )
  19023. );
  19024. }
  19025. }
  19026. public function parseGitIgnoreLine($line)
  19027. {
  19028. return $this->generatePattern($line);
  19029. }
  19030. public function parseGitAttributesLine($line)
  19031. {
  19032. $parts = preg_split('#\s+#', $line);
  19033. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  19034. return $this->generatePattern($parts[0]);
  19035. }
  19036. return null;
  19037. }
  19038. }
  19039. <?php
  19040. namespace Composer\Package\Archiver;
  19041. use Symfony\Component\Finder;
  19042. class HgExcludeFilter extends BaseExcludeFilter
  19043. {
  19044. const HG_IGNORE_REGEX = 1;
  19045. const HG_IGNORE_GLOB = 2;
  19046. protected $patternMode;
  19047. public function __construct($sourcePath)
  19048. {
  19049. parent::__construct($sourcePath);
  19050. $this->patternMode = self::HG_IGNORE_REGEX;
  19051. if (file_exists($sourcePath.'/.hgignore')) {
  19052. $this->excludePatterns = $this->parseLines(
  19053. file($sourcePath.'/.hgignore'),
  19054. array($this, 'parseHgIgnoreLine')
  19055. );
  19056. }
  19057. }
  19058. public function parseHgIgnoreLine($line)
  19059. {
  19060. if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)) {
  19061. if ($matches[1] === 'glob') {
  19062. $this->patternMode = self::HG_IGNORE_GLOB;
  19063. } else {
  19064. $this->patternMode = self::HG_IGNORE_REGEX;
  19065. }
  19066. return null;
  19067. }
  19068. if ($this->patternMode == self::HG_IGNORE_GLOB) {
  19069. return $this->patternFromGlob($line);
  19070. }
  19071. return $this->patternFromRegex($line);
  19072. }
  19073. protected function patternFromGlob($line)
  19074. {
  19075. $pattern = '#'.substr(Finder\Glob::toRegex($line), 2, -1).'#';
  19076. $pattern = str_replace('[^/]*', '.*', $pattern);
  19077. return array($pattern, false, true);
  19078. }
  19079. public function patternFromRegex($line)
  19080. {
  19081. $pattern = '#'.preg_replace('/((?:\\\\\\\\)*)(\\\\?)#/', '\1\2\2\\#', $line).'#';
  19082. return array($pattern, false, true);
  19083. }
  19084. }
  19085. <?php
  19086. namespace Composer\Package\Archiver;
  19087. class PharArchiver implements ArchiverInterface
  19088. {
  19089. protected static $formats = array(
  19090. 'zip' => \Phar::ZIP,
  19091. 'tar' => \Phar::TAR,
  19092. 'tar.gz' => \Phar::TAR,
  19093. 'tar.bz2' => \Phar::TAR,
  19094. );
  19095. protected static $compressFormats = array(
  19096. 'tar.gz' => \Phar::GZ,
  19097. 'tar.bz2' => \Phar::BZ2,
  19098. );
  19099. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  19100. {
  19101. $sources = realpath($sources);
  19102. if (file_exists($target)) {
  19103. unlink($target);
  19104. }
  19105. try {
  19106. $filename = substr($target, 0, strrpos($target, $format) - 1);
  19107. if (isset(static::$compressFormats[$format])) {
  19108. $target = $filename . '.tar';
  19109. }
  19110. $phar = new \PharData($target, null, null, static::$formats[$format]);
  19111. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  19112. $filesOnly = new ArchivableFilesFilter($files);
  19113. $phar->buildFromIterator($filesOnly, $sources);
  19114. $filesOnly->addEmptyDir($phar, $sources);
  19115. if (isset(static::$compressFormats[$format])) {
  19116. if (!$phar->canCompress(static::$compressFormats[$format])) {
  19117. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  19118. }
  19119. unlink($target);
  19120. $phar->compress(static::$compressFormats[$format]);
  19121. $target = $filename . '.' . $format;
  19122. }
  19123. return $target;
  19124. } catch (\UnexpectedValueException $e) {
  19125. $message = sprintf(
  19126. "Could not create archive '%s' from '%s': %s",
  19127. $target,
  19128. $sources,
  19129. $e->getMessage()
  19130. );
  19131. throw new \RuntimeException($message, $e->getCode(), $e);
  19132. }
  19133. }
  19134. public function supports($format, $sourceType)
  19135. {
  19136. return isset(static::$formats[$format]);
  19137. }
  19138. }
  19139. <?php
  19140. namespace Composer\Package\Archiver;
  19141. use ZipArchive;
  19142. use Composer\Util\Filesystem;
  19143. class ZipArchiver implements ArchiverInterface
  19144. {
  19145. protected static $formats = array(
  19146. 'zip' => 1,
  19147. );
  19148. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  19149. {
  19150. $fs = new Filesystem();
  19151. $sources = $fs->normalizePath($sources);
  19152. $zip = new ZipArchive();
  19153. $res = $zip->open($target, ZipArchive::CREATE);
  19154. if ($res === true) {
  19155. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  19156. foreach ($files as $file) {
  19157. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  19158. $localname = $filepath;
  19159. if (strpos($localname, $sources . '/') === 0) {
  19160. $localname = substr($localname, strlen($sources . '/'));
  19161. }
  19162. if ($file->isDir()) {
  19163. $zip->addEmptyDir($localname);
  19164. } else {
  19165. $zip->addFile($filepath, $localname);
  19166. }
  19167. if (PHP_VERSION_ID >= 50600) {
  19168. $perms = fileperms($filepath);
  19169. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  19170. }
  19171. }
  19172. if ($zip->close()) {
  19173. return $target;
  19174. }
  19175. }
  19176. $message = sprintf(
  19177. "Could not create archive '%s' from '%s': %s",
  19178. $target,
  19179. $sources,
  19180. $zip->getStatusString()
  19181. );
  19182. throw new \RuntimeException($message);
  19183. }
  19184. public function supports($format, $sourceType)
  19185. {
  19186. return isset(static::$formats[$format]) && $this->compressionAvailable();
  19187. }
  19188. private function compressionAvailable()
  19189. {
  19190. return class_exists('ZipArchive');
  19191. }
  19192. }
  19193. <?php
  19194. namespace Composer\Package;
  19195. use Composer\Repository\RepositoryInterface;
  19196. use Composer\Repository\PlatformRepository;
  19197. abstract class BasePackage implements PackageInterface
  19198. {
  19199. public static $supportedLinkTypes = array(
  19200. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  19201. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  19202. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  19203. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  19204. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  19205. );
  19206. const STABILITY_STABLE = 0;
  19207. const STABILITY_RC = 5;
  19208. const STABILITY_BETA = 10;
  19209. const STABILITY_ALPHA = 15;
  19210. const STABILITY_DEV = 20;
  19211. public static $stabilities = array(
  19212. 'stable' => self::STABILITY_STABLE,
  19213. 'RC' => self::STABILITY_RC,
  19214. 'beta' => self::STABILITY_BETA,
  19215. 'alpha' => self::STABILITY_ALPHA,
  19216. 'dev' => self::STABILITY_DEV,
  19217. );
  19218. public $id;
  19219. protected $name;
  19220. protected $prettyName;
  19221. protected $repository;
  19222. protected $transportOptions = array();
  19223. public function __construct($name)
  19224. {
  19225. $this->prettyName = $name;
  19226. $this->name = strtolower($name);
  19227. $this->id = -1;
  19228. }
  19229. public function getName()
  19230. {
  19231. return $this->name;
  19232. }
  19233. public function getPrettyName()
  19234. {
  19235. return $this->prettyName;
  19236. }
  19237. public function getNames($provides = true)
  19238. {
  19239. $names = array(
  19240. $this->getName() => true,
  19241. );
  19242. if ($provides) {
  19243. foreach ($this->getProvides() as $link) {
  19244. $names[$link->getTarget()] = true;
  19245. }
  19246. }
  19247. foreach ($this->getReplaces() as $link) {
  19248. $names[$link->getTarget()] = true;
  19249. }
  19250. return array_keys($names);
  19251. }
  19252. public function setId($id)
  19253. {
  19254. $this->id = $id;
  19255. }
  19256. public function getId()
  19257. {
  19258. return $this->id;
  19259. }
  19260. public function setRepository(RepositoryInterface $repository)
  19261. {
  19262. if ($this->repository && $repository !== $this->repository) {
  19263. throw new \LogicException('A package can only be added to one repository');
  19264. }
  19265. $this->repository = $repository;
  19266. }
  19267. public function getRepository()
  19268. {
  19269. return $this->repository;
  19270. }
  19271. public function getTransportOptions()
  19272. {
  19273. return $this->transportOptions;
  19274. }
  19275. public function setTransportOptions(array $options)
  19276. {
  19277. $this->transportOptions = $options;
  19278. }
  19279. public function isPlatform()
  19280. {
  19281. return $this->getRepository() instanceof PlatformRepository;
  19282. }
  19283. public function getUniqueName()
  19284. {
  19285. return $this->getName().'-'.$this->getVersion();
  19286. }
  19287. public function equals(PackageInterface $package)
  19288. {
  19289. $self = $this;
  19290. if ($this instanceof AliasPackage) {
  19291. $self = $this->getAliasOf();
  19292. }
  19293. if ($package instanceof AliasPackage) {
  19294. $package = $package->getAliasOf();
  19295. }
  19296. return $package === $self;
  19297. }
  19298. public function __toString()
  19299. {
  19300. return $this->getUniqueName();
  19301. }
  19302. public function getPrettyString()
  19303. {
  19304. return $this->getPrettyName().' '.$this->getPrettyVersion();
  19305. }
  19306. public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
  19307. {
  19308. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  19309. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  19310. ) {
  19311. return $this->getPrettyVersion();
  19312. }
  19313. switch ($displayMode) {
  19314. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  19315. case PackageInterface::DISPLAY_SOURCE_REF:
  19316. $reference = $this->getSourceReference();
  19317. break;
  19318. case PackageInterface::DISPLAY_DIST_REF:
  19319. $reference = $this->getDistReference();
  19320. break;
  19321. default:
  19322. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  19323. }
  19324. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  19325. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  19326. }
  19327. return $this->getPrettyVersion() . ' ' . $reference;
  19328. }
  19329. public function getStabilityPriority()
  19330. {
  19331. return self::$stabilities[$this->getStability()];
  19332. }
  19333. public function __clone()
  19334. {
  19335. $this->repository = null;
  19336. $this->id = -1;
  19337. }
  19338. public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
  19339. {
  19340. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  19341. return sprintf($wrap, $cleanedAllowPattern);
  19342. }
  19343. }
  19344. <?php
  19345. namespace Composer\Package\Comparer;
  19346. class Comparer
  19347. {
  19348. private $source;
  19349. private $update;
  19350. private $changed;
  19351. public function setSource($source)
  19352. {
  19353. $this->source = $source;
  19354. }
  19355. public function setUpdate($update)
  19356. {
  19357. $this->update = $update;
  19358. }
  19359. public function getChanged($toString = false, $explicated = false)
  19360. {
  19361. $changed = $this->changed;
  19362. if (!count($changed)) {
  19363. return false;
  19364. }
  19365. if ($explicated) {
  19366. foreach ($changed as $sectionKey => $itemSection) {
  19367. foreach ($itemSection as $itemKey => $item) {
  19368. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  19369. }
  19370. }
  19371. }
  19372. if ($toString) {
  19373. foreach ($changed as $sectionKey => $itemSection) {
  19374. foreach ($itemSection as $itemKey => $item) {
  19375. $changed['string'][] = $item."\r\n";
  19376. }
  19377. }
  19378. $changed = implode("\r\n", $changed['string']);
  19379. }
  19380. return $changed;
  19381. }
  19382. public function doCompare()
  19383. {
  19384. $source = array();
  19385. $destination = array();
  19386. $this->changed = array();
  19387. $currentDirectory = getcwd();
  19388. chdir($this->source);
  19389. $source = $this->doTree('.', $source);
  19390. if (!is_array($source)) {
  19391. return;
  19392. }
  19393. chdir($currentDirectory);
  19394. chdir($this->update);
  19395. $destination = $this->doTree('.', $destination);
  19396. if (!is_array($destination)) {
  19397. exit;
  19398. }
  19399. chdir($currentDirectory);
  19400. foreach ($source as $dir => $value) {
  19401. foreach ($value as $file => $hash) {
  19402. if (isset($destination[$dir][$file])) {
  19403. if ($hash !== $destination[$dir][$file]) {
  19404. $this->changed['changed'][] = $dir.'/'.$file;
  19405. }
  19406. } else {
  19407. $this->changed['removed'][] = $dir.'/'.$file;
  19408. }
  19409. }
  19410. }
  19411. foreach ($destination as $dir => $value) {
  19412. foreach ($value as $file => $hash) {
  19413. if (!isset($source[$dir][$file])) {
  19414. $this->changed['added'][] = $dir.'/'.$file;
  19415. }
  19416. }
  19417. }
  19418. }
  19419. private function doTree($dir, &$array)
  19420. {
  19421. if ($dh = opendir($dir)) {
  19422. while ($file = readdir($dh)) {
  19423. if ($file !== '.' && $file !== '..') {
  19424. if (is_link($dir.'/'.$file)) {
  19425. $array[$dir][$file] = readlink($dir.'/'.$file);
  19426. } elseif (is_dir($dir.'/'.$file)) {
  19427. if (!count($array)) {
  19428. $array[0] = 'Temp';
  19429. }
  19430. if (!$this->doTree($dir.'/'.$file, $array)) {
  19431. return false;
  19432. }
  19433. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  19434. $array[$dir][$file] = md5_file($dir.'/'.$file);
  19435. }
  19436. }
  19437. }
  19438. if (count($array) > 1 && isset($array['0'])) {
  19439. unset($array['0']);
  19440. }
  19441. return $array;
  19442. }
  19443. return false;
  19444. }
  19445. }
  19446. <?php
  19447. namespace Composer\Package;
  19448. class CompletePackage extends Package implements CompletePackageInterface
  19449. {
  19450. protected $repositories;
  19451. protected $license = array();
  19452. protected $keywords;
  19453. protected $authors;
  19454. protected $description;
  19455. protected $homepage;
  19456. protected $scripts = array();
  19457. protected $support = array();
  19458. protected $funding = array();
  19459. protected $abandoned = false;
  19460. public function setScripts(array $scripts)
  19461. {
  19462. $this->scripts = $scripts;
  19463. }
  19464. public function getScripts()
  19465. {
  19466. return $this->scripts;
  19467. }
  19468. public function setRepositories($repositories)
  19469. {
  19470. $this->repositories = $repositories;
  19471. }
  19472. public function getRepositories()
  19473. {
  19474. return $this->repositories;
  19475. }
  19476. public function setLicense(array $license)
  19477. {
  19478. $this->license = $license;
  19479. }
  19480. public function getLicense()
  19481. {
  19482. return $this->license;
  19483. }
  19484. public function setKeywords(array $keywords)
  19485. {
  19486. $this->keywords = $keywords;
  19487. }
  19488. public function getKeywords()
  19489. {
  19490. return $this->keywords;
  19491. }
  19492. public function setAuthors(array $authors)
  19493. {
  19494. $this->authors = $authors;
  19495. }
  19496. public function getAuthors()
  19497. {
  19498. return $this->authors;
  19499. }
  19500. public function setDescription($description)
  19501. {
  19502. $this->description = $description;
  19503. }
  19504. public function getDescription()
  19505. {
  19506. return $this->description;
  19507. }
  19508. public function setHomepage($homepage)
  19509. {
  19510. $this->homepage = $homepage;
  19511. }
  19512. public function getHomepage()
  19513. {
  19514. return $this->homepage;
  19515. }
  19516. public function setSupport(array $support)
  19517. {
  19518. $this->support = $support;
  19519. }
  19520. public function getSupport()
  19521. {
  19522. return $this->support;
  19523. }
  19524. public function setFunding(array $funding)
  19525. {
  19526. $this->funding = $funding;
  19527. }
  19528. public function getFunding()
  19529. {
  19530. return $this->funding;
  19531. }
  19532. public function isAbandoned()
  19533. {
  19534. return (bool) $this->abandoned;
  19535. }
  19536. public function setAbandoned($abandoned)
  19537. {
  19538. $this->abandoned = $abandoned;
  19539. }
  19540. public function getReplacementPackage()
  19541. {
  19542. return \is_string($this->abandoned) ? $this->abandoned : null;
  19543. }
  19544. }
  19545. <?php
  19546. namespace Composer\Package;
  19547. interface CompletePackageInterface extends PackageInterface
  19548. {
  19549. public function getScripts();
  19550. public function getRepositories();
  19551. public function getLicense();
  19552. public function getKeywords();
  19553. public function getDescription();
  19554. public function getHomepage();
  19555. public function getAuthors();
  19556. public function getSupport();
  19557. public function getFunding();
  19558. public function isAbandoned();
  19559. public function getReplacementPackage();
  19560. }
  19561. <?php
  19562. namespace Composer\Package\Dumper;
  19563. use Composer\Package\BasePackage;
  19564. use Composer\Package\PackageInterface;
  19565. use Composer\Package\CompletePackageInterface;
  19566. use Composer\Package\RootPackageInterface;
  19567. class ArrayDumper
  19568. {
  19569. public function dump(PackageInterface $package)
  19570. {
  19571. $keys = array(
  19572. 'binaries' => 'bin',
  19573. 'type',
  19574. 'extra',
  19575. 'installationSource' => 'installation-source',
  19576. 'autoload',
  19577. 'devAutoload' => 'autoload-dev',
  19578. 'notificationUrl' => 'notification-url',
  19579. 'includePaths' => 'include-path',
  19580. );
  19581. $data = array();
  19582. $data['name'] = $package->getPrettyName();
  19583. $data['version'] = $package->getPrettyVersion();
  19584. $data['version_normalized'] = $package->getVersion();
  19585. if ($package->getTargetDir()) {
  19586. $data['target-dir'] = $package->getTargetDir();
  19587. }
  19588. if ($package->getSourceType()) {
  19589. $data['source']['type'] = $package->getSourceType();
  19590. $data['source']['url'] = $package->getSourceUrl();
  19591. if (null !== ($value = $package->getSourceReference())) {
  19592. $data['source']['reference'] = $value;
  19593. }
  19594. if ($mirrors = $package->getSourceMirrors()) {
  19595. $data['source']['mirrors'] = $mirrors;
  19596. }
  19597. }
  19598. if ($package->getDistType()) {
  19599. $data['dist']['type'] = $package->getDistType();
  19600. $data['dist']['url'] = $package->getDistUrl();
  19601. if (null !== ($value = $package->getDistReference())) {
  19602. $data['dist']['reference'] = $value;
  19603. }
  19604. if (null !== ($value = $package->getDistSha1Checksum())) {
  19605. $data['dist']['shasum'] = $value;
  19606. }
  19607. if ($mirrors = $package->getDistMirrors()) {
  19608. $data['dist']['mirrors'] = $mirrors;
  19609. }
  19610. }
  19611. if ($package->getArchiveName()) {
  19612. $data['archive']['name'] = $package->getArchiveName();
  19613. }
  19614. if ($package->getArchiveExcludes()) {
  19615. $data['archive']['exclude'] = $package->getArchiveExcludes();
  19616. }
  19617. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  19618. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  19619. foreach ($links as $link) {
  19620. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  19621. }
  19622. ksort($data[$type]);
  19623. }
  19624. }
  19625. if ($packages = $package->getSuggests()) {
  19626. ksort($packages);
  19627. $data['suggest'] = $packages;
  19628. }
  19629. if ($package->getReleaseDate()) {
  19630. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  19631. }
  19632. if ($package->isDefaultBranch()) {
  19633. $data['default-branch'] = true;
  19634. }
  19635. $data = $this->dumpValues($package, $keys, $data);
  19636. if ($package instanceof CompletePackageInterface) {
  19637. $keys = array(
  19638. 'scripts',
  19639. 'license',
  19640. 'authors',
  19641. 'description',
  19642. 'homepage',
  19643. 'keywords',
  19644. 'repositories',
  19645. 'support',
  19646. 'funding',
  19647. );
  19648. $data = $this->dumpValues($package, $keys, $data);
  19649. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  19650. sort($data['keywords']);
  19651. }
  19652. if ($package->isAbandoned()) {
  19653. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  19654. }
  19655. }
  19656. if ($package instanceof RootPackageInterface) {
  19657. $minimumStability = $package->getMinimumStability();
  19658. if ($minimumStability) {
  19659. $data['minimum-stability'] = $minimumStability;
  19660. }
  19661. }
  19662. if (\count($package->getTransportOptions()) > 0) {
  19663. $data['transport-options'] = $package->getTransportOptions();
  19664. }
  19665. return $data;
  19666. }
  19667. private function dumpValues(PackageInterface $package, array $keys, array $data)
  19668. {
  19669. foreach ($keys as $method => $key) {
  19670. if (is_numeric($method)) {
  19671. $method = $key;
  19672. }
  19673. $getter = 'get'.ucfirst($method);
  19674. $value = $package->$getter();
  19675. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  19676. $data[$key] = $value;
  19677. }
  19678. }
  19679. return $data;
  19680. }
  19681. }
  19682. <?php
  19683. namespace Composer\Package;
  19684. use Composer\Semver\Constraint\ConstraintInterface;
  19685. class Link
  19686. {
  19687. const TYPE_REQUIRE = 'requires';
  19688. const TYPE_DEV_REQUIRE = 'devRequires';
  19689. const TYPE_PROVIDE = 'provides';
  19690. const TYPE_CONFLICT = 'conflicts';
  19691. const TYPE_REPLACE = 'replaces';
  19692. public static $TYPES = array(
  19693. self::TYPE_REQUIRE,
  19694. self::TYPE_DEV_REQUIRE,
  19695. self::TYPE_PROVIDE,
  19696. self::TYPE_CONFLICT,
  19697. self::TYPE_REPLACE,
  19698. );
  19699. protected $source;
  19700. protected $target;
  19701. protected $constraint;
  19702. protected $description;
  19703. protected $prettyConstraint;
  19704. public function __construct(
  19705. $source,
  19706. $target,
  19707. ConstraintInterface $constraint,
  19708. $description = 'relates to',
  19709. $prettyConstraint = null
  19710. ) {
  19711. $this->source = strtolower($source);
  19712. $this->target = strtolower($target);
  19713. $this->constraint = $constraint;
  19714. $this->description = $description;
  19715. $this->prettyConstraint = $prettyConstraint;
  19716. }
  19717. public function getDescription()
  19718. {
  19719. return $this->description;
  19720. }
  19721. public function getSource()
  19722. {
  19723. return $this->source;
  19724. }
  19725. public function getTarget()
  19726. {
  19727. return $this->target;
  19728. }
  19729. public function getConstraint()
  19730. {
  19731. return $this->constraint;
  19732. }
  19733. public function getPrettyConstraint()
  19734. {
  19735. if (null === $this->prettyConstraint) {
  19736. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  19737. }
  19738. return $this->prettyConstraint;
  19739. }
  19740. public function __toString()
  19741. {
  19742. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  19743. }
  19744. public function getPrettyString(PackageInterface $sourcePackage)
  19745. {
  19746. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.($this->constraint ? ' '.$this->constraint->getPrettyString() : '');
  19747. }
  19748. }
  19749. <?php
  19750. namespace Composer\Package\Loader;
  19751. use Composer\Package;
  19752. use Composer\Package\AliasPackage;
  19753. use Composer\Package\Link;
  19754. use Composer\Package\RootAliasPackage;
  19755. use Composer\Package\RootPackageInterface;
  19756. use Composer\Package\Version\VersionParser;
  19757. class ArrayLoader implements LoaderInterface
  19758. {
  19759. protected $versionParser;
  19760. protected $loadOptions;
  19761. public function __construct(VersionParser $parser = null, $loadOptions = false)
  19762. {
  19763. if (!$parser) {
  19764. $parser = new VersionParser;
  19765. }
  19766. $this->versionParser = $parser;
  19767. $this->loadOptions = $loadOptions;
  19768. }
  19769. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  19770. {
  19771. $package = $this->createObject($config, $class);
  19772. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19773. if (isset($config[$type])) {
  19774. $method = 'set'.ucfirst($opts['method']);
  19775. $package->{$method}(
  19776. $this->parseLinks(
  19777. $package->getName(),
  19778. $package->getPrettyVersion(),
  19779. $opts['description'],
  19780. $config[$type]
  19781. )
  19782. );
  19783. }
  19784. }
  19785. $package = $this->configureObject($package, $config);
  19786. return $package;
  19787. }
  19788. public function loadPackages(array $versions, $class)
  19789. {
  19790. $packages = array();
  19791. $linkCache = array();
  19792. foreach ($versions as $version) {
  19793. $package = $this->createObject($version, $class);
  19794. $this->configureCachedLinks($linkCache, $package, $version);
  19795. $package = $this->configureObject($package, $version);
  19796. $packages[] = $package;
  19797. }
  19798. return $packages;
  19799. }
  19800. private function createObject(array $config, $class)
  19801. {
  19802. if (!isset($config['name'])) {
  19803. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  19804. }
  19805. if (!isset($config['version'])) {
  19806. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  19807. }
  19808. if (isset($config['version_normalized'])) {
  19809. $version = $config['version_normalized'];
  19810. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  19811. $version = $this->versionParser->normalize($config['version']);
  19812. }
  19813. } else {
  19814. $version = $this->versionParser->normalize($config['version']);
  19815. }
  19816. return new $class($config['name'], $version, $config['version']);
  19817. }
  19818. private function configureObject($package, array $config)
  19819. {
  19820. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  19821. if (isset($config['target-dir'])) {
  19822. $package->setTargetDir($config['target-dir']);
  19823. }
  19824. if (isset($config['extra']) && \is_array($config['extra'])) {
  19825. $package->setExtra($config['extra']);
  19826. }
  19827. if (isset($config['bin'])) {
  19828. if (!\is_array($config['bin'])) {
  19829. $config['bin'] = array($config['bin']);
  19830. }
  19831. foreach ($config['bin'] as $key => $bin) {
  19832. $config['bin'][$key] = ltrim($bin, '/');
  19833. }
  19834. $package->setBinaries($config['bin']);
  19835. }
  19836. if (isset($config['installation-source'])) {
  19837. $package->setInstallationSource($config['installation-source']);
  19838. }
  19839. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19840. $package->setIsDefaultBranch(true);
  19841. }
  19842. if (isset($config['source'])) {
  19843. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  19844. throw new \UnexpectedValueException(sprintf(
  19845. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  19846. $config['name'],
  19847. json_encode($config['source'])
  19848. ));
  19849. }
  19850. $package->setSourceType($config['source']['type']);
  19851. $package->setSourceUrl($config['source']['url']);
  19852. $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
  19853. if (isset($config['source']['mirrors'])) {
  19854. $package->setSourceMirrors($config['source']['mirrors']);
  19855. }
  19856. }
  19857. if (isset($config['dist'])) {
  19858. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  19859. throw new \UnexpectedValueException(sprintf(
  19860. "Package %s's dist key should be specified as ".
  19861. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  19862. $config['name'],
  19863. json_encode($config['dist'])
  19864. ));
  19865. }
  19866. $package->setDistType($config['dist']['type']);
  19867. $package->setDistUrl($config['dist']['url']);
  19868. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  19869. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  19870. if (isset($config['dist']['mirrors'])) {
  19871. $package->setDistMirrors($config['dist']['mirrors']);
  19872. }
  19873. }
  19874. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  19875. foreach ($config['suggest'] as $target => $reason) {
  19876. if ('self.version' === trim($reason)) {
  19877. $config['suggest'][$target] = $package->getPrettyVersion();
  19878. }
  19879. }
  19880. $package->setSuggests($config['suggest']);
  19881. }
  19882. if (isset($config['autoload'])) {
  19883. $package->setAutoload($config['autoload']);
  19884. }
  19885. if (isset($config['autoload-dev'])) {
  19886. $package->setDevAutoload($config['autoload-dev']);
  19887. }
  19888. if (isset($config['include-path'])) {
  19889. $package->setIncludePaths($config['include-path']);
  19890. }
  19891. if (!empty($config['time'])) {
  19892. $time = preg_match('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  19893. try {
  19894. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  19895. $package->setReleaseDate($date);
  19896. } catch (\Exception $e) {
  19897. }
  19898. }
  19899. if (!empty($config['notification-url'])) {
  19900. $package->setNotificationUrl($config['notification-url']);
  19901. }
  19902. if (!empty($config['archive']['name'])) {
  19903. $package->setArchiveName($config['archive']['name']);
  19904. }
  19905. if (!empty($config['archive']['exclude'])) {
  19906. $package->setArchiveExcludes($config['archive']['exclude']);
  19907. }
  19908. if ($package instanceof Package\CompletePackageInterface) {
  19909. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  19910. foreach ($config['scripts'] as $event => $listeners) {
  19911. $config['scripts'][$event] = (array) $listeners;
  19912. }
  19913. if (isset($config['scripts']['composer'])) {
  19914. trigger_error('The `composer` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  19915. }
  19916. $package->setScripts($config['scripts']);
  19917. }
  19918. if (!empty($config['description']) && \is_string($config['description'])) {
  19919. $package->setDescription($config['description']);
  19920. }
  19921. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  19922. $package->setHomepage($config['homepage']);
  19923. }
  19924. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  19925. $package->setKeywords($config['keywords']);
  19926. }
  19927. if (!empty($config['license'])) {
  19928. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  19929. }
  19930. if (!empty($config['authors']) && \is_array($config['authors'])) {
  19931. $package->setAuthors($config['authors']);
  19932. }
  19933. if (isset($config['support'])) {
  19934. $package->setSupport($config['support']);
  19935. }
  19936. if (!empty($config['funding']) && \is_array($config['funding'])) {
  19937. $package->setFunding($config['funding']);
  19938. }
  19939. if (isset($config['abandoned'])) {
  19940. $package->setAbandoned($config['abandoned']);
  19941. }
  19942. }
  19943. if ($this->loadOptions && isset($config['transport-options'])) {
  19944. $package->setTransportOptions($config['transport-options']);
  19945. }
  19946. if ($aliasNormalized = $this->getBranchAlias($config)) {
  19947. $prettyAlias = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
  19948. if ($package instanceof RootPackageInterface) {
  19949. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  19950. }
  19951. return new AliasPackage($package, $aliasNormalized, $prettyAlias);
  19952. }
  19953. return $package;
  19954. }
  19955. private function configureCachedLinks(&$linkCache, $package, array $config)
  19956. {
  19957. $name = $package->getName();
  19958. $prettyVersion = $package->getPrettyVersion();
  19959. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19960. if (isset($config[$type])) {
  19961. $method = 'set'.ucfirst($opts['method']);
  19962. $links = array();
  19963. foreach ($config[$type] as $prettyTarget => $constraint) {
  19964. $target = strtolower($prettyTarget);
  19965. if ($constraint === 'self.version') {
  19966. $links[$target] = $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint);
  19967. } else {
  19968. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  19969. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint));
  19970. }
  19971. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  19972. $links[$target] = $link;
  19973. }
  19974. }
  19975. $package->{$method}($links);
  19976. }
  19977. }
  19978. }
  19979. public function parseLinks($source, $sourceVersion, $description, $links)
  19980. {
  19981. $res = array();
  19982. foreach ($links as $target => $constraint) {
  19983. $res[strtolower($target)] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  19984. }
  19985. return $res;
  19986. }
  19987. private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
  19988. {
  19989. if (!\is_string($prettyConstraint)) {
  19990. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  19991. }
  19992. if ('self.version' === $prettyConstraint) {
  19993. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  19994. } else {
  19995. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  19996. }
  19997. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  19998. }
  19999. public function getBranchAlias(array $config)
  20000. {
  20001. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  20002. return;
  20003. }
  20004. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  20005. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  20006. if ('-dev' !== substr($targetBranch, -4)) {
  20007. continue;
  20008. }
  20009. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  20010. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  20011. } else {
  20012. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  20013. }
  20014. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  20015. continue;
  20016. }
  20017. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  20018. continue;
  20019. }
  20020. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  20021. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  20022. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  20023. ) {
  20024. continue;
  20025. }
  20026. return $validatedTargetBranch;
  20027. }
  20028. }
  20029. if (
  20030. isset($config['default-branch'])
  20031. && $config['default-branch'] === true
  20032. && false === $this->versionParser->parseNumericAliasPrefix($config['version'])
  20033. ) {
  20034. return VersionParser::DEFAULT_BRANCH_ALIAS;
  20035. }
  20036. }
  20037. }
  20038. <?php
  20039. namespace Composer\Package\Loader;
  20040. class InvalidPackageException extends \Exception
  20041. {
  20042. private $errors;
  20043. private $warnings;
  20044. private $data;
  20045. public function __construct(array $errors, array $warnings, array $data)
  20046. {
  20047. $this->errors = $errors;
  20048. $this->warnings = $warnings;
  20049. $this->data = $data;
  20050. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  20051. }
  20052. public function getData()
  20053. {
  20054. return $this->data;
  20055. }
  20056. public function getErrors()
  20057. {
  20058. return $this->errors;
  20059. }
  20060. public function getWarnings()
  20061. {
  20062. return $this->warnings;
  20063. }
  20064. }
  20065. <?php
  20066. namespace Composer\Package\Loader;
  20067. use Composer\Json\JsonFile;
  20068. class JsonLoader
  20069. {
  20070. private $loader;
  20071. public function __construct(LoaderInterface $loader)
  20072. {
  20073. $this->loader = $loader;
  20074. }
  20075. public function load($json)
  20076. {
  20077. if ($json instanceof JsonFile) {
  20078. $config = $json->read();
  20079. } elseif (file_exists($json)) {
  20080. $config = JsonFile::parseJson(file_get_contents($json), $json);
  20081. } elseif (is_string($json)) {
  20082. $config = JsonFile::parseJson($json);
  20083. } else {
  20084. throw new \InvalidArgumentException(sprintf(
  20085. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  20086. gettype($json)
  20087. ));
  20088. }
  20089. return $this->loader->load($config);
  20090. }
  20091. }
  20092. <?php
  20093. namespace Composer\Package\Loader;
  20094. interface LoaderInterface
  20095. {
  20096. public function load(array $package, $class = 'Composer\Package\CompletePackage');
  20097. }
  20098. <?php
  20099. namespace Composer\Package\Loader;
  20100. use Composer\Package\BasePackage;
  20101. use Composer\Package\AliasPackage;
  20102. use Composer\Config;
  20103. use Composer\IO\IOInterface;
  20104. use Composer\Package\RootPackageInterface;
  20105. use Composer\Repository\RepositoryFactory;
  20106. use Composer\Package\Version\VersionGuesser;
  20107. use Composer\Package\Version\VersionParser;
  20108. use Composer\Package\RootPackage;
  20109. use Composer\Repository\RepositoryManager;
  20110. use Composer\Util\ProcessExecutor;
  20111. class RootPackageLoader extends ArrayLoader
  20112. {
  20113. private $manager;
  20114. private $config;
  20115. private $versionGuesser;
  20116. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  20117. {
  20118. parent::__construct($parser);
  20119. $this->manager = $manager;
  20120. $this->config = $config;
  20121. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  20122. }
  20123. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  20124. {
  20125. if (!isset($config['name'])) {
  20126. $config['name'] = '__root__';
  20127. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  20128. throw new \RuntimeException('Your package name '.$err);
  20129. }
  20130. $autoVersioned = false;
  20131. if (!isset($config['version'])) {
  20132. $commit = null;
  20133. if (getenv('COMPOSER_ROOT_VERSION')) {
  20134. $config['version'] = getenv('COMPOSER_ROOT_VERSION');
  20135. } else {
  20136. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  20137. if ($versionData) {
  20138. $config['version'] = $versionData['pretty_version'];
  20139. $config['version_normalized'] = $versionData['version'];
  20140. $commit = $versionData['commit'];
  20141. }
  20142. }
  20143. if (!isset($config['version'])) {
  20144. $config['version'] = '1.0.0';
  20145. $autoVersioned = true;
  20146. }
  20147. if ($commit) {
  20148. $config['source'] = array(
  20149. 'type' => '',
  20150. 'url' => '',
  20151. 'reference' => $commit,
  20152. );
  20153. $config['dist'] = array(
  20154. 'type' => '',
  20155. 'url' => '',
  20156. 'reference' => $commit,
  20157. );
  20158. }
  20159. }
  20160. $realPackage = $package = parent::load($config, $class);
  20161. if ($realPackage instanceof AliasPackage) {
  20162. $realPackage = $package->getAliasOf();
  20163. }
  20164. if ($autoVersioned) {
  20165. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  20166. }
  20167. if (isset($config['minimum-stability'])) {
  20168. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  20169. }
  20170. $aliases = array();
  20171. $stabilityFlags = array();
  20172. $references = array();
  20173. foreach (array('require', 'require-dev') as $linkType) {
  20174. if (isset($config[$linkType])) {
  20175. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  20176. $method = 'get'.ucfirst($linkInfo['method']);
  20177. $links = array();
  20178. foreach ($realPackage->$method() as $link) {
  20179. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  20180. }
  20181. $aliases = $this->extractAliases($links, $aliases);
  20182. $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
  20183. $references = $this->extractReferences($links, $references);
  20184. if (isset($links[$config['name']])) {
  20185. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  20186. 'Did you accidentally name your root package after an external package?', $config['name']));
  20187. }
  20188. }
  20189. }
  20190. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20191. if (isset($config[$linkType])) {
  20192. foreach ($config[$linkType] as $linkName => $constraint) {
  20193. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  20194. throw new \RuntimeException($linkType.'.'.$err);
  20195. }
  20196. }
  20197. }
  20198. }
  20199. $realPackage->setAliases($aliases);
  20200. $realPackage->setStabilityFlags($stabilityFlags);
  20201. $realPackage->setReferences($references);
  20202. if (isset($config['prefer-stable'])) {
  20203. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  20204. }
  20205. if (isset($config['config'])) {
  20206. $realPackage->setConfig($config['config']);
  20207. }
  20208. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  20209. foreach ($repos as $repo) {
  20210. $this->manager->addRepository($repo);
  20211. }
  20212. $realPackage->setRepositories($this->config->getRepositories());
  20213. return $package;
  20214. }
  20215. private function extractAliases(array $requires, array $aliases)
  20216. {
  20217. foreach ($requires as $reqName => $reqVersion) {
  20218. if (preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  20219. $aliases[] = array(
  20220. 'package' => strtolower($reqName),
  20221. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  20222. 'alias' => $match[2],
  20223. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  20224. );
  20225. } elseif (strpos($reqVersion, ' as ') !== false) {
  20226. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  20227. }
  20228. }
  20229. return $aliases;
  20230. }
  20231. private function extractStabilityFlags(array $requires, array $stabilityFlags, $minimumStability)
  20232. {
  20233. $stabilities = BasePackage::$stabilities;
  20234. $minimumStability = $stabilities[$minimumStability];
  20235. foreach ($requires as $reqName => $reqVersion) {
  20236. $constraints = array();
  20237. $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
  20238. foreach ($orSplit as $orConstraint) {
  20239. $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  20240. foreach ($andSplit as $andConstraint) {
  20241. $constraints[] = $andConstraint;
  20242. }
  20243. }
  20244. $match = false;
  20245. foreach ($constraints as $constraint) {
  20246. if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  20247. $name = strtolower($reqName);
  20248. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  20249. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  20250. continue;
  20251. }
  20252. $stabilityFlags[$name] = $stability;
  20253. $match = true;
  20254. }
  20255. }
  20256. if ($match) {
  20257. continue;
  20258. }
  20259. foreach ($constraints as $constraint) {
  20260. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  20261. if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  20262. $name = strtolower($reqName);
  20263. $stability = $stabilities[$stabilityName];
  20264. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  20265. continue;
  20266. }
  20267. $stabilityFlags[$name] = $stability;
  20268. }
  20269. }
  20270. }
  20271. return $stabilityFlags;
  20272. }
  20273. private function extractReferences(array $requires, array $references)
  20274. {
  20275. foreach ($requires as $reqName => $reqVersion) {
  20276. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  20277. if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  20278. $name = strtolower($reqName);
  20279. $references[$name] = $match[1];
  20280. }
  20281. }
  20282. return $references;
  20283. }
  20284. }
  20285. <?php
  20286. namespace Composer\Package\Loader;
  20287. use Composer\Package\BasePackage;
  20288. use Composer\Semver\Constraint\Constraint;
  20289. use Composer\Package\Version\VersionParser;
  20290. use Composer\Repository\PlatformRepository;
  20291. use Composer\Spdx\SpdxLicenses;
  20292. class ValidatingArrayLoader implements LoaderInterface
  20293. {
  20294. const CHECK_ALL = 3;
  20295. const CHECK_UNBOUND_CONSTRAINTS = 1;
  20296. const CHECK_STRICT_CONSTRAINTS = 2;
  20297. private $loader;
  20298. private $versionParser;
  20299. private $errors;
  20300. private $warnings;
  20301. private $config;
  20302. private $strictName;
  20303. private $flags;
  20304. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  20305. {
  20306. $this->loader = $loader;
  20307. $this->versionParser = $parser ?: new VersionParser();
  20308. $this->strictName = $strictName;
  20309. $this->flags = $flags;
  20310. }
  20311. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  20312. {
  20313. $this->errors = array();
  20314. $this->warnings = array();
  20315. $this->config = $config;
  20316. if ($err = self::hasPackageNamingError($config['name'])) {
  20317. $this->warnings[] = 'Deprecation warning: Your package name '.$err.' Make sure you fix this as Composer 2.0 will error.';
  20318. }
  20319. if ($this->strictName) {
  20320. $this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
  20321. } else {
  20322. $this->validateString('name', true);
  20323. }
  20324. if (!empty($this->config['version'])) {
  20325. try {
  20326. $this->versionParser->normalize($this->config['version']);
  20327. } catch (\Exception $e) {
  20328. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  20329. unset($this->config['version']);
  20330. }
  20331. }
  20332. if (!empty($this->config['config']['platform'])) {
  20333. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  20334. try {
  20335. $this->versionParser->normalize($platform);
  20336. } catch (\Exception $e) {
  20337. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  20338. }
  20339. }
  20340. }
  20341. $this->validateRegex('type', '[A-Za-z0-9-]+');
  20342. $this->validateString('target-dir');
  20343. $this->validateArray('extra');
  20344. if (isset($this->config['bin'])) {
  20345. if (is_string($this->config['bin'])) {
  20346. $this->validateString('bin');
  20347. } else {
  20348. $this->validateFlatArray('bin');
  20349. }
  20350. }
  20351. $this->validateArray('scripts');
  20352. $this->validateString('description');
  20353. $this->validateUrl('homepage');
  20354. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  20355. $releaseDate = null;
  20356. $this->validateString('time');
  20357. if (!empty($this->config['time'])) {
  20358. try {
  20359. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  20360. } catch (\Exception $e) {
  20361. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  20362. unset($this->config['time']);
  20363. }
  20364. }
  20365. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  20366. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  20367. $licenses = (array) $this->config['license'];
  20368. $licenseValidator = new SpdxLicenses();
  20369. foreach ($licenses as $license) {
  20370. if ('proprietary' === $license) {
  20371. continue;
  20372. }
  20373. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  20374. if (!$licenseValidator->validate($licenseToValidate)) {
  20375. if ($licenseValidator->validate(trim($licenseToValidate))) {
  20376. $this->warnings[] = sprintf(
  20377. 'License %s must not contain extra spaces, make sure to trim it.',
  20378. json_encode($license)
  20379. );
  20380. } else {
  20381. $this->warnings[] = sprintf(
  20382. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  20383. 'If the software is closed-source, you may use "proprietary" as license.',
  20384. json_encode($license)
  20385. );
  20386. }
  20387. }
  20388. }
  20389. }
  20390. }
  20391. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  20392. foreach ($this->config['authors'] as $key => $author) {
  20393. if (!is_array($author)) {
  20394. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  20395. unset($this->config['authors'][$key]);
  20396. continue;
  20397. }
  20398. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  20399. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  20400. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  20401. unset($this->config['authors'][$key][$authorData]);
  20402. }
  20403. }
  20404. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  20405. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  20406. unset($this->config['authors'][$key]['homepage']);
  20407. }
  20408. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  20409. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  20410. unset($this->config['authors'][$key]['email']);
  20411. }
  20412. if (empty($this->config['authors'][$key])) {
  20413. unset($this->config['authors'][$key]);
  20414. }
  20415. }
  20416. if (empty($this->config['authors'])) {
  20417. unset($this->config['authors']);
  20418. }
  20419. }
  20420. if ($this->validateArray('support') && !empty($this->config['support'])) {
  20421. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  20422. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  20423. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  20424. unset($this->config['support'][$key]);
  20425. }
  20426. }
  20427. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  20428. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  20429. unset($this->config['support']['email']);
  20430. }
  20431. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc'))) {
  20432. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> URL';
  20433. unset($this->config['support']['irc']);
  20434. }
  20435. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  20436. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  20437. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  20438. unset($this->config['support'][$key]);
  20439. }
  20440. }
  20441. if (empty($this->config['support'])) {
  20442. unset($this->config['support']);
  20443. }
  20444. }
  20445. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  20446. foreach ($this->config['funding'] as $key => $fundingOption) {
  20447. if (!is_array($fundingOption)) {
  20448. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  20449. unset($this->config['funding'][$key]);
  20450. continue;
  20451. }
  20452. foreach (array('type', 'url') as $fundingData) {
  20453. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  20454. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  20455. unset($this->config['funding'][$key][$fundingData]);
  20456. }
  20457. }
  20458. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  20459. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  20460. unset($this->config['funding'][$key]['url']);
  20461. }
  20462. if (empty($this->config['funding'][$key])) {
  20463. unset($this->config['funding'][$key]);
  20464. }
  20465. }
  20466. if (empty($this->config['funding'])) {
  20467. unset($this->config['funding']);
  20468. }
  20469. }
  20470. $unboundConstraint = new Constraint('=', '10000000-dev');
  20471. $stableConstraint = new Constraint('=', '1.0.0');
  20472. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20473. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  20474. foreach ($this->config[$linkType] as $package => $constraint) {
  20475. if ($err = self::hasPackageNamingError($package, true)) {
  20476. $this->warnings[] = 'Deprecation warning: '.$linkType.'.'.$err.' Make sure you fix this as Composer 2.0 will error.';
  20477. } elseif (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
  20478. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  20479. }
  20480. if (!is_string($constraint)) {
  20481. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  20482. unset($this->config[$linkType][$package]);
  20483. } elseif ('self.version' !== $constraint) {
  20484. try {
  20485. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  20486. } catch (\Exception $e) {
  20487. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  20488. unset($this->config[$linkType][$package]);
  20489. continue;
  20490. }
  20491. if (
  20492. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  20493. && 'require' === $linkType
  20494. && $linkConstraint->matches($unboundConstraint)
  20495. && !PlatformRepository::isPlatformPackage($package)
  20496. ) {
  20497. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  20498. } elseif (
  20499. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  20500. && 'require' === $linkType
  20501. && strpos($linkConstraint, '=') === 0
  20502. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  20503. ) {
  20504. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  20505. }
  20506. }
  20507. }
  20508. }
  20509. }
  20510. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  20511. foreach ($this->config['suggest'] as $package => $description) {
  20512. if (!is_string($description)) {
  20513. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  20514. unset($this->config['suggest'][$package]);
  20515. }
  20516. }
  20517. }
  20518. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  20519. if (!isset(BasePackage::$stabilities[$this->config['minimum-stability']])) {
  20520. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  20521. unset($this->config['minimum-stability']);
  20522. }
  20523. }
  20524. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  20525. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  20526. foreach ($this->config['autoload'] as $type => $typeConfig) {
  20527. if (!in_array($type, $types)) {
  20528. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  20529. unset($this->config['autoload'][$type]);
  20530. }
  20531. if ($type === 'psr-4') {
  20532. foreach ($typeConfig as $namespace => $dirs) {
  20533. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  20534. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  20535. }
  20536. }
  20537. }
  20538. }
  20539. }
  20540. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  20541. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  20542. unset($this->config['autoload']['psr-4']);
  20543. }
  20544. $this->validateFlatArray('include-path');
  20545. $this->validateArray('transport-options');
  20546. if (isset($this->config['extra']['branch-alias'])) {
  20547. if (!is_array($this->config['extra']['branch-alias'])) {
  20548. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  20549. } else {
  20550. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  20551. if ('-dev' !== substr($targetBranch, -4)) {
  20552. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  20553. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20554. continue;
  20555. }
  20556. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  20557. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  20558. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  20559. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20560. continue;
  20561. }
  20562. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  20563. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  20564. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  20565. ) {
  20566. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  20567. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20568. }
  20569. }
  20570. }
  20571. }
  20572. if ($this->errors) {
  20573. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  20574. }
  20575. $package = $this->loader->load($this->config, $class);
  20576. $this->config = null;
  20577. return $package;
  20578. }
  20579. public function getWarnings()
  20580. {
  20581. return $this->warnings;
  20582. }
  20583. public function getErrors()
  20584. {
  20585. return $this->errors;
  20586. }
  20587. public static function hasPackageNamingError($name, $isLink = false)
  20588. {
  20589. if (PlatformRepository::isPlatformPackage($name)) {
  20590. return;
  20591. }
  20592. if (!preg_match('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  20593. 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]+)*$".';
  20594. }
  20595. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  20596. $bits = explode('/', strtolower($name));
  20597. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  20598. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  20599. }
  20600. if (preg_match('{\.json$}', $name)) {
  20601. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  20602. }
  20603. if (preg_match('{[A-Z]}', $name)) {
  20604. if ($isLink) {
  20605. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  20606. }
  20607. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  20608. $suggestName = strtolower($suggestName);
  20609. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  20610. }
  20611. }
  20612. private function validateRegex($property, $regex, $mandatory = false)
  20613. {
  20614. if (!$this->validateString($property, $mandatory)) {
  20615. return false;
  20616. }
  20617. if (!preg_match('{^'.$regex.'$}u', $this->config[$property])) {
  20618. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  20619. if ($mandatory) {
  20620. $this->errors[] = $message;
  20621. } else {
  20622. $this->warnings[] = $message;
  20623. }
  20624. unset($this->config[$property]);
  20625. return false;
  20626. }
  20627. return true;
  20628. }
  20629. private function validateString($property, $mandatory = false)
  20630. {
  20631. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  20632. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  20633. unset($this->config[$property]);
  20634. return false;
  20635. }
  20636. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  20637. if ($mandatory) {
  20638. $this->errors[] = $property.' : must be present';
  20639. }
  20640. unset($this->config[$property]);
  20641. return false;
  20642. }
  20643. return true;
  20644. }
  20645. private function validateArray($property, $mandatory = false)
  20646. {
  20647. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  20648. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  20649. unset($this->config[$property]);
  20650. return false;
  20651. }
  20652. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  20653. if ($mandatory) {
  20654. $this->errors[] = $property.' : must be present and contain at least one element';
  20655. }
  20656. unset($this->config[$property]);
  20657. return false;
  20658. }
  20659. return true;
  20660. }
  20661. private function validateFlatArray($property, $regex = null, $mandatory = false)
  20662. {
  20663. if (!$this->validateArray($property, $mandatory)) {
  20664. return false;
  20665. }
  20666. $pass = true;
  20667. foreach ($this->config[$property] as $key => $value) {
  20668. if (!is_string($value) && !is_numeric($value)) {
  20669. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  20670. unset($this->config[$property][$key]);
  20671. $pass = false;
  20672. continue;
  20673. }
  20674. if ($regex && !preg_match('{^'.$regex.'$}u', $value)) {
  20675. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  20676. unset($this->config[$property][$key]);
  20677. $pass = false;
  20678. }
  20679. }
  20680. return $pass;
  20681. }
  20682. private function validateUrl($property, $mandatory = false)
  20683. {
  20684. if (!$this->validateString($property, $mandatory)) {
  20685. return false;
  20686. }
  20687. if (!$this->filterUrl($this->config[$property])) {
  20688. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  20689. unset($this->config[$property]);
  20690. return false;
  20691. }
  20692. return true;
  20693. }
  20694. private function filterUrl($value, array $schemes = array('http', 'https'))
  20695. {
  20696. if ($value === '') {
  20697. return true;
  20698. }
  20699. $bits = parse_url($value);
  20700. if (empty($bits['scheme']) || empty($bits['host'])) {
  20701. return false;
  20702. }
  20703. if (!in_array($bits['scheme'], $schemes, true)) {
  20704. return false;
  20705. }
  20706. return true;
  20707. }
  20708. }
  20709. <?php
  20710. namespace Composer\Package;
  20711. use Composer\Json\JsonFile;
  20712. use Composer\Installer\InstallationManager;
  20713. use Composer\Repository\LockArrayRepository;
  20714. use Composer\Util\ProcessExecutor;
  20715. use Composer\Package\Dumper\ArrayDumper;
  20716. use Composer\Package\Loader\ArrayLoader;
  20717. use Composer\Package\Version\VersionParser;
  20718. use Composer\Plugin\PluginInterface;
  20719. use Composer\Util\Git as GitUtil;
  20720. use Composer\IO\IOInterface;
  20721. use Seld\JsonLint\ParsingException;
  20722. class Locker
  20723. {
  20724. private $lockFile;
  20725. private $installationManager;
  20726. private $hash;
  20727. private $contentHash;
  20728. private $loader;
  20729. private $dumper;
  20730. private $process;
  20731. private $lockDataCache;
  20732. private $virtualFileWritten;
  20733. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents, ProcessExecutor $process = null)
  20734. {
  20735. $this->lockFile = $lockFile;
  20736. $this->installationManager = $installationManager;
  20737. $this->hash = md5($composerFileContents);
  20738. $this->contentHash = self::getContentHash($composerFileContents);
  20739. $this->loader = new ArrayLoader(null, true);
  20740. $this->dumper = new ArrayDumper();
  20741. $this->process = $process ?: new ProcessExecutor($io);
  20742. }
  20743. public static function getContentHash($composerFileContents)
  20744. {
  20745. $content = json_decode($composerFileContents, true);
  20746. $relevantKeys = array(
  20747. 'name',
  20748. 'version',
  20749. 'require',
  20750. 'require-dev',
  20751. 'conflict',
  20752. 'replace',
  20753. 'provide',
  20754. 'minimum-stability',
  20755. 'prefer-stable',
  20756. 'repositories',
  20757. 'extra',
  20758. );
  20759. $relevantContent = array();
  20760. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  20761. $relevantContent[$key] = $content[$key];
  20762. }
  20763. if (isset($content['config']['platform'])) {
  20764. $relevantContent['config']['platform'] = $content['config']['platform'];
  20765. }
  20766. ksort($relevantContent);
  20767. return md5(json_encode($relevantContent));
  20768. }
  20769. public function isLocked()
  20770. {
  20771. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  20772. return false;
  20773. }
  20774. $data = $this->getLockData();
  20775. return isset($data['packages']);
  20776. }
  20777. public function isFresh()
  20778. {
  20779. $lock = $this->lockFile->read();
  20780. if (!empty($lock['content-hash'])) {
  20781. return $this->contentHash === $lock['content-hash'];
  20782. }
  20783. if (!empty($lock['hash'])) {
  20784. return $this->hash === $lock['hash'];
  20785. }
  20786. return false;
  20787. }
  20788. public function getLockedRepository($withDevReqs = false)
  20789. {
  20790. $lockData = $this->getLockData();
  20791. $packages = new LockArrayRepository();
  20792. $lockedPackages = $lockData['packages'];
  20793. if ($withDevReqs) {
  20794. if (isset($lockData['packages-dev'])) {
  20795. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  20796. } else {
  20797. 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.');
  20798. }
  20799. }
  20800. if (empty($lockedPackages)) {
  20801. return $packages;
  20802. }
  20803. if (isset($lockedPackages[0]['name'])) {
  20804. $packageByName = array();
  20805. foreach ($lockedPackages as $info) {
  20806. $package = $this->loader->load($info);
  20807. $packages->addPackage($package);
  20808. $packageByName[$package->getName()] = $package;
  20809. if ($package instanceof AliasPackage) {
  20810. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  20811. }
  20812. }
  20813. if (isset($lockData['aliases'])) {
  20814. foreach ($lockData['aliases'] as $alias) {
  20815. if (isset($packageByName[$alias['package']])) {
  20816. $aliasPkg = new AliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  20817. $aliasPkg->setRootPackageAlias(true);
  20818. $packages->addPackage($aliasPkg);
  20819. }
  20820. }
  20821. }
  20822. return $packages;
  20823. }
  20824. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  20825. }
  20826. public function getDevPackageNames()
  20827. {
  20828. $names = array();
  20829. $lockData = $this->getLockData();
  20830. if (isset($lockData['packages-dev'])) {
  20831. foreach ($lockData['packages-dev'] as $package) {
  20832. $names[] = strtolower($package['name']);
  20833. }
  20834. }
  20835. return $names;
  20836. }
  20837. public function getPlatformRequirements($withDevReqs = false)
  20838. {
  20839. $lockData = $this->getLockData();
  20840. $requirements = array();
  20841. if (!empty($lockData['platform'])) {
  20842. $requirements = $this->loader->parseLinks(
  20843. '__root__',
  20844. '1.0.0',
  20845. Link::TYPE_REQUIRE,
  20846. isset($lockData['platform']) ? $lockData['platform'] : array()
  20847. );
  20848. }
  20849. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  20850. $devRequirements = $this->loader->parseLinks(
  20851. '__root__',
  20852. '1.0.0',
  20853. Link::TYPE_REQUIRE,
  20854. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  20855. );
  20856. $requirements = array_merge($requirements, $devRequirements);
  20857. }
  20858. return $requirements;
  20859. }
  20860. public function getMinimumStability()
  20861. {
  20862. $lockData = $this->getLockData();
  20863. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  20864. }
  20865. public function getStabilityFlags()
  20866. {
  20867. $lockData = $this->getLockData();
  20868. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  20869. }
  20870. public function getPreferStable()
  20871. {
  20872. $lockData = $this->getLockData();
  20873. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  20874. }
  20875. public function getPreferLowest()
  20876. {
  20877. $lockData = $this->getLockData();
  20878. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  20879. }
  20880. public function getPlatformOverrides()
  20881. {
  20882. $lockData = $this->getLockData();
  20883. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  20884. }
  20885. public function getAliases()
  20886. {
  20887. $lockData = $this->getLockData();
  20888. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  20889. }
  20890. public function getLockData()
  20891. {
  20892. if (null !== $this->lockDataCache) {
  20893. return $this->lockDataCache;
  20894. }
  20895. if (!$this->lockFile->exists()) {
  20896. throw new \LogicException('No lockfile found. Unable to read locked packages');
  20897. }
  20898. return $this->lockDataCache = $this->lockFile->read();
  20899. }
  20900. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
  20901. {
  20902. $aliases = array_map(function ($alias) {
  20903. if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  20904. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  20905. }
  20906. return $alias;
  20907. }, $aliases);
  20908. $lock = array(
  20909. '_readme' => array('This file locks the dependencies of your project to a known state',
  20910. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  20911. 'This file is @gener'.'ated automatically', ),
  20912. 'content-hash' => $this->contentHash,
  20913. 'packages' => null,
  20914. 'packages-dev' => null,
  20915. 'aliases' => $aliases,
  20916. 'minimum-stability' => $minimumStability,
  20917. 'stability-flags' => $stabilityFlags,
  20918. 'prefer-stable' => $preferStable,
  20919. 'prefer-lowest' => $preferLowest,
  20920. );
  20921. $lock['packages'] = $this->lockPackages($packages);
  20922. if (null !== $devPackages) {
  20923. $lock['packages-dev'] = $this->lockPackages($devPackages);
  20924. }
  20925. $lock['platform'] = $platformReqs;
  20926. $lock['platform-dev'] = $platformDevReqs;
  20927. if ($platformOverrides) {
  20928. $lock['platform-overrides'] = $platformOverrides;
  20929. }
  20930. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  20931. try {
  20932. $isLocked = $this->isLocked();
  20933. } catch (ParsingException $e) {
  20934. $isLocked = false;
  20935. }
  20936. if (!$isLocked || $lock !== $this->getLockData()) {
  20937. if ($write) {
  20938. $this->lockFile->write($lock);
  20939. $this->lockDataCache = null;
  20940. $this->virtualFileWritten = false;
  20941. } else {
  20942. $this->virtualFileWritten = true;
  20943. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT));
  20944. }
  20945. return true;
  20946. }
  20947. return false;
  20948. }
  20949. private function lockPackages(array $packages)
  20950. {
  20951. $locked = array();
  20952. foreach ($packages as $package) {
  20953. if ($package instanceof AliasPackage) {
  20954. continue;
  20955. }
  20956. $name = $package->getPrettyName();
  20957. $version = $package->getPrettyVersion();
  20958. if (!$name || !$version) {
  20959. throw new \LogicException(sprintf(
  20960. 'Package "%s" has no version or name and can not be locked',
  20961. $package
  20962. ));
  20963. }
  20964. $spec = $this->dumper->dump($package);
  20965. unset($spec['version_normalized']);
  20966. $time = isset($spec['time']) ? $spec['time'] : null;
  20967. unset($spec['time']);
  20968. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  20969. $time = $this->getPackageTime($package) ?: $time;
  20970. }
  20971. if (null !== $time) {
  20972. $spec['time'] = $time;
  20973. }
  20974. unset($spec['installation-source']);
  20975. $locked[] = $spec;
  20976. }
  20977. usort($locked, function ($a, $b) {
  20978. $comparison = strcmp($a['name'], $b['name']);
  20979. if (0 !== $comparison) {
  20980. return $comparison;
  20981. }
  20982. return strcmp($a['version'], $b['version']);
  20983. });
  20984. return $locked;
  20985. }
  20986. private function getPackageTime(PackageInterface $package)
  20987. {
  20988. if (!function_exists('proc_open')) {
  20989. return null;
  20990. }
  20991. $path = realpath($this->installationManager->getInstallPath($package));
  20992. $sourceType = $package->getSourceType();
  20993. $datetime = null;
  20994. if ($path && in_array($sourceType, array('git', 'hg'))) {
  20995. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  20996. switch ($sourceType) {
  20997. case 'git':
  20998. GitUtil::cleanEnv();
  20999. 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)) {
  21000. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  21001. }
  21002. break;
  21003. case 'hg':
  21004. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) {
  21005. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  21006. }
  21007. break;
  21008. }
  21009. }
  21010. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  21011. }
  21012. }
  21013. <?php
  21014. namespace Composer\Package;
  21015. use Composer\Package\Version\VersionParser;
  21016. use Composer\Util\ComposerMirror;
  21017. class Package extends BasePackage
  21018. {
  21019. protected $type;
  21020. protected $targetDir;
  21021. protected $installationSource;
  21022. protected $sourceType;
  21023. protected $sourceUrl;
  21024. protected $sourceReference;
  21025. protected $sourceMirrors;
  21026. protected $distType;
  21027. protected $distUrl;
  21028. protected $distReference;
  21029. protected $distSha1Checksum;
  21030. protected $distMirrors;
  21031. protected $version;
  21032. protected $prettyVersion;
  21033. protected $releaseDate;
  21034. protected $extra = array();
  21035. protected $binaries = array();
  21036. protected $dev;
  21037. protected $stability;
  21038. protected $notificationUrl;
  21039. protected $requires = array();
  21040. protected $conflicts = array();
  21041. protected $provides = array();
  21042. protected $replaces = array();
  21043. protected $devRequires = array();
  21044. protected $suggests = array();
  21045. protected $autoload = array();
  21046. protected $devAutoload = array();
  21047. protected $includePaths = array();
  21048. protected $archiveName;
  21049. protected $archiveExcludes = array();
  21050. protected $isDefaultBranch = false;
  21051. public function __construct($name, $version, $prettyVersion)
  21052. {
  21053. parent::__construct($name);
  21054. $this->version = $version;
  21055. $this->prettyVersion = $prettyVersion;
  21056. $this->stability = VersionParser::parseStability($version);
  21057. $this->dev = $this->stability === 'dev';
  21058. }
  21059. public function isDev()
  21060. {
  21061. return $this->dev;
  21062. }
  21063. public function setType($type)
  21064. {
  21065. $this->type = $type;
  21066. }
  21067. public function getType()
  21068. {
  21069. return $this->type ?: 'library';
  21070. }
  21071. public function getStability()
  21072. {
  21073. return $this->stability;
  21074. }
  21075. public function setTargetDir($targetDir)
  21076. {
  21077. $this->targetDir = $targetDir;
  21078. }
  21079. public function getTargetDir()
  21080. {
  21081. if (null === $this->targetDir) {
  21082. return;
  21083. }
  21084. return ltrim(preg_replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  21085. }
  21086. public function setExtra(array $extra)
  21087. {
  21088. $this->extra = $extra;
  21089. }
  21090. public function getExtra()
  21091. {
  21092. return $this->extra;
  21093. }
  21094. public function setBinaries(array $binaries)
  21095. {
  21096. $this->binaries = $binaries;
  21097. }
  21098. public function getBinaries()
  21099. {
  21100. return $this->binaries;
  21101. }
  21102. public function setInstallationSource($type)
  21103. {
  21104. $this->installationSource = $type;
  21105. }
  21106. public function getInstallationSource()
  21107. {
  21108. return $this->installationSource;
  21109. }
  21110. public function setSourceType($type)
  21111. {
  21112. $this->sourceType = $type;
  21113. }
  21114. public function getSourceType()
  21115. {
  21116. return $this->sourceType;
  21117. }
  21118. public function setSourceUrl($url)
  21119. {
  21120. $this->sourceUrl = $url;
  21121. }
  21122. public function getSourceUrl()
  21123. {
  21124. return $this->sourceUrl;
  21125. }
  21126. public function setSourceReference($reference)
  21127. {
  21128. $this->sourceReference = $reference;
  21129. }
  21130. public function getSourceReference()
  21131. {
  21132. return $this->sourceReference;
  21133. }
  21134. public function setSourceMirrors($mirrors)
  21135. {
  21136. $this->sourceMirrors = $mirrors;
  21137. }
  21138. public function getSourceMirrors()
  21139. {
  21140. return $this->sourceMirrors;
  21141. }
  21142. public function getSourceUrls()
  21143. {
  21144. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  21145. }
  21146. public function setDistType($type)
  21147. {
  21148. $this->distType = $type;
  21149. }
  21150. public function getDistType()
  21151. {
  21152. return $this->distType;
  21153. }
  21154. public function setDistUrl($url)
  21155. {
  21156. $this->distUrl = $url;
  21157. }
  21158. public function getDistUrl()
  21159. {
  21160. return $this->distUrl;
  21161. }
  21162. public function setDistReference($reference)
  21163. {
  21164. $this->distReference = $reference;
  21165. }
  21166. public function getDistReference()
  21167. {
  21168. return $this->distReference;
  21169. }
  21170. public function setDistSha1Checksum($sha1checksum)
  21171. {
  21172. $this->distSha1Checksum = $sha1checksum;
  21173. }
  21174. public function getDistSha1Checksum()
  21175. {
  21176. return $this->distSha1Checksum;
  21177. }
  21178. public function setDistMirrors($mirrors)
  21179. {
  21180. $this->distMirrors = $mirrors;
  21181. }
  21182. public function getDistMirrors()
  21183. {
  21184. return $this->distMirrors;
  21185. }
  21186. public function getDistUrls()
  21187. {
  21188. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  21189. }
  21190. public function getVersion()
  21191. {
  21192. return $this->version;
  21193. }
  21194. public function getPrettyVersion()
  21195. {
  21196. return $this->prettyVersion;
  21197. }
  21198. public function setReleaseDate(\DateTime $releaseDate)
  21199. {
  21200. $this->releaseDate = $releaseDate;
  21201. }
  21202. public function getReleaseDate()
  21203. {
  21204. return $this->releaseDate;
  21205. }
  21206. public function setRequires(array $requires)
  21207. {
  21208. $this->requires = $requires;
  21209. }
  21210. public function getRequires()
  21211. {
  21212. return $this->requires;
  21213. }
  21214. public function setConflicts(array $conflicts)
  21215. {
  21216. $this->conflicts = $conflicts;
  21217. }
  21218. public function getConflicts()
  21219. {
  21220. return $this->conflicts;
  21221. }
  21222. public function setProvides(array $provides)
  21223. {
  21224. $this->provides = $provides;
  21225. }
  21226. public function getProvides()
  21227. {
  21228. return $this->provides;
  21229. }
  21230. public function setReplaces(array $replaces)
  21231. {
  21232. $this->replaces = $replaces;
  21233. }
  21234. public function getReplaces()
  21235. {
  21236. return $this->replaces;
  21237. }
  21238. public function setDevRequires(array $devRequires)
  21239. {
  21240. $this->devRequires = $devRequires;
  21241. }
  21242. public function getDevRequires()
  21243. {
  21244. return $this->devRequires;
  21245. }
  21246. public function setSuggests(array $suggests)
  21247. {
  21248. $this->suggests = $suggests;
  21249. }
  21250. public function getSuggests()
  21251. {
  21252. return $this->suggests;
  21253. }
  21254. public function setAutoload(array $autoload)
  21255. {
  21256. $this->autoload = $autoload;
  21257. }
  21258. public function getAutoload()
  21259. {
  21260. return $this->autoload;
  21261. }
  21262. public function setDevAutoload(array $devAutoload)
  21263. {
  21264. $this->devAutoload = $devAutoload;
  21265. }
  21266. public function getDevAutoload()
  21267. {
  21268. return $this->devAutoload;
  21269. }
  21270. public function setIncludePaths(array $includePaths)
  21271. {
  21272. $this->includePaths = $includePaths;
  21273. }
  21274. public function getIncludePaths()
  21275. {
  21276. return $this->includePaths;
  21277. }
  21278. public function setNotificationUrl($notificationUrl)
  21279. {
  21280. $this->notificationUrl = $notificationUrl;
  21281. }
  21282. public function getNotificationUrl()
  21283. {
  21284. return $this->notificationUrl;
  21285. }
  21286. public function setArchiveName($name)
  21287. {
  21288. $this->archiveName = $name;
  21289. }
  21290. public function getArchiveName()
  21291. {
  21292. return $this->archiveName;
  21293. }
  21294. public function setArchiveExcludes(array $excludes)
  21295. {
  21296. $this->archiveExcludes = $excludes;
  21297. }
  21298. public function getArchiveExcludes()
  21299. {
  21300. return $this->archiveExcludes;
  21301. }
  21302. public function setIsDefaultBranch($defaultBranch)
  21303. {
  21304. $this->isDefaultBranch = $defaultBranch;
  21305. }
  21306. public function isDefaultBranch()
  21307. {
  21308. return $this->isDefaultBranch;
  21309. }
  21310. public function setSourceDistReferences($reference)
  21311. {
  21312. $this->setSourceReference($reference);
  21313. if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())) {
  21314. $this->setDistReference($reference);
  21315. $this->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  21316. } elseif ($this->getDistReference()) {
  21317. $this->setDistReference($reference);
  21318. }
  21319. }
  21320. public function replaceVersion($version, $prettyVersion)
  21321. {
  21322. $this->version = $version;
  21323. $this->prettyVersion = $prettyVersion;
  21324. $this->stability = VersionParser::parseStability($version);
  21325. $this->dev = $this->stability === 'dev';
  21326. }
  21327. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  21328. {
  21329. if (!$url) {
  21330. return array();
  21331. }
  21332. $urls = array($url);
  21333. if ($mirrors) {
  21334. foreach ($mirrors as $mirror) {
  21335. if ($urlType === 'dist') {
  21336. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
  21337. } elseif ($urlType === 'source' && $type === 'git') {
  21338. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  21339. } elseif ($urlType === 'source' && $type === 'hg') {
  21340. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  21341. } else {
  21342. continue;
  21343. }
  21344. if (!\in_array($mirrorUrl, $urls)) {
  21345. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  21346. $func($urls, $mirrorUrl);
  21347. }
  21348. }
  21349. }
  21350. return $urls;
  21351. }
  21352. }
  21353. <?php
  21354. namespace Composer\Package;
  21355. use Composer\Repository\RepositoryInterface;
  21356. interface PackageInterface
  21357. {
  21358. const DISPLAY_SOURCE_REF_IF_DEV = 0;
  21359. const DISPLAY_SOURCE_REF = 1;
  21360. const DISPLAY_DIST_REF = 2;
  21361. public function getName();
  21362. public function getPrettyName();
  21363. public function getNames($provides = true);
  21364. public function setId($id);
  21365. public function getId();
  21366. public function isDev();
  21367. public function getType();
  21368. public function getTargetDir();
  21369. public function getExtra();
  21370. public function setInstallationSource($type);
  21371. public function getInstallationSource();
  21372. public function getSourceType();
  21373. public function getSourceUrl();
  21374. public function getSourceUrls();
  21375. public function getSourceReference();
  21376. public function getSourceMirrors();
  21377. public function getDistType();
  21378. public function getDistUrl();
  21379. public function getDistUrls();
  21380. public function getDistReference();
  21381. public function getDistSha1Checksum();
  21382. public function getDistMirrors();
  21383. public function getVersion();
  21384. public function getPrettyVersion();
  21385. public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
  21386. public function getReleaseDate();
  21387. public function getStability();
  21388. public function getRequires();
  21389. public function getConflicts();
  21390. public function getProvides();
  21391. public function getReplaces();
  21392. public function getDevRequires();
  21393. public function getSuggests();
  21394. public function getAutoload();
  21395. public function getDevAutoload();
  21396. public function getIncludePaths();
  21397. public function setRepository(RepositoryInterface $repository);
  21398. public function getRepository();
  21399. public function getBinaries();
  21400. public function getUniqueName();
  21401. public function getNotificationUrl();
  21402. public function __toString();
  21403. public function getPrettyString();
  21404. public function getArchiveName();
  21405. public function getArchiveExcludes();
  21406. public function isDefaultBranch();
  21407. public function getTransportOptions();
  21408. public function setSourceReference($reference);
  21409. public function setDistUrl($url);
  21410. public function setDistType($type);
  21411. public function setDistReference($reference);
  21412. public function setSourceDistReferences($reference);
  21413. }
  21414. <?php
  21415. namespace Composer\Package;
  21416. class RootAliasPackage extends AliasPackage implements RootPackageInterface
  21417. {
  21418. public function __construct(RootPackageInterface $aliasOf, $version, $prettyVersion)
  21419. {
  21420. parent::__construct($aliasOf, $version, $prettyVersion);
  21421. }
  21422. public function getAliases()
  21423. {
  21424. return $this->aliasOf->getAliases();
  21425. }
  21426. public function getMinimumStability()
  21427. {
  21428. return $this->aliasOf->getMinimumStability();
  21429. }
  21430. public function getStabilityFlags()
  21431. {
  21432. return $this->aliasOf->getStabilityFlags();
  21433. }
  21434. public function getReferences()
  21435. {
  21436. return $this->aliasOf->getReferences();
  21437. }
  21438. public function getPreferStable()
  21439. {
  21440. return $this->aliasOf->getPreferStable();
  21441. }
  21442. public function getConfig()
  21443. {
  21444. return $this->aliasOf->getConfig();
  21445. }
  21446. public function setRequires(array $require)
  21447. {
  21448. $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
  21449. $this->aliasOf->setRequires($require);
  21450. }
  21451. public function setDevRequires(array $devRequire)
  21452. {
  21453. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
  21454. $this->aliasOf->setDevRequires($devRequire);
  21455. }
  21456. public function setConflicts(array $conflicts)
  21457. {
  21458. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  21459. $this->aliasOf->setConflicts($conflicts);
  21460. }
  21461. public function setProvides(array $provides)
  21462. {
  21463. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  21464. $this->aliasOf->setProvides($provides);
  21465. }
  21466. public function setReplaces(array $replaces)
  21467. {
  21468. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  21469. $this->aliasOf->setReplaces($replaces);
  21470. }
  21471. public function setRepositories($repositories)
  21472. {
  21473. $this->aliasOf->setRepositories($repositories);
  21474. }
  21475. public function setAutoload(array $autoload)
  21476. {
  21477. $this->aliasOf->setAutoload($autoload);
  21478. }
  21479. public function setDevAutoload(array $devAutoload)
  21480. {
  21481. $this->aliasOf->setDevAutoload($devAutoload);
  21482. }
  21483. public function setStabilityFlags(array $stabilityFlags)
  21484. {
  21485. $this->aliasOf->setStabilityFlags($stabilityFlags);
  21486. }
  21487. public function setSuggests(array $suggests)
  21488. {
  21489. $this->aliasOf->setSuggests($suggests);
  21490. }
  21491. public function setExtra(array $extra)
  21492. {
  21493. $this->aliasOf->setExtra($extra);
  21494. }
  21495. public function __clone()
  21496. {
  21497. parent::__clone();
  21498. $this->aliasOf = clone $this->aliasOf;
  21499. }
  21500. }
  21501. <?php
  21502. namespace Composer\Package;
  21503. class RootPackage extends CompletePackage implements RootPackageInterface
  21504. {
  21505. const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  21506. protected $minimumStability = 'stable';
  21507. protected $preferStable = false;
  21508. protected $stabilityFlags = array();
  21509. protected $config = array();
  21510. protected $references = array();
  21511. protected $aliases = array();
  21512. public function setMinimumStability($minimumStability)
  21513. {
  21514. $this->minimumStability = $minimumStability;
  21515. }
  21516. public function getMinimumStability()
  21517. {
  21518. return $this->minimumStability;
  21519. }
  21520. public function setStabilityFlags(array $stabilityFlags)
  21521. {
  21522. $this->stabilityFlags = $stabilityFlags;
  21523. }
  21524. public function getStabilityFlags()
  21525. {
  21526. return $this->stabilityFlags;
  21527. }
  21528. public function setPreferStable($preferStable)
  21529. {
  21530. $this->preferStable = $preferStable;
  21531. }
  21532. public function getPreferStable()
  21533. {
  21534. return $this->preferStable;
  21535. }
  21536. public function setConfig(array $config)
  21537. {
  21538. $this->config = $config;
  21539. }
  21540. public function getConfig()
  21541. {
  21542. return $this->config;
  21543. }
  21544. public function setReferences(array $references)
  21545. {
  21546. $this->references = $references;
  21547. }
  21548. public function getReferences()
  21549. {
  21550. return $this->references;
  21551. }
  21552. public function setAliases(array $aliases)
  21553. {
  21554. $this->aliases = $aliases;
  21555. }
  21556. public function getAliases()
  21557. {
  21558. return $this->aliases;
  21559. }
  21560. }
  21561. <?php
  21562. namespace Composer\Package;
  21563. interface RootPackageInterface extends CompletePackageInterface
  21564. {
  21565. public function getAliases();
  21566. public function getMinimumStability();
  21567. public function getStabilityFlags();
  21568. public function getReferences();
  21569. public function getPreferStable();
  21570. public function getConfig();
  21571. public function setRequires(array $requires);
  21572. public function setDevRequires(array $devRequires);
  21573. public function setConflicts(array $conflicts);
  21574. public function setProvides(array $provides);
  21575. public function setReplaces(array $replaces);
  21576. public function setRepositories($repositories);
  21577. public function setAutoload(array $autoload);
  21578. public function setDevAutoload(array $devAutoload);
  21579. public function setStabilityFlags(array $stabilityFlags);
  21580. public function setSuggests(array $suggests);
  21581. public function setExtra(array $extra);
  21582. }
  21583. <?php
  21584. namespace Composer\Package\Version;
  21585. use Composer\Package\BasePackage;
  21586. class StabilityFilter
  21587. {
  21588. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, $names, $stability)
  21589. {
  21590. foreach ($names as $name) {
  21591. if (isset($stabilityFlags[$name])) {
  21592. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  21593. return true;
  21594. }
  21595. } elseif (isset($acceptableStabilities[$stability])) {
  21596. return true;
  21597. }
  21598. }
  21599. return false;
  21600. }
  21601. }
  21602. <?php
  21603. namespace Composer\Package\Version;
  21604. use Composer\Config;
  21605. use Composer\Repository\Vcs\HgDriver;
  21606. use Composer\IO\NullIO;
  21607. use Composer\Semver\VersionParser as SemverVersionParser;
  21608. use Composer\Util\Git as GitUtil;
  21609. use Composer\Util\HttpDownloader;
  21610. use Composer\Util\ProcessExecutor;
  21611. use Composer\Util\Svn as SvnUtil;
  21612. class VersionGuesser
  21613. {
  21614. private $config;
  21615. private $process;
  21616. private $versionParser;
  21617. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  21618. {
  21619. $this->config = $config;
  21620. $this->process = $process;
  21621. $this->versionParser = $versionParser;
  21622. }
  21623. public function guessVersion(array $packageConfig, $path)
  21624. {
  21625. if (!function_exists('proc_open')) {
  21626. return null;
  21627. }
  21628. $versionData = $this->guessGitVersion($packageConfig, $path);
  21629. if (null !== $versionData && null !== $versionData['version']) {
  21630. return $this->postprocess($versionData);
  21631. }
  21632. $versionData = $this->guessHgVersion($packageConfig, $path);
  21633. if (null !== $versionData && null !== $versionData['version']) {
  21634. return $this->postprocess($versionData);
  21635. }
  21636. $versionData = $this->guessFossilVersion($path);
  21637. if (null !== $versionData && null !== $versionData['version']) {
  21638. return $this->postprocess($versionData);
  21639. }
  21640. $versionData = $this->guessSvnVersion($packageConfig, $path);
  21641. if (null !== $versionData && null !== $versionData['version']) {
  21642. return $this->postprocess($versionData);
  21643. }
  21644. return null;
  21645. }
  21646. private function postprocess(array $versionData)
  21647. {
  21648. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  21649. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  21650. }
  21651. if ('-dev' === substr($versionData['version'], -4) && preg_match('{\.9{7}}', $versionData['version'])) {
  21652. $versionData['pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['version']);
  21653. }
  21654. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && preg_match('{\.9{7}}', $versionData['feature_version'])) {
  21655. $versionData['feature_pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  21656. }
  21657. return $versionData;
  21658. }
  21659. private function guessGitVersion(array $packageConfig, $path)
  21660. {
  21661. GitUtil::cleanEnv();
  21662. $commit = null;
  21663. $version = null;
  21664. $prettyVersion = null;
  21665. $featureVersion = null;
  21666. $featurePrettyVersion = null;
  21667. $isDetached = false;
  21668. if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
  21669. $branches = array();
  21670. $isFeatureBranch = false;
  21671. foreach ($this->process->splitLines($output) as $branch) {
  21672. if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21673. if (
  21674. $match[1] === '(no branch)'
  21675. || strpos($match[1], '(detached ') === 0
  21676. || strpos($match[1], '(HEAD detached at') === 0
  21677. ) {
  21678. $version = 'dev-' . $match[2];
  21679. $prettyVersion = $version;
  21680. $isFeatureBranch = true;
  21681. $isDetached = true;
  21682. } else {
  21683. $version = $this->versionParser->normalizeBranch($match[1]);
  21684. $prettyVersion = 'dev-' . $match[1];
  21685. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  21686. }
  21687. if ($match[2]) {
  21688. $commit = $match[2];
  21689. }
  21690. }
  21691. if ($branch && !preg_match('{^ *.+/HEAD }', $branch)) {
  21692. if (preg_match('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21693. $branches[] = $match[1];
  21694. }
  21695. }
  21696. }
  21697. if ($isFeatureBranch) {
  21698. $featureVersion = $version;
  21699. $featurePrettyVersion = $prettyVersion;
  21700. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  21701. $version = $result['version'];
  21702. $prettyVersion = $result['pretty_version'];
  21703. }
  21704. }
  21705. if (!$version || $isDetached) {
  21706. $result = $this->versionFromGitTags($path);
  21707. if ($result) {
  21708. $version = $result['version'];
  21709. $prettyVersion = $result['pretty_version'];
  21710. $featureVersion = null;
  21711. $featurePrettyVersion = null;
  21712. }
  21713. }
  21714. if (!$commit) {
  21715. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  21716. if (0 === $this->process->execute($command, $output, $path)) {
  21717. $commit = trim($output) ?: null;
  21718. }
  21719. }
  21720. if ($featureVersion) {
  21721. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  21722. }
  21723. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  21724. }
  21725. private function versionFromGitTags($path)
  21726. {
  21727. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  21728. try {
  21729. $version = $this->versionParser->normalize(trim($output));
  21730. return array('version' => $version, 'pretty_version' => trim($output));
  21731. } catch (\Exception $e) {
  21732. }
  21733. }
  21734. return null;
  21735. }
  21736. private function guessHgVersion(array $packageConfig, $path)
  21737. {
  21738. if (0 === $this->process->execute('hg branch', $output, $path)) {
  21739. $branch = trim($output);
  21740. $version = $this->versionParser->normalizeBranch($branch);
  21741. $isFeatureBranch = 0 === strpos($version, 'dev-');
  21742. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  21743. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  21744. }
  21745. if (!$isFeatureBranch) {
  21746. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  21747. }
  21748. $io = new NullIO();
  21749. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  21750. $branches = array_keys($driver->getBranches());
  21751. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  21752. $result['commit'] = '';
  21753. $result['feature_version'] = $version;
  21754. $result['feature_pretty_version'] = $version;
  21755. return $result;
  21756. }
  21757. }
  21758. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  21759. {
  21760. $prettyVersion = $version;
  21761. if (!isset($packageConfig['extra']['branch-alias'][$version])
  21762. || strpos(json_encode($packageConfig), '"self.version"')
  21763. ) {
  21764. $branch = preg_replace('{^dev-}', '', $version);
  21765. $length = PHP_INT_MAX;
  21766. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  21767. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21768. }
  21769. usort($branches, function ($a, $b) {
  21770. $aRemote = 0 === strpos($a, 'remotes/');
  21771. $bRemote = 0 === strpos($b, 'remotes/');
  21772. if ($aRemote !== $bRemote) {
  21773. return $aRemote ? 1 : -1;
  21774. }
  21775. return strnatcasecmp($b, $a);
  21776. });
  21777. foreach ($branches as $candidate) {
  21778. $candidateVersion = preg_replace('{^remotes/\S+/}', '', $candidate);
  21779. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  21780. continue;
  21781. }
  21782. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  21783. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  21784. continue;
  21785. }
  21786. if (strlen($output) < $length) {
  21787. $length = strlen($output);
  21788. $version = $this->versionParser->normalizeBranch($candidateVersion);
  21789. $prettyVersion = 'dev-' . $candidateVersion;
  21790. if ($length === 0) {
  21791. break;
  21792. }
  21793. }
  21794. }
  21795. }
  21796. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21797. }
  21798. private function isFeatureBranch(array $packageConfig, $branchName)
  21799. {
  21800. $nonFeatureBranches = '';
  21801. if (!empty($packageConfig['non-feature-branches'])) {
  21802. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  21803. }
  21804. return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  21805. }
  21806. private function guessFossilVersion($path)
  21807. {
  21808. $version = null;
  21809. $prettyVersion = null;
  21810. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  21811. $branch = trim($output);
  21812. $version = $this->versionParser->normalizeBranch($branch);
  21813. $prettyVersion = 'dev-' . $branch;
  21814. }
  21815. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  21816. try {
  21817. $version = $this->versionParser->normalize(trim($output));
  21818. $prettyVersion = trim($output);
  21819. } catch (\Exception $e) {
  21820. }
  21821. }
  21822. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21823. }
  21824. private function guessSvnVersion(array $packageConfig, $path)
  21825. {
  21826. SvnUtil::cleanEnv();
  21827. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  21828. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  21829. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  21830. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  21831. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  21832. if (preg_match($urlPattern, $output, $matches)) {
  21833. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  21834. $version = $this->versionParser->normalizeBranch($matches[3]);
  21835. $prettyVersion = 'dev-' . $matches[3];
  21836. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21837. }
  21838. $prettyVersion = trim($matches[1]);
  21839. if ($prettyVersion === 'trunk') {
  21840. $version = 'dev-trunk';
  21841. } else {
  21842. $version = $this->versionParser->normalize($prettyVersion);
  21843. }
  21844. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21845. }
  21846. }
  21847. }
  21848. }
  21849. <?php
  21850. namespace Composer\Package\Version;
  21851. use Composer\Repository\PlatformRepository;
  21852. use Composer\Semver\VersionParser as SemverVersionParser;
  21853. use Composer\Semver\Semver;
  21854. class VersionParser extends SemverVersionParser
  21855. {
  21856. const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  21857. private static $constraints = array();
  21858. public function parseConstraints($constraints)
  21859. {
  21860. if (!isset(self::$constraints[$constraints])) {
  21861. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  21862. }
  21863. return self::$constraints[$constraints];
  21864. }
  21865. public function parseNameVersionPairs(array $pairs)
  21866. {
  21867. $pairs = array_values($pairs);
  21868. $result = array();
  21869. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  21870. $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  21871. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  21872. $pair .= ' '.$pairs[$i + 1];
  21873. $i++;
  21874. }
  21875. if (strpos($pair, ' ')) {
  21876. list($name, $version) = explode(' ', $pair, 2);
  21877. $result[] = array('name' => $name, 'version' => $version);
  21878. } else {
  21879. $result[] = array('name' => $pair);
  21880. }
  21881. }
  21882. return $result;
  21883. }
  21884. public static function isUpgrade($normalizedFrom, $normalizedTo)
  21885. {
  21886. if ($normalizedFrom === $normalizedTo) {
  21887. return true;
  21888. }
  21889. if (in_array($normalizedFrom, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  21890. $normalizedFrom = VersionParser::DEFAULT_BRANCH_ALIAS;
  21891. }
  21892. if (in_array($normalizedTo, array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  21893. $normalizedTo = VersionParser::DEFAULT_BRANCH_ALIAS;
  21894. }
  21895. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  21896. return true;
  21897. }
  21898. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  21899. return $sorted[0] === $normalizedFrom;
  21900. }
  21901. }
  21902. <?php
  21903. namespace Composer\Package\Version;
  21904. use Composer\Package\BasePackage;
  21905. use Composer\Package\AliasPackage;
  21906. use Composer\Package\PackageInterface;
  21907. use Composer\Composer;
  21908. use Composer\Package\Loader\ArrayLoader;
  21909. use Composer\Package\Dumper\ArrayDumper;
  21910. use Composer\Repository\RepositorySet;
  21911. use Composer\Repository\PlatformRepository;
  21912. use Composer\Semver\Constraint\Constraint;
  21913. class VersionSelector
  21914. {
  21915. private $repositorySet;
  21916. private $platformConstraints = array();
  21917. private $parser;
  21918. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  21919. {
  21920. $this->repositorySet = $repositorySet;
  21921. if ($platformRepo) {
  21922. foreach ($platformRepo->getPackages() as $package) {
  21923. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  21924. }
  21925. }
  21926. }
  21927. public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $ignorePlatformReqs = false, $repoSetFlags = 0)
  21928. {
  21929. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  21930. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  21931. }
  21932. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  21933. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  21934. if ($this->platformConstraints && true !== $ignorePlatformReqs) {
  21935. $platformConstraints = $this->platformConstraints;
  21936. $ignorePlatformReqs = $ignorePlatformReqs ?: array();
  21937. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $ignorePlatformReqs) {
  21938. $reqs = $pkg->getRequires();
  21939. foreach ($reqs as $name => $link) {
  21940. if (!in_array($name, $ignorePlatformReqs, true) && isset($platformConstraints[$name])) {
  21941. foreach ($platformConstraints[$name] as $constraint) {
  21942. if ($link->getConstraint()->matches($constraint)) {
  21943. continue 2;
  21944. }
  21945. }
  21946. return false;
  21947. }
  21948. }
  21949. return true;
  21950. });
  21951. }
  21952. if (!$candidates) {
  21953. return false;
  21954. }
  21955. $package = reset($candidates);
  21956. $minPriority = BasePackage::$stabilities[$preferredStability];
  21957. foreach ($candidates as $candidate) {
  21958. $candidatePriority = $candidate->getStabilityPriority();
  21959. $currentPriority = $package->getStabilityPriority();
  21960. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  21961. continue;
  21962. }
  21963. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  21964. $package = $candidate;
  21965. continue;
  21966. }
  21967. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  21968. $package = $candidate;
  21969. continue;
  21970. }
  21971. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  21972. $package = $candidate;
  21973. }
  21974. }
  21975. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  21976. $package = $package->getAliasOf();
  21977. }
  21978. return $package;
  21979. }
  21980. public function findRecommendedRequireVersion(PackageInterface $package)
  21981. {
  21982. $version = $package->getVersion();
  21983. if (!$package->isDev()) {
  21984. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  21985. }
  21986. $loader = new ArrayLoader($this->getParser());
  21987. $dumper = new ArrayDumper();
  21988. $extra = $loader->getBranchAlias($dumper->dump($package));
  21989. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  21990. $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  21991. if ($count) {
  21992. $extra = str_replace('.9999999', '.0', $extra);
  21993. return $this->transformVersion($extra, $extra, 'dev');
  21994. }
  21995. }
  21996. return $package->getPrettyVersion();
  21997. }
  21998. private function transformVersion($version, $prettyVersion, $stability)
  21999. {
  22000. $semanticVersionParts = explode('.', $version);
  22001. if (count($semanticVersionParts) == 4 && preg_match('{^0\D?}', $semanticVersionParts[3])) {
  22002. if ($semanticVersionParts[0] === '0') {
  22003. unset($semanticVersionParts[3]);
  22004. } else {
  22005. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  22006. }
  22007. $version = implode('.', $semanticVersionParts);
  22008. } else {
  22009. return $prettyVersion;
  22010. }
  22011. if ($stability != 'stable') {
  22012. $version .= '@'.$stability;
  22013. }
  22014. return '^' . $version;
  22015. }
  22016. private function getParser()
  22017. {
  22018. if ($this->parser === null) {
  22019. $this->parser = new VersionParser();
  22020. }
  22021. return $this->parser;
  22022. }
  22023. }
  22024. <?php
  22025. namespace Composer\Platform;
  22026. use Composer\Util\Platform;
  22027. use Composer\Util\ProcessExecutor;
  22028. use Symfony\Component\Process\ExecutableFinder;
  22029. class HhvmDetector
  22030. {
  22031. private static $hhvmVersion;
  22032. private $executableFinder;
  22033. private $processExecutor;
  22034. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  22035. {
  22036. $this->executableFinder = $executableFinder;
  22037. $this->processExecutor = $processExecutor;
  22038. }
  22039. public function reset()
  22040. {
  22041. self::$hhvmVersion = null;
  22042. }
  22043. public function getVersion()
  22044. {
  22045. if (null !== self::$hhvmVersion) {
  22046. return self::$hhvmVersion ?: null;
  22047. }
  22048. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  22049. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  22050. self::$hhvmVersion = false;
  22051. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  22052. $hhvmPath = $this->executableFinder->find('hhvm');
  22053. if ($hhvmPath !== null) {
  22054. $this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
  22055. $exitCode = $this->processExecutor->execute(
  22056. ProcessExecutor::escape($hhvmPath).
  22057. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  22058. self::$hhvmVersion
  22059. );
  22060. if ($exitCode !== 0) {
  22061. self::$hhvmVersion = false;
  22062. }
  22063. }
  22064. }
  22065. return self::$hhvmVersion;
  22066. }
  22067. }
  22068. <?php
  22069. namespace Composer\Platform;
  22070. class Runtime
  22071. {
  22072. public function hasConstant($constant, $class = null)
  22073. {
  22074. return defined(ltrim($class.'::'.$constant, ':'));
  22075. }
  22076. public function getConstant($constant, $class = null)
  22077. {
  22078. return constant(ltrim($class.'::'.$constant, ':'));
  22079. }
  22080. public function hasFunction($fn)
  22081. {
  22082. return function_exists($fn);
  22083. }
  22084. public function invoke($callable, array $arguments = array())
  22085. {
  22086. return call_user_func_array($callable, $arguments);
  22087. }
  22088. public function hasClass($class)
  22089. {
  22090. return class_exists($class, false);
  22091. }
  22092. public function construct($class, array $arguments = array())
  22093. {
  22094. if (empty($arguments)) {
  22095. return new $class;
  22096. }
  22097. $refl = new \ReflectionClass($class);
  22098. return $refl->newInstanceArgs($arguments);
  22099. }
  22100. public function getExtensions()
  22101. {
  22102. return get_loaded_extensions();
  22103. }
  22104. public function getExtensionVersion($extension)
  22105. {
  22106. return phpversion($extension);
  22107. }
  22108. public function getExtensionInfo($extension)
  22109. {
  22110. $reflector = new \ReflectionExtension($extension);
  22111. ob_start();
  22112. $reflector->info();
  22113. return ob_get_clean();
  22114. }
  22115. }
  22116. <?php
  22117. namespace Composer\Platform;
  22118. class Version
  22119. {
  22120. public static function parseOpenssl($opensslVersion, &$isFips)
  22121. {
  22122. $isFips = false;
  22123. if (!preg_match('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?$/', $opensslVersion, $matches)) {
  22124. return null;
  22125. }
  22126. $isFips = strpos($matches['suffix'], 'fips') !== false;
  22127. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  22128. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  22129. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  22130. }
  22131. public static function parseLibjpeg($libjpegVersion)
  22132. {
  22133. if (!preg_match('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  22134. return null;
  22135. }
  22136. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  22137. }
  22138. public static function parseZoneinfoVersion($zoneinfoVersion)
  22139. {
  22140. if (!preg_match('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  22141. return null;
  22142. }
  22143. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  22144. }
  22145. private static function convertAlphaVersionToIntVersion($alpha)
  22146. {
  22147. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  22148. }
  22149. public static function convertLibxpmVersionId($versionId)
  22150. {
  22151. return self::convertVersionId($versionId, 100);
  22152. }
  22153. public static function convertOpenldapVersionId($versionId)
  22154. {
  22155. return self::convertVersionId($versionId, 100);
  22156. }
  22157. private static function convertVersionId($versionId, $base)
  22158. {
  22159. return sprintf(
  22160. '%d.%d.%d',
  22161. $versionId / ($base * $base),
  22162. ($versionId / $base) % $base,
  22163. $versionId % $base
  22164. );
  22165. }
  22166. }
  22167. <?php
  22168. namespace Composer\Plugin\Capability;
  22169. interface Capability
  22170. {
  22171. }
  22172. <?php
  22173. namespace Composer\Plugin\Capability;
  22174. interface CommandProvider extends Capability
  22175. {
  22176. public function getCommands();
  22177. }
  22178. <?php
  22179. namespace Composer\Plugin;
  22180. interface Capable
  22181. {
  22182. public function getCapabilities();
  22183. }
  22184. <?php
  22185. namespace Composer\Plugin;
  22186. use Composer\EventDispatcher\Event;
  22187. use Symfony\Component\Console\Input\InputInterface;
  22188. use Symfony\Component\Console\Output\OutputInterface;
  22189. class CommandEvent extends Event
  22190. {
  22191. private $commandName;
  22192. private $input;
  22193. private $output;
  22194. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  22195. {
  22196. parent::__construct($name, $args, $flags);
  22197. $this->commandName = $commandName;
  22198. $this->input = $input;
  22199. $this->output = $output;
  22200. }
  22201. public function getInput()
  22202. {
  22203. return $this->input;
  22204. }
  22205. public function getOutput()
  22206. {
  22207. return $this->output;
  22208. }
  22209. public function getCommandName()
  22210. {
  22211. return $this->commandName;
  22212. }
  22213. }
  22214. <?php
  22215. namespace Composer\Plugin;
  22216. class PluginEvents
  22217. {
  22218. const INIT = 'init';
  22219. const COMMAND = 'command';
  22220. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  22221. const POST_FILE_DOWNLOAD = 'post-file-download';
  22222. const PRE_COMMAND_RUN = 'pre-command-run';
  22223. const PRE_POOL_CREATE = 'pre-pool-create';
  22224. }
  22225. <?php
  22226. namespace Composer\Plugin;
  22227. use Composer\Composer;
  22228. use Composer\IO\IOInterface;
  22229. interface PluginInterface
  22230. {
  22231. const PLUGIN_API_VERSION = '2.0.0';
  22232. public function activate(Composer $composer, IOInterface $io);
  22233. public function deactivate(Composer $composer, IOInterface $io);
  22234. public function uninstall(Composer $composer, IOInterface $io);
  22235. }
  22236. <?php
  22237. namespace Composer\Plugin;
  22238. use Composer\Composer;
  22239. use Composer\EventDispatcher\EventSubscriberInterface;
  22240. use Composer\IO\IOInterface;
  22241. use Composer\Package\CompletePackage;
  22242. use Composer\Package\Package;
  22243. use Composer\Package\RootPackage;
  22244. use Composer\Package\Version\VersionParser;
  22245. use Composer\Repository\RepositoryInterface;
  22246. use Composer\Repository\InstalledRepository;
  22247. use Composer\Repository\RootPackageRepository;
  22248. use Composer\Package\PackageInterface;
  22249. use Composer\Package\RootPackageInterface;
  22250. use Composer\Package\Link;
  22251. use Composer\Semver\Constraint\Constraint;
  22252. use Composer\Plugin\Capability\Capability;
  22253. use Composer\Util\PackageSorter;
  22254. class PluginManager
  22255. {
  22256. protected $composer;
  22257. protected $io;
  22258. protected $globalComposer;
  22259. protected $versionParser;
  22260. protected $disablePlugins = false;
  22261. protected $plugins = array();
  22262. protected $registeredPlugins = array();
  22263. private static $classCounter = 0;
  22264. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  22265. {
  22266. $this->io = $io;
  22267. $this->composer = $composer;
  22268. $this->globalComposer = $globalComposer;
  22269. $this->versionParser = new VersionParser();
  22270. $this->disablePlugins = $disablePlugins;
  22271. }
  22272. public function loadInstalledPlugins()
  22273. {
  22274. if ($this->disablePlugins) {
  22275. return;
  22276. }
  22277. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  22278. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22279. if ($repo) {
  22280. $this->loadRepository($repo, false);
  22281. }
  22282. if ($globalRepo) {
  22283. $this->loadRepository($globalRepo, true);
  22284. }
  22285. }
  22286. public function getPlugins()
  22287. {
  22288. return $this->plugins;
  22289. }
  22290. public function getGlobalComposer()
  22291. {
  22292. return $this->globalComposer;
  22293. }
  22294. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false, $isGlobalPlugin = false)
  22295. {
  22296. if ($this->disablePlugins) {
  22297. return;
  22298. }
  22299. if ($package->getType() === 'composer-plugin') {
  22300. $requiresComposer = null;
  22301. foreach ($package->getRequires() as $link) {
  22302. if ('composer-plugin-api' === $link->getTarget()) {
  22303. $requiresComposer = $link->getConstraint();
  22304. break;
  22305. }
  22306. }
  22307. if (!$requiresComposer) {
  22308. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  22309. }
  22310. $currentPluginApiVersion = $this->getPluginApiVersion();
  22311. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  22312. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  22313. $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>');
  22314. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  22315. $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>');
  22316. return;
  22317. }
  22318. if ($package->getName() === 'symfony/flex' && preg_match('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  22319. $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>');
  22320. return;
  22321. }
  22322. }
  22323. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22324. if (isset($this->registeredPlugins[$package->getName()])) {
  22325. return;
  22326. }
  22327. $extra = $package->getExtra();
  22328. if (empty($extra['class'])) {
  22329. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  22330. }
  22331. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  22332. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  22333. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22334. $rootPackage = clone $this->composer->getPackage();
  22335. $rootPackageRepo = new RootPackageRepository($rootPackage);
  22336. $installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo));
  22337. if ($globalRepo) {
  22338. $installedRepo->addRepository($globalRepo);
  22339. }
  22340. $autoloadPackages = array($package->getName() => $package);
  22341. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  22342. $generator = $this->composer->getAutoloadGenerator();
  22343. $autoloads = array(array($rootPackage, ''));
  22344. foreach ($autoloadPackages as $autoloadPackage) {
  22345. if ($autoloadPackage === $rootPackage) {
  22346. continue;
  22347. }
  22348. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  22349. $autoloads[] = array($autoloadPackage, $downloadPath);
  22350. }
  22351. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  22352. $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir'));
  22353. $classLoader->register(false);
  22354. foreach ($classes as $class) {
  22355. if (class_exists($class, false)) {
  22356. $class = trim($class, '\\');
  22357. $path = $classLoader->findFile($class);
  22358. $code = file_get_contents($path);
  22359. $separatorPos = strrpos($class, '\\');
  22360. $className = $class;
  22361. if ($separatorPos) {
  22362. $className = substr($class, $separatorPos + 1);
  22363. }
  22364. $code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  22365. $code = strtr($code, array(
  22366. '__FILE__' => var_export($path, true),
  22367. '__DIR__' => var_export(dirname($path), true),
  22368. '__CLASS__' => var_export($class, true),
  22369. ));
  22370. $code = preg_replace('/^\s*<\?(php)?/i', '', $code, 1);
  22371. eval($code);
  22372. $class .= '_composer_tmp'.self::$classCounter;
  22373. self::$classCounter++;
  22374. }
  22375. if ($oldInstallerPlugin) {
  22376. $this->io->writeError('<warning>Loading "'.$package->getName() . '" '.($isGlobalPlugin ? '(installed globally) ' : '').'which is a legacy composer-installer built for Composer 1.x, it is likely to cause issues as you are running Composer 2.x.</warning>');
  22377. $installer = new $class($this->io, $this->composer);
  22378. $this->composer->getInstallationManager()->addInstaller($installer);
  22379. $this->registeredPlugins[$package->getName()] = $installer;
  22380. } elseif (class_exists($class)) {
  22381. $plugin = new $class();
  22382. $this->addPlugin($plugin, $isGlobalPlugin, $package);
  22383. $this->registeredPlugins[$package->getName()] = $plugin;
  22384. } elseif ($failOnMissingClasses) {
  22385. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  22386. }
  22387. }
  22388. }
  22389. public function deactivatePackage(PackageInterface $package)
  22390. {
  22391. if ($this->disablePlugins) {
  22392. return;
  22393. }
  22394. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22395. if (!isset($this->registeredPlugins[$package->getName()])) {
  22396. return;
  22397. }
  22398. if ($oldInstallerPlugin) {
  22399. $installer = $this->registeredPlugins[$package->getName()];
  22400. unset($this->registeredPlugins[$package->getName()]);
  22401. $this->composer->getInstallationManager()->removeInstaller($installer);
  22402. } else {
  22403. $plugin = $this->registeredPlugins[$package->getName()];
  22404. unset($this->registeredPlugins[$package->getName()]);
  22405. $this->removePlugin($plugin);
  22406. }
  22407. }
  22408. public function uninstallPackage(PackageInterface $package)
  22409. {
  22410. if ($this->disablePlugins) {
  22411. return;
  22412. }
  22413. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22414. if (!isset($this->registeredPlugins[$package->getName()])) {
  22415. return;
  22416. }
  22417. if ($oldInstallerPlugin) {
  22418. $this->deactivatePackage($package);
  22419. } else {
  22420. $plugin = $this->registeredPlugins[$package->getName()];
  22421. unset($this->registeredPlugins[$package->getName()]);
  22422. $this->removePlugin($plugin);
  22423. $this->uninstallPlugin($plugin);
  22424. }
  22425. }
  22426. protected function getPluginApiVersion()
  22427. {
  22428. return PluginInterface::PLUGIN_API_VERSION;
  22429. }
  22430. public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false, PackageInterface $sourcePackage = null)
  22431. {
  22432. $details = array();
  22433. if ($sourcePackage) {
  22434. $details[] = 'from '.$sourcePackage->getName();
  22435. }
  22436. if ($isGlobalPlugin) {
  22437. $details[] = 'installed globally';
  22438. }
  22439. $this->io->writeError('Loading plugin '.get_class($plugin).($details ? ' ('.implode(', ', $details).')' : ''), true, IOInterface::DEBUG);
  22440. $this->plugins[] = $plugin;
  22441. $plugin->activate($this->composer, $this->io);
  22442. if ($plugin instanceof EventSubscriberInterface) {
  22443. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  22444. }
  22445. }
  22446. public function removePlugin(PluginInterface $plugin)
  22447. {
  22448. $index = array_search($plugin, $this->plugins, true);
  22449. if ($index === false) {
  22450. return;
  22451. }
  22452. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22453. unset($this->plugins[$index]);
  22454. $plugin->deactivate($this->composer, $this->io);
  22455. $this->composer->getEventDispatcher()->removeListener($plugin);
  22456. }
  22457. public function uninstallPlugin(PluginInterface $plugin)
  22458. {
  22459. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22460. $plugin->uninstall($this->composer, $this->io);
  22461. }
  22462. private function loadRepository(RepositoryInterface $repo, $isGlobalRepo)
  22463. {
  22464. $packages = $repo->getPackages();
  22465. $sortedPackages = PackageSorter::sortPackages($packages);
  22466. foreach ($sortedPackages as $package) {
  22467. if (!($package instanceof CompletePackage)) {
  22468. continue;
  22469. }
  22470. if ('composer-plugin' === $package->getType()) {
  22471. $this->registerPackage($package, false, $isGlobalRepo);
  22472. } elseif ('composer-installer' === $package->getType()) {
  22473. $this->registerPackage($package, false, $isGlobalRepo);
  22474. }
  22475. }
  22476. }
  22477. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
  22478. {
  22479. foreach ($package->getRequires() as $requireLink) {
  22480. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  22481. if (!isset($collected[$requiredPackage->getName()])) {
  22482. $collected[$requiredPackage->getName()] = $requiredPackage;
  22483. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  22484. }
  22485. }
  22486. }
  22487. return $collected;
  22488. }
  22489. private function getInstallPath(PackageInterface $package, $global = false)
  22490. {
  22491. if (!$global) {
  22492. return $this->composer->getInstallationManager()->getInstallPath($package);
  22493. }
  22494. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  22495. }
  22496. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  22497. {
  22498. if (!($plugin instanceof Capable)) {
  22499. return null;
  22500. }
  22501. $capabilities = (array) $plugin->getCapabilities();
  22502. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  22503. return trim($capabilities[$capability]);
  22504. }
  22505. if (
  22506. array_key_exists($capability, $capabilities)
  22507. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  22508. ) {
  22509. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], 1));
  22510. }
  22511. }
  22512. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  22513. {
  22514. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  22515. if (!class_exists($capabilityClass)) {
  22516. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  22517. }
  22518. $ctorArgs['plugin'] = $plugin;
  22519. $capabilityObj = new $capabilityClass($ctorArgs);
  22520. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  22521. throw new \RuntimeException(
  22522. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  22523. );
  22524. }
  22525. return $capabilityObj;
  22526. }
  22527. }
  22528. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  22529. {
  22530. $capabilities = array();
  22531. foreach ($this->getPlugins() as $plugin) {
  22532. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  22533. $capabilities[] = $capability;
  22534. }
  22535. }
  22536. return $capabilities;
  22537. }
  22538. }
  22539. <?php
  22540. namespace Composer\Plugin;
  22541. use Composer\EventDispatcher\Event;
  22542. use Composer\Package\PackageInterface;
  22543. class PostFileDownloadEvent extends Event
  22544. {
  22545. private $fileName;
  22546. private $checksum;
  22547. private $url;
  22548. private $package;
  22549. public function __construct($name, $fileName, $checksum, $url, PackageInterface $package)
  22550. {
  22551. parent::__construct($name);
  22552. $this->fileName = $fileName;
  22553. $this->checksum = $checksum;
  22554. $this->url = $url;
  22555. $this->package = $package;
  22556. }
  22557. public function getFileName()
  22558. {
  22559. return $this->fileName;
  22560. }
  22561. public function getChecksum()
  22562. {
  22563. return $this->checksum;
  22564. }
  22565. public function getUrl()
  22566. {
  22567. return $this->url;
  22568. }
  22569. public function getPackage()
  22570. {
  22571. return $this->package;
  22572. }
  22573. }
  22574. <?php
  22575. namespace Composer\Plugin;
  22576. use Composer\EventDispatcher\Event;
  22577. use Symfony\Component\Console\Input\InputInterface;
  22578. class PreCommandRunEvent extends Event
  22579. {
  22580. private $input;
  22581. private $command;
  22582. public function __construct($name, InputInterface $input, $command)
  22583. {
  22584. parent::__construct($name);
  22585. $this->input = $input;
  22586. $this->command = $command;
  22587. }
  22588. public function getInput()
  22589. {
  22590. return $this->input;
  22591. }
  22592. public function getCommand()
  22593. {
  22594. return $this->command;
  22595. }
  22596. }
  22597. <?php
  22598. namespace Composer\Plugin;
  22599. use Composer\EventDispatcher\Event;
  22600. use Composer\Util\HttpDownloader;
  22601. class PreFileDownloadEvent extends Event
  22602. {
  22603. private $httpDownloader;
  22604. private $processedUrl;
  22605. private $customCacheKey;
  22606. private $type;
  22607. private $context;
  22608. public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null)
  22609. {
  22610. parent::__construct($name);
  22611. $this->httpDownloader = $httpDownloader;
  22612. $this->processedUrl = $processedUrl;
  22613. $this->type = $type;
  22614. $this->context = $context;
  22615. }
  22616. public function getHttpDownloader()
  22617. {
  22618. return $this->httpDownloader;
  22619. }
  22620. public function getProcessedUrl()
  22621. {
  22622. return $this->processedUrl;
  22623. }
  22624. public function setProcessedUrl($processedUrl)
  22625. {
  22626. $this->processedUrl = $processedUrl;
  22627. }
  22628. public function getCustomCacheKey()
  22629. {
  22630. return $this->customCacheKey;
  22631. }
  22632. public function setCustomCacheKey($customCacheKey)
  22633. {
  22634. $this->customCacheKey = $customCacheKey;
  22635. }
  22636. public function getType()
  22637. {
  22638. return $this->type;
  22639. }
  22640. public function getContext()
  22641. {
  22642. return $this->context;
  22643. }
  22644. }
  22645. <?php
  22646. namespace Composer\Plugin;
  22647. use Composer\EventDispatcher\Event;
  22648. use Composer\Repository\RepositoryInterface;
  22649. use Composer\DependencyResolver\Request;
  22650. use Composer\Package\PackageInterface;
  22651. class PrePoolCreateEvent extends Event
  22652. {
  22653. private $repositories;
  22654. private $request;
  22655. private $acceptableStabilities;
  22656. private $stabilityFlags;
  22657. private $rootAliases;
  22658. private $rootReferences;
  22659. private $packages;
  22660. private $unacceptableFixedPackages;
  22661. public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  22662. {
  22663. parent::__construct($name);
  22664. $this->repositories = $repositories;
  22665. $this->request = $request;
  22666. $this->acceptableStabilities = $acceptableStabilities;
  22667. $this->stabilityFlags = $stabilityFlags;
  22668. $this->rootAliases = $rootAliases;
  22669. $this->rootReferences = $rootReferences;
  22670. $this->packages = $packages;
  22671. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  22672. }
  22673. public function getRepositories()
  22674. {
  22675. return $this->repositories;
  22676. }
  22677. public function getRequest()
  22678. {
  22679. return $this->request;
  22680. }
  22681. public function getAcceptableStabilities()
  22682. {
  22683. return $this->acceptableStabilities;
  22684. }
  22685. public function getStabilityFlags()
  22686. {
  22687. return $this->stabilityFlags;
  22688. }
  22689. public function getRootAliases()
  22690. {
  22691. return $this->rootAliases;
  22692. }
  22693. public function getRootReferences()
  22694. {
  22695. return $this->rootReferences;
  22696. }
  22697. public function getPackages()
  22698. {
  22699. return $this->packages;
  22700. }
  22701. public function getUnacceptableFixedPackages()
  22702. {
  22703. return $this->unacceptableFixedPackages;
  22704. }
  22705. public function setPackages(array $packages)
  22706. {
  22707. $this->packages = $packages;
  22708. }
  22709. public function setUnacceptableFixedPackages(array $packages)
  22710. {
  22711. $this->unacceptableFixedPackages = $packages;
  22712. }
  22713. }
  22714. <?php
  22715. namespace Composer\Question;
  22716. use Symfony\Component\Console\Exception\InvalidArgumentException;
  22717. use Symfony\Component\Console\Question\Question;
  22718. class StrictConfirmationQuestion extends Question
  22719. {
  22720. private $trueAnswerRegex;
  22721. private $falseAnswerRegex;
  22722. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  22723. {
  22724. parent::__construct($question, (bool) $default);
  22725. $this->trueAnswerRegex = $trueAnswerRegex;
  22726. $this->falseAnswerRegex = $falseAnswerRegex;
  22727. $this->setNormalizer($this->getDefaultNormalizer());
  22728. $this->setValidator($this->getDefaultValidator());
  22729. }
  22730. private function getDefaultNormalizer()
  22731. {
  22732. $default = $this->getDefault();
  22733. $trueRegex = $this->trueAnswerRegex;
  22734. $falseRegex = $this->falseAnswerRegex;
  22735. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  22736. if (is_bool($answer)) {
  22737. return $answer;
  22738. }
  22739. if (empty($answer) && !empty($default)) {
  22740. return $default;
  22741. }
  22742. if (preg_match($trueRegex, $answer)) {
  22743. return true;
  22744. }
  22745. if (preg_match($falseRegex, $answer)) {
  22746. return false;
  22747. }
  22748. return null;
  22749. };
  22750. }
  22751. private function getDefaultValidator()
  22752. {
  22753. return function ($answer) {
  22754. if (!is_bool($answer)) {
  22755. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  22756. }
  22757. return $answer;
  22758. };
  22759. }
  22760. }
  22761. <?php
  22762. namespace Composer\Repository;
  22763. use Composer\Package\AliasPackage;
  22764. use Composer\Package\PackageInterface;
  22765. use Composer\Package\CompletePackageInterface;
  22766. use Composer\Package\Version\VersionParser;
  22767. use Composer\Package\Version\StabilityFilter;
  22768. use Composer\Semver\Constraint\ConstraintInterface;
  22769. use Composer\Semver\Constraint\Constraint;
  22770. class ArrayRepository implements RepositoryInterface
  22771. {
  22772. protected $packages;
  22773. protected $packageMap;
  22774. public function __construct(array $packages = array())
  22775. {
  22776. foreach ($packages as $package) {
  22777. $this->addPackage($package);
  22778. }
  22779. }
  22780. public function getRepoName()
  22781. {
  22782. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  22783. }
  22784. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  22785. {
  22786. $packages = $this->getPackages();
  22787. $result = array();
  22788. $namesFound = array();
  22789. foreach ($packages as $package) {
  22790. if (array_key_exists($package->getName(), $packageMap)) {
  22791. if (
  22792. (!$packageMap[$package->getName()] || $packageMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  22793. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  22794. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  22795. ) {
  22796. $result[spl_object_hash($package)] = $package;
  22797. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  22798. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  22799. }
  22800. }
  22801. $namesFound[$package->getName()] = true;
  22802. }
  22803. }
  22804. foreach ($packages as $package) {
  22805. if ($package instanceof AliasPackage) {
  22806. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  22807. $result[spl_object_hash($package)] = $package;
  22808. }
  22809. }
  22810. }
  22811. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  22812. }
  22813. public function findPackage($name, $constraint)
  22814. {
  22815. $name = strtolower($name);
  22816. if (!$constraint instanceof ConstraintInterface) {
  22817. $versionParser = new VersionParser();
  22818. $constraint = $versionParser->parseConstraints($constraint);
  22819. }
  22820. foreach ($this->getPackages() as $package) {
  22821. if ($name === $package->getName()) {
  22822. $pkgConstraint = new Constraint('==', $package->getVersion());
  22823. if ($constraint->matches($pkgConstraint)) {
  22824. return $package;
  22825. }
  22826. }
  22827. }
  22828. return null;
  22829. }
  22830. public function findPackages($name, $constraint = null)
  22831. {
  22832. $name = strtolower($name);
  22833. $packages = array();
  22834. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  22835. $versionParser = new VersionParser();
  22836. $constraint = $versionParser->parseConstraints($constraint);
  22837. }
  22838. foreach ($this->getPackages() as $package) {
  22839. if ($name === $package->getName()) {
  22840. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  22841. $packages[] = $package;
  22842. }
  22843. }
  22844. }
  22845. return $packages;
  22846. }
  22847. public function search($query, $mode = 0, $type = null)
  22848. {
  22849. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  22850. $matches = array();
  22851. foreach ($this->getPackages() as $package) {
  22852. $name = $package->getName();
  22853. if (isset($matches[$name])) {
  22854. continue;
  22855. }
  22856. if (preg_match($regex, $name)
  22857. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  22858. ) {
  22859. if (null !== $type && $package->getType() !== $type) {
  22860. continue;
  22861. }
  22862. $matches[$name] = array(
  22863. 'name' => $package->getPrettyName(),
  22864. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  22865. );
  22866. }
  22867. }
  22868. return array_values($matches);
  22869. }
  22870. public function hasPackage(PackageInterface $package)
  22871. {
  22872. if ($this->packageMap === null) {
  22873. $this->packageMap = array();
  22874. foreach ($this->getPackages() as $repoPackage) {
  22875. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  22876. }
  22877. }
  22878. return isset($this->packageMap[$package->getUniqueName()]);
  22879. }
  22880. public function addPackage(PackageInterface $package)
  22881. {
  22882. if (null === $this->packages) {
  22883. $this->initialize();
  22884. }
  22885. $package->setRepository($this);
  22886. $this->packages[] = $package;
  22887. if ($package instanceof AliasPackage) {
  22888. $aliasedPackage = $package->getAliasOf();
  22889. if (null === $aliasedPackage->getRepository()) {
  22890. $this->addPackage($aliasedPackage);
  22891. }
  22892. }
  22893. $this->packageMap = null;
  22894. }
  22895. public function getProviders($packageName)
  22896. {
  22897. $result = array();
  22898. foreach ($this->getPackages() as $candidate) {
  22899. if (isset($result[$candidate->getName()])) {
  22900. continue;
  22901. }
  22902. foreach ($candidate->getProvides() as $link) {
  22903. if ($packageName === $link->getTarget()) {
  22904. $result[$candidate->getName()] = array(
  22905. 'name' => $candidate->getName(),
  22906. 'description' => $candidate->getDescription(),
  22907. 'type' => $candidate->getType(),
  22908. );
  22909. continue 2;
  22910. }
  22911. }
  22912. }
  22913. return $result;
  22914. }
  22915. protected function createAliasPackage(PackageInterface $package, $alias, $prettyAlias)
  22916. {
  22917. return new AliasPackage($package instanceof AliasPackage ? $package->getAliasOf() : $package, $alias, $prettyAlias);
  22918. }
  22919. public function removePackage(PackageInterface $package)
  22920. {
  22921. $packageId = $package->getUniqueName();
  22922. foreach ($this->getPackages() as $key => $repoPackage) {
  22923. if ($packageId === $repoPackage->getUniqueName()) {
  22924. array_splice($this->packages, $key, 1);
  22925. $this->packageMap = null;
  22926. return;
  22927. }
  22928. }
  22929. }
  22930. public function getPackages()
  22931. {
  22932. if (null === $this->packages) {
  22933. $this->initialize();
  22934. }
  22935. return $this->packages;
  22936. }
  22937. public function count()
  22938. {
  22939. if (null === $this->packages) {
  22940. $this->initialize();
  22941. }
  22942. return count($this->packages);
  22943. }
  22944. protected function initialize()
  22945. {
  22946. $this->packages = array();
  22947. }
  22948. }
  22949. <?php
  22950. namespace Composer\Repository;
  22951. use Composer\IO\IOInterface;
  22952. use Composer\Json\JsonFile;
  22953. use Composer\Package\Loader\ArrayLoader;
  22954. use Composer\Package\Loader\LoaderInterface;
  22955. use Composer\Util\Tar;
  22956. use Composer\Util\Zip;
  22957. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22958. {
  22959. protected $loader;
  22960. protected $lookup;
  22961. protected $repoConfig;
  22962. private $io;
  22963. public function __construct(array $repoConfig, IOInterface $io)
  22964. {
  22965. parent::__construct();
  22966. if (!extension_loaded('zip')) {
  22967. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  22968. }
  22969. $this->loader = new ArrayLoader();
  22970. $this->lookup = $repoConfig['url'];
  22971. $this->io = $io;
  22972. $this->repoConfig = $repoConfig;
  22973. }
  22974. public function getRepoName()
  22975. {
  22976. return 'artifact repo ('.$this->lookup.')';
  22977. }
  22978. public function getRepoConfig()
  22979. {
  22980. return $this->repoConfig;
  22981. }
  22982. protected function initialize()
  22983. {
  22984. parent::initialize();
  22985. $this->scanDirectory($this->lookup);
  22986. }
  22987. private function scanDirectory($path)
  22988. {
  22989. $io = $this->io;
  22990. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  22991. $iterator = new \RecursiveIteratorIterator($directory);
  22992. $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar|tar|gz|tgz)$/i');
  22993. foreach ($regex as $file) {
  22994. if (!$file->isFile()) {
  22995. continue;
  22996. }
  22997. $package = $this->getComposerInformation($file);
  22998. if (!$package) {
  22999. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  23000. continue;
  23001. }
  23002. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  23003. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  23004. $this->addPackage($package);
  23005. }
  23006. }
  23007. private function getComposerInformation(\SplFileInfo $file)
  23008. {
  23009. $json = null;
  23010. $fileType = null;
  23011. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  23012. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  23013. $fileType = 'tar';
  23014. } elseif ($fileExtension === 'zip') {
  23015. $fileType = 'zip';
  23016. } else {
  23017. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  23018. }
  23019. try {
  23020. if ($fileType === 'tar') {
  23021. $json = Tar::getComposerJson($file->getPathname());
  23022. } else {
  23023. $json = Zip::getComposerJson($file->getPathname());
  23024. }
  23025. } catch (\Exception $exception) {
  23026. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  23027. }
  23028. if (null === $json) {
  23029. return false;
  23030. }
  23031. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  23032. $package['dist'] = array(
  23033. 'type' => $fileType,
  23034. 'url' => strtr($file->getPathname(), '\\', '/'),
  23035. 'shasum' => sha1_file($file->getRealPath()),
  23036. );
  23037. try {
  23038. $package = $this->loader->load($package);
  23039. } catch (\UnexpectedValueException $e) {
  23040. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  23041. }
  23042. return $package;
  23043. }
  23044. }
  23045. <?php
  23046. namespace Composer\Repository;
  23047. use Composer\Package\BasePackage;
  23048. use Composer\Package\Loader\ArrayLoader;
  23049. use Composer\Package\PackageInterface;
  23050. use Composer\Package\AliasPackage;
  23051. use Composer\Package\Version\VersionParser;
  23052. use Composer\Package\Version\StabilityFilter;
  23053. use Composer\Json\JsonFile;
  23054. use Composer\Cache;
  23055. use Composer\Config;
  23056. use Composer\IO\IOInterface;
  23057. use Composer\Semver\CompilingMatcher;
  23058. use Composer\Util\HttpDownloader;
  23059. use Composer\Util\Loop;
  23060. use Composer\Plugin\PluginEvents;
  23061. use Composer\Plugin\PreFileDownloadEvent;
  23062. use Composer\EventDispatcher\EventDispatcher;
  23063. use Composer\Downloader\TransportException;
  23064. use Composer\Semver\Constraint\ConstraintInterface;
  23065. use Composer\Semver\Constraint\Constraint;
  23066. use Composer\Semver\Constraint\MatchAllConstraint;
  23067. use Composer\Util\Http\Response;
  23068. use Composer\MetadataMinifier\MetadataMinifier;
  23069. use Composer\Util\Url;
  23070. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  23071. {
  23072. private $repoConfig;
  23073. private $options;
  23074. private $url;
  23075. private $baseUrl;
  23076. private $io;
  23077. private $httpDownloader;
  23078. private $loop;
  23079. protected $cache;
  23080. protected $notifyUrl;
  23081. protected $searchUrl;
  23082. protected $providersApiUrl;
  23083. protected $hasProviders = false;
  23084. protected $providersUrl;
  23085. protected $listUrl;
  23086. protected $hasAvailablePackageList = false;
  23087. protected $availablePackages;
  23088. protected $availablePackagePatterns;
  23089. protected $lazyProvidersUrl;
  23090. protected $providerListing;
  23091. protected $loader;
  23092. private $allowSslDowngrade = false;
  23093. private $eventDispatcher;
  23094. private $sourceMirrors;
  23095. private $distMirrors;
  23096. private $degradedMode = false;
  23097. private $rootData;
  23098. private $hasPartialPackages;
  23099. private $partialPackagesByName;
  23100. public $freshMetadataUrls = array();
  23101. public $packagesNotFoundCache = array();
  23102. public $versionParser;
  23103. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  23104. {
  23105. parent::__construct();
  23106. if (!preg_match('{^[\w.]+\??://}', $repoConfig['url'])) {
  23107. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  23108. }
  23109. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  23110. if (strpos($repoConfig['url'], 'https?') === 0) {
  23111. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  23112. }
  23113. $urlBits = parse_url($repoConfig['url']);
  23114. if ($urlBits === false || empty($urlBits['scheme'])) {
  23115. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  23116. }
  23117. if (!isset($repoConfig['options'])) {
  23118. $repoConfig['options'] = array();
  23119. }
  23120. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  23121. $this->allowSslDowngrade = true;
  23122. }
  23123. $this->options = $repoConfig['options'];
  23124. $this->url = $repoConfig['url'];
  23125. if (preg_match('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  23126. $this->url = $match['proto'].'://repo.packagist.org';
  23127. }
  23128. $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  23129. $this->io = $io;
  23130. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  23131. $this->cache->setReadOnly($config->get('cache-read-only'));
  23132. $this->versionParser = new VersionParser();
  23133. $this->loader = new ArrayLoader($this->versionParser);
  23134. $this->httpDownloader = $httpDownloader;
  23135. $this->eventDispatcher = $eventDispatcher;
  23136. $this->repoConfig = $repoConfig;
  23137. $this->loop = new Loop($this->httpDownloader);
  23138. }
  23139. public function getRepoName()
  23140. {
  23141. return 'composer repo ('.Url::sanitize($this->url).')';
  23142. }
  23143. public function getRepoConfig()
  23144. {
  23145. return $this->repoConfig;
  23146. }
  23147. public function findPackage($name, $constraint)
  23148. {
  23149. $hasProviders = $this->hasProviders();
  23150. $name = strtolower($name);
  23151. if (!$constraint instanceof ConstraintInterface) {
  23152. $constraint = $this->versionParser->parseConstraints($constraint);
  23153. }
  23154. if ($this->lazyProvidersUrl) {
  23155. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  23156. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  23157. }
  23158. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  23159. return;
  23160. }
  23161. $packages = $this->loadAsyncPackages(array($name => $constraint));
  23162. return reset($packages['packages']);
  23163. }
  23164. if ($hasProviders) {
  23165. foreach ($this->getProviderNames() as $providerName) {
  23166. if ($name === $providerName) {
  23167. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  23168. }
  23169. }
  23170. return;
  23171. }
  23172. return parent::findPackage($name, $constraint);
  23173. }
  23174. public function findPackages($name, $constraint = null)
  23175. {
  23176. $hasProviders = $this->hasProviders();
  23177. $name = strtolower($name);
  23178. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  23179. $constraint = $this->versionParser->parseConstraints($constraint);
  23180. }
  23181. if ($this->lazyProvidersUrl) {
  23182. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  23183. return $this->filterPackages($this->whatProvides($name), $constraint);
  23184. }
  23185. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  23186. return array();
  23187. }
  23188. $result = $this->loadAsyncPackages(array($name => $constraint));
  23189. return $result['packages'];
  23190. }
  23191. if ($hasProviders) {
  23192. foreach ($this->getProviderNames() as $providerName) {
  23193. if ($name === $providerName) {
  23194. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  23195. }
  23196. }
  23197. return array();
  23198. }
  23199. return parent::findPackages($name, $constraint);
  23200. }
  23201. private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
  23202. {
  23203. if (null === $constraint) {
  23204. if ($returnFirstMatch) {
  23205. return reset($packages);
  23206. }
  23207. return $packages;
  23208. }
  23209. $filteredPackages = array();
  23210. foreach ($packages as $package) {
  23211. $pkgConstraint = new Constraint('==', $package->getVersion());
  23212. if ($constraint->matches($pkgConstraint)) {
  23213. if ($returnFirstMatch) {
  23214. return $package;
  23215. }
  23216. $filteredPackages[] = $package;
  23217. }
  23218. }
  23219. if ($returnFirstMatch) {
  23220. return null;
  23221. }
  23222. return $filteredPackages;
  23223. }
  23224. public function getPackages()
  23225. {
  23226. $hasProviders = $this->hasProviders();
  23227. if ($this->lazyProvidersUrl) {
  23228. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  23229. $packageMap = array();
  23230. foreach ($this->availablePackages as $name) {
  23231. $packageMap[$name] = new MatchAllConstraint();
  23232. }
  23233. $result = $this->loadAsyncPackages($packageMap);
  23234. return array_values($result['packages']);
  23235. }
  23236. if ($this->hasPartialPackages()) {
  23237. return array_values($this->partialPackagesByName);
  23238. }
  23239. 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.');
  23240. }
  23241. if ($hasProviders) {
  23242. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  23243. }
  23244. return parent::getPackages();
  23245. }
  23246. public function getPackageNames($packageFilter = null)
  23247. {
  23248. $hasProviders = $this->hasProviders();
  23249. $packageFilterCb = function ($name) {
  23250. return true;
  23251. };
  23252. if (null !== $packageFilter) {
  23253. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  23254. $packageFilterCb = function ($name) use ($packageFilterRegex) {
  23255. return (bool) preg_match($packageFilterRegex, $name);
  23256. };
  23257. }
  23258. if ($this->lazyProvidersUrl) {
  23259. if (is_array($this->availablePackages)) {
  23260. return array_filter(array_keys($this->availablePackages), $packageFilterCb);
  23261. }
  23262. if ($this->listUrl) {
  23263. $url = $this->listUrl;
  23264. if ($packageFilter) {
  23265. $url .= '?filter='.urlencode($packageFilter);
  23266. }
  23267. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23268. return $result['packageNames'];
  23269. }
  23270. if ($this->hasPartialPackages()) {
  23271. return array_filter(array_keys($this->partialPackagesByName), $packageFilterCb);
  23272. }
  23273. return array();
  23274. }
  23275. if ($hasProviders) {
  23276. return array_filter($this->getProviderNames(), $packageFilterCb);
  23277. }
  23278. $names = array();
  23279. foreach ($this->getPackages() as $package) {
  23280. if ($packageFilterCb($package->getName())) {
  23281. $names[] = $package->getPrettyName();
  23282. }
  23283. }
  23284. return $names;
  23285. }
  23286. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23287. {
  23288. $hasProviders = $this->hasProviders();
  23289. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  23290. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23291. }
  23292. $packages = array();
  23293. $namesFound = array();
  23294. if ($hasProviders || $this->hasPartialPackages()) {
  23295. foreach ($packageNameMap as $name => $constraint) {
  23296. $matches = array();
  23297. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  23298. continue;
  23299. }
  23300. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23301. foreach ($candidates as $candidate) {
  23302. if ($candidate->getName() !== $name) {
  23303. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  23304. }
  23305. $namesFound[$name] = true;
  23306. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  23307. $matches[spl_object_hash($candidate)] = $candidate;
  23308. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23309. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  23310. }
  23311. }
  23312. }
  23313. foreach ($candidates as $candidate) {
  23314. if ($candidate instanceof AliasPackage) {
  23315. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23316. $matches[spl_object_hash($candidate)] = $candidate;
  23317. }
  23318. }
  23319. }
  23320. $packages = array_merge($packages, $matches);
  23321. unset($packageNameMap[$name]);
  23322. }
  23323. }
  23324. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  23325. if ($this->hasAvailablePackageList) {
  23326. foreach ($packageNameMap as $name => $constraint) {
  23327. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  23328. unset($packageNameMap[$name]);
  23329. }
  23330. }
  23331. }
  23332. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23333. $packages = array_merge($packages, $result['packages']);
  23334. $namesFound = array_merge($namesFound, $result['namesFound']);
  23335. }
  23336. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  23337. }
  23338. public function search($query, $mode = 0, $type = null)
  23339. {
  23340. $this->loadRootServerFile();
  23341. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  23342. $url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
  23343. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23344. if (empty($search['results'])) {
  23345. return array();
  23346. }
  23347. $results = array();
  23348. foreach ($search['results'] as $result) {
  23349. if (empty($result['virtual'])) {
  23350. $results[] = $result;
  23351. }
  23352. }
  23353. return $results;
  23354. }
  23355. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  23356. $results = array();
  23357. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  23358. foreach ($this->getPackageNames() as $name) {
  23359. if (preg_match($regex, $name)) {
  23360. $results[] = array('name' => $name);
  23361. }
  23362. }
  23363. return $results;
  23364. }
  23365. return parent::search($query, $mode);
  23366. }
  23367. public function getProviders($packageName)
  23368. {
  23369. $this->loadRootServerFile();
  23370. $result = array();
  23371. if ($this->providersApiUrl) {
  23372. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  23373. foreach ($apiResult['providers'] as $provider) {
  23374. $result[$provider['name']] = $provider;
  23375. }
  23376. return $result;
  23377. }
  23378. if ($this->hasPartialPackages()) {
  23379. foreach ($this->partialPackagesByName as $versions) {
  23380. foreach ($versions as $candidate) {
  23381. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  23382. continue;
  23383. }
  23384. $result[$candidate['name']] = array(
  23385. 'name' => $candidate['name'],
  23386. 'description' => isset($candidate['description']) ? $candidate['description'] : '',
  23387. 'type' => isset($candidate['type']) ? $candidate['type'] : '',
  23388. );
  23389. }
  23390. }
  23391. }
  23392. if ($this->packages) {
  23393. $result = array_merge($result, parent::getProviders($packageName));
  23394. }
  23395. return $result;
  23396. }
  23397. private function getProviderNames()
  23398. {
  23399. $this->loadRootServerFile();
  23400. if (null === $this->providerListing) {
  23401. $this->loadProviderListings($this->loadRootServerFile());
  23402. }
  23403. if ($this->lazyProvidersUrl) {
  23404. return array();
  23405. }
  23406. if ($this->providersUrl) {
  23407. return array_keys($this->providerListing);
  23408. }
  23409. return array();
  23410. }
  23411. protected function configurePackageTransportOptions(PackageInterface $package)
  23412. {
  23413. foreach ($package->getDistUrls() as $url) {
  23414. if (strpos($url, $this->baseUrl) === 0) {
  23415. $package->setTransportOptions($this->options);
  23416. return;
  23417. }
  23418. }
  23419. }
  23420. private function hasProviders()
  23421. {
  23422. $this->loadRootServerFile();
  23423. return $this->hasProviders;
  23424. }
  23425. private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23426. {
  23427. $packagesSource = null;
  23428. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  23429. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  23430. return array();
  23431. }
  23432. if (null === $this->providerListing) {
  23433. $this->loadProviderListings($this->loadRootServerFile());
  23434. }
  23435. $useLastModifiedCheck = false;
  23436. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  23437. $hash = null;
  23438. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23439. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23440. $useLastModifiedCheck = true;
  23441. } elseif ($this->providersUrl) {
  23442. if (!isset($this->providerListing[$name])) {
  23443. return array();
  23444. }
  23445. $hash = $this->providerListing[$name]['sha256'];
  23446. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  23447. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23448. } else {
  23449. return array();
  23450. }
  23451. $packages = null;
  23452. if ($cacheKey) {
  23453. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  23454. $packages = json_decode($this->cache->read($cacheKey), true);
  23455. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  23456. } elseif ($useLastModifiedCheck) {
  23457. if ($contents = $this->cache->read($cacheKey)) {
  23458. $contents = json_decode($contents, true);
  23459. if (isset($alreadyLoaded[$name])) {
  23460. $packages = $contents;
  23461. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  23462. } elseif (isset($contents['last-modified'])) {
  23463. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  23464. $packages = true === $response ? $contents : $response;
  23465. $packagesSource = true === $response ? 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')' : 'downloaded file ('.Url::sanitize($url).')';
  23466. }
  23467. }
  23468. }
  23469. }
  23470. if (!$packages) {
  23471. try {
  23472. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  23473. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  23474. } catch (TransportException $e) {
  23475. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  23476. $packages = array('packages' => array());
  23477. $packagesSource = 'not-found file ('.Url::sanitize($url).')';
  23478. if ($e->getStatusCode() === 499) {
  23479. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  23480. }
  23481. } else {
  23482. throw $e;
  23483. }
  23484. }
  23485. }
  23486. $loadingPartialPackage = false;
  23487. } else {
  23488. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  23489. $packagesSource = 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')';
  23490. $loadingPartialPackage = true;
  23491. }
  23492. $result = array();
  23493. $versionsToLoad = array();
  23494. foreach ($packages['packages'] as $versions) {
  23495. foreach ($versions as $version) {
  23496. $normalizedName = strtolower($version['name']);
  23497. if ($normalizedName !== $name) {
  23498. continue;
  23499. }
  23500. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  23501. continue;
  23502. }
  23503. if (!isset($versionsToLoad[$version['uid']])) {
  23504. if (!isset($version['version_normalized'])) {
  23505. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23506. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23507. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23508. }
  23509. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  23510. continue;
  23511. }
  23512. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  23513. $versionsToLoad[$version['uid']] = $version;
  23514. }
  23515. }
  23516. }
  23517. }
  23518. $loadedPackages = $this->createPackages($versionsToLoad, $packagesSource);
  23519. $uids = array_keys($versionsToLoad);
  23520. foreach ($loadedPackages as $index => $package) {
  23521. $package->setRepository($this);
  23522. $uid = $uids[$index];
  23523. if ($package instanceof AliasPackage) {
  23524. $aliased = $package->getAliasOf();
  23525. $aliased->setRepository($this);
  23526. $result[$uid] = $aliased;
  23527. $result[$uid.'-alias'] = $package;
  23528. } else {
  23529. $result[$uid] = $package;
  23530. }
  23531. }
  23532. return $result;
  23533. }
  23534. protected function initialize()
  23535. {
  23536. parent::initialize();
  23537. $repoData = $this->loadDataFromServer();
  23538. foreach ($this->createPackages($repoData, 'root file ('.Url::sanitize($this->getPackagesJsonUrl()).')') as $package) {
  23539. $this->addPackage($package);
  23540. }
  23541. }
  23542. public function addPackage(PackageInterface $package)
  23543. {
  23544. parent::addPackage($package);
  23545. $this->configurePackageTransportOptions($package);
  23546. }
  23547. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23548. {
  23549. $this->loadRootServerFile();
  23550. $packages = array();
  23551. $namesFound = array();
  23552. $promises = array();
  23553. $repo = $this;
  23554. if (!$this->lazyProvidersUrl) {
  23555. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  23556. }
  23557. foreach ($packageNames as $name => $constraint) {
  23558. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  23559. $packageNames[$name.'~dev'] = $constraint;
  23560. }
  23561. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  23562. unset($packageNames[$name]);
  23563. }
  23564. }
  23565. foreach ($packageNames as $name => $constraint) {
  23566. $name = strtolower($name);
  23567. $realName = preg_replace('{~dev$}', '', $name);
  23568. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  23569. continue;
  23570. }
  23571. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23572. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  23573. $lastModified = null;
  23574. if ($contents = $this->cache->read($cacheKey)) {
  23575. $contents = json_decode($contents, true);
  23576. $lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
  23577. }
  23578. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  23579. ->then(function ($response) use (&$packages, &$namesFound, $url, $cacheKey, $contents, $realName, $constraint, $repo, $acceptableStabilities, $stabilityFlags, $alreadyLoaded) {
  23580. $packagesSource = 'downloaded file ('.Url::sanitize($url).')';
  23581. if (true === $response) {
  23582. $packagesSource = 'cached file ('.$cacheKey.' originating from '.Url::sanitize($url).')';
  23583. $response = $contents;
  23584. }
  23585. if (!isset($response['packages'][$realName])) {
  23586. return;
  23587. }
  23588. $versions = $response['packages'][$realName];
  23589. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  23590. $versions = MetadataMinifier::expand($versions);
  23591. }
  23592. $namesFound[$realName] = true;
  23593. $versionsToLoad = array();
  23594. foreach ($versions as $version) {
  23595. if (!isset($version['version_normalized'])) {
  23596. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23597. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23598. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23599. }
  23600. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  23601. continue;
  23602. }
  23603. if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  23604. $versionsToLoad[] = $version;
  23605. }
  23606. }
  23607. $loadedPackages = $repo->createPackages($versionsToLoad, $packagesSource);
  23608. foreach ($loadedPackages as $package) {
  23609. $package->setRepository($repo);
  23610. $packages[spl_object_hash($package)] = $package;
  23611. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  23612. $package->getAliasOf()->setRepository($repo);
  23613. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  23614. }
  23615. }
  23616. });
  23617. }
  23618. $this->loop->wait($promises);
  23619. return array('namesFound' => $namesFound, 'packages' => $packages);
  23620. }
  23621. public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
  23622. {
  23623. $versions = array($versionData['version_normalized']);
  23624. if ($alias = $this->loader->getBranchAlias($versionData)) {
  23625. $versions[] = $alias;
  23626. }
  23627. foreach ($versions as $version) {
  23628. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  23629. continue;
  23630. }
  23631. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  23632. continue;
  23633. }
  23634. return true;
  23635. }
  23636. return false;
  23637. }
  23638. private function getPackagesJsonUrl()
  23639. {
  23640. $jsonUrlParts = parse_url($this->url);
  23641. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  23642. return $this->url;
  23643. }
  23644. return $this->url . '/packages.json';
  23645. }
  23646. protected function loadRootServerFile()
  23647. {
  23648. if (null !== $this->rootData) {
  23649. return $this->rootData;
  23650. }
  23651. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  23652. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  23653. }
  23654. $data = $this->fetchFile($this->getPackagesJsonUrl(), 'packages.json');
  23655. if (!empty($data['notify-batch'])) {
  23656. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  23657. } elseif (!empty($data['notify'])) {
  23658. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  23659. }
  23660. if (!empty($data['search'])) {
  23661. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  23662. }
  23663. if (!empty($data['mirrors'])) {
  23664. foreach ($data['mirrors'] as $mirror) {
  23665. if (!empty($mirror['git-url'])) {
  23666. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  23667. }
  23668. if (!empty($mirror['hg-url'])) {
  23669. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  23670. }
  23671. if (!empty($mirror['dist-url'])) {
  23672. $this->distMirrors[] = array(
  23673. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  23674. 'preferred' => !empty($mirror['preferred']),
  23675. );
  23676. }
  23677. }
  23678. }
  23679. if (!empty($data['providers-lazy-url'])) {
  23680. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  23681. $this->hasProviders = true;
  23682. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23683. }
  23684. if (!empty($data['metadata-url']) && !empty($data['list']) && $data['metadata-url'] === '/p/%package%.json' && $data['list'] === 'https://packagist.org/packages/list.json') {
  23685. $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>');
  23686. unset($data['metadata-url']);
  23687. }
  23688. if (!empty($data['metadata-url'])) {
  23689. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  23690. $this->providersUrl = null;
  23691. $this->hasProviders = false;
  23692. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23693. $this->allowSslDowngrade = false;
  23694. if (!empty($data['available-packages'])) {
  23695. $availPackages = array_map('strtolower', $data['available-packages']);
  23696. $this->availablePackages = array_combine($availPackages, $availPackages);
  23697. $this->hasAvailablePackageList = true;
  23698. }
  23699. if (!empty($data['available-package-patterns'])) {
  23700. $this->availablePackagePatterns = array_map(function ($pattern) {
  23701. return BasePackage::packageNameToRegexp($pattern);
  23702. }, $data['available-package-patterns']);
  23703. $this->hasAvailablePackageList = true;
  23704. }
  23705. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  23706. }
  23707. if ($this->allowSslDowngrade) {
  23708. $this->url = str_replace('https://', 'http://', $this->url);
  23709. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  23710. }
  23711. if (!empty($data['providers-url'])) {
  23712. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  23713. $this->hasProviders = true;
  23714. }
  23715. if (!empty($data['list'])) {
  23716. $this->listUrl = $this->canonicalizeUrl($data['list']);
  23717. }
  23718. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  23719. $this->hasProviders = true;
  23720. }
  23721. if (!empty($data['providers-api'])) {
  23722. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  23723. }
  23724. return $this->rootData = $data;
  23725. }
  23726. private function canonicalizeUrl($url)
  23727. {
  23728. if ('/' === $url[0]) {
  23729. if (preg_match('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  23730. return $matches[0] . $url;
  23731. }
  23732. return $this->url;
  23733. }
  23734. return $url;
  23735. }
  23736. private function loadDataFromServer()
  23737. {
  23738. $data = $this->loadRootServerFile();
  23739. return $this->loadIncludes($data);
  23740. }
  23741. private function hasPartialPackages()
  23742. {
  23743. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  23744. $this->initializePartialPackages();
  23745. }
  23746. return $this->hasPartialPackages;
  23747. }
  23748. private function loadProviderListings($data)
  23749. {
  23750. if (isset($data['providers'])) {
  23751. if (!is_array($this->providerListing)) {
  23752. $this->providerListing = array();
  23753. }
  23754. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  23755. }
  23756. if ($this->providersUrl && isset($data['provider-includes'])) {
  23757. $includes = $data['provider-includes'];
  23758. foreach ($includes as $include => $metadata) {
  23759. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  23760. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  23761. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  23762. $includedData = json_decode($this->cache->read($cacheKey), true);
  23763. } else {
  23764. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  23765. }
  23766. $this->loadProviderListings($includedData);
  23767. }
  23768. }
  23769. }
  23770. private function loadIncludes($data)
  23771. {
  23772. $packages = array();
  23773. if (!isset($data['packages']) && !isset($data['includes'])) {
  23774. foreach ($data as $pkg) {
  23775. foreach ($pkg['versions'] as $metadata) {
  23776. $packages[] = $metadata;
  23777. }
  23778. }
  23779. return $packages;
  23780. }
  23781. if (isset($data['packages'])) {
  23782. foreach ($data['packages'] as $package => $versions) {
  23783. foreach ($versions as $version => $metadata) {
  23784. $packages[] = $metadata;
  23785. }
  23786. }
  23787. }
  23788. if (isset($data['includes'])) {
  23789. foreach ($data['includes'] as $include => $metadata) {
  23790. if (isset($metadata['sha1']) && $this->cache->sha1($include) === $metadata['sha1']) {
  23791. $includedData = json_decode($this->cache->read($include), true);
  23792. } else {
  23793. $includedData = $this->fetchFile($include);
  23794. }
  23795. $packages = array_merge($packages, $this->loadIncludes($includedData));
  23796. }
  23797. }
  23798. return $packages;
  23799. }
  23800. public function createPackages(array $packages, $source = null)
  23801. {
  23802. if (!$packages) {
  23803. return array();
  23804. }
  23805. try {
  23806. foreach ($packages as &$data) {
  23807. if (!isset($data['notification-url'])) {
  23808. $data['notification-url'] = $this->notifyUrl;
  23809. }
  23810. }
  23811. $packageInstances = $this->loader->loadPackages($packages, 'Composer\Package\CompletePackage');
  23812. foreach ($packageInstances as $package) {
  23813. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  23814. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  23815. }
  23816. $package->setDistMirrors($this->distMirrors);
  23817. $this->configurePackageTransportOptions($package);
  23818. }
  23819. return $packageInstances;
  23820. } catch (\Exception $e) {
  23821. 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);
  23822. }
  23823. }
  23824. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  23825. {
  23826. if (null === $cacheKey) {
  23827. $cacheKey = $filename;
  23828. $filename = $this->baseUrl.'/'.$filename;
  23829. }
  23830. if (($pos = strpos($filename, '$')) && preg_match('{^https?://}i', $filename)) {
  23831. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  23832. }
  23833. $retries = 3;
  23834. while ($retries--) {
  23835. try {
  23836. if ($this->eventDispatcher) {
  23837. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23838. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23839. $filename = $preFileDownloadEvent->getProcessedUrl();
  23840. }
  23841. $response = $this->httpDownloader->get($filename, $this->options);
  23842. $json = $response->getBody();
  23843. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  23844. if ($this->allowSslDowngrade) {
  23845. $this->url = str_replace('http://', 'https://', $this->url);
  23846. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  23847. $filename = str_replace('http://', 'https://', $filename);
  23848. }
  23849. if ($retries) {
  23850. usleep(100000);
  23851. continue;
  23852. }
  23853. 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.');
  23854. }
  23855. $data = $response->decodeJson();
  23856. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23857. if ($cacheKey && !$this->cache->isReadOnly()) {
  23858. if ($storeLastModifiedTime) {
  23859. $lastModifiedDate = $response->getHeader('last-modified');
  23860. if ($lastModifiedDate) {
  23861. $data['last-modified'] = $lastModifiedDate;
  23862. $json = json_encode($data);
  23863. }
  23864. }
  23865. $this->cache->write($cacheKey, $json);
  23866. }
  23867. $response->collect();
  23868. break;
  23869. } catch (\Exception $e) {
  23870. if ($e instanceof \LogicException) {
  23871. throw $e;
  23872. }
  23873. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23874. throw $e;
  23875. }
  23876. if ($retries) {
  23877. usleep(100000);
  23878. continue;
  23879. }
  23880. if ($e instanceof RepositorySecurityException) {
  23881. throw $e;
  23882. }
  23883. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  23884. if (!$this->degradedMode) {
  23885. $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>');
  23886. }
  23887. $this->degradedMode = true;
  23888. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  23889. break;
  23890. }
  23891. throw $e;
  23892. }
  23893. }
  23894. if (!isset($data)) {
  23895. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  23896. }
  23897. return $data;
  23898. }
  23899. private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  23900. {
  23901. $retries = 3;
  23902. while ($retries--) {
  23903. try {
  23904. if ($this->eventDispatcher) {
  23905. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23906. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23907. $filename = $preFileDownloadEvent->getProcessedUrl();
  23908. }
  23909. $options = $this->options;
  23910. if (isset($options['http']['header'])) {
  23911. $options['http']['header'] = (array) $options['http']['header'];
  23912. }
  23913. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23914. $response = $this->httpDownloader->get($filename, $options);
  23915. $json = $response->getBody();
  23916. if ($json === '' && $response->getStatusCode() === 304) {
  23917. return true;
  23918. }
  23919. $data = $response->decodeJson();
  23920. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23921. $lastModifiedDate = $response->getHeader('last-modified');
  23922. $response->collect();
  23923. if ($lastModifiedDate) {
  23924. $data['last-modified'] = $lastModifiedDate;
  23925. $json = json_encode($data);
  23926. }
  23927. if (!$this->cache->isReadOnly()) {
  23928. $this->cache->write($cacheKey, $json);
  23929. }
  23930. return $data;
  23931. } catch (\Exception $e) {
  23932. if ($e instanceof \LogicException) {
  23933. throw $e;
  23934. }
  23935. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23936. throw $e;
  23937. }
  23938. if ($retries) {
  23939. usleep(100000);
  23940. continue;
  23941. }
  23942. if (!$this->degradedMode) {
  23943. $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>');
  23944. }
  23945. $this->degradedMode = true;
  23946. return true;
  23947. }
  23948. }
  23949. }
  23950. private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
  23951. {
  23952. $retries = 3;
  23953. if (isset($this->packagesNotFoundCache[$filename])) {
  23954. return \React\Promise\resolve(array('packages' => array()));
  23955. }
  23956. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  23957. return \React\Promise\resolve(true);
  23958. }
  23959. $httpDownloader = $this->httpDownloader;
  23960. if ($this->eventDispatcher) {
  23961. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23962. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23963. $filename = $preFileDownloadEvent->getProcessedUrl();
  23964. }
  23965. $options = $this->options;
  23966. if ($lastModifiedTime) {
  23967. if (isset($options['http']['header'])) {
  23968. $options['http']['header'] = (array) $options['http']['header'];
  23969. }
  23970. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23971. }
  23972. $io = $this->io;
  23973. $url = $this->url;
  23974. $cache = $this->cache;
  23975. $degradedMode = &$this->degradedMode;
  23976. $repo = $this;
  23977. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) {
  23978. if ($response->getStatusCode() === 404) {
  23979. $repo->packagesNotFoundCache[$filename] = true;
  23980. return array('packages' => array());
  23981. }
  23982. $json = $response->getBody();
  23983. if ($json === '' && $response->getStatusCode() === 304) {
  23984. $repo->freshMetadataUrls[$filename] = true;
  23985. return true;
  23986. }
  23987. $data = $response->decodeJson();
  23988. HttpDownloader::outputWarnings($io, $url, $data);
  23989. $lastModifiedDate = $response->getHeader('last-modified');
  23990. $response->collect();
  23991. if ($lastModifiedDate) {
  23992. $data['last-modified'] = $lastModifiedDate;
  23993. $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE);
  23994. }
  23995. if (!$cache->isReadOnly()) {
  23996. $cache->write($cacheKey, $json);
  23997. }
  23998. $repo->freshMetadataUrls[$filename] = true;
  23999. return $data;
  24000. };
  24001. $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) {
  24002. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  24003. $repo->packagesNotFoundCache[$filename] = true;
  24004. return false;
  24005. }
  24006. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  24007. $retries = 0;
  24008. }
  24009. if (--$retries > 0) {
  24010. usleep(100000);
  24011. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  24012. }
  24013. if (!$degradedMode) {
  24014. $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>');
  24015. }
  24016. $degradedMode = true;
  24017. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  24018. return $accept(new Response(array('url' => $url), 404, array(), ''));
  24019. }
  24020. throw $e;
  24021. };
  24022. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  24023. }
  24024. private function initializePartialPackages()
  24025. {
  24026. $rootData = $this->loadRootServerFile();
  24027. $this->partialPackagesByName = array();
  24028. foreach ($rootData['packages'] as $package => $versions) {
  24029. foreach ($versions as $version) {
  24030. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  24031. }
  24032. }
  24033. $this->rootData = true;
  24034. }
  24035. protected function lazyProvidersRepoContains($name)
  24036. {
  24037. if (!$this->hasAvailablePackageList) {
  24038. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  24039. }
  24040. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  24041. return true;
  24042. }
  24043. if (is_array($this->availablePackagePatterns)) {
  24044. foreach ($this->availablePackagePatterns as $providerRegex) {
  24045. if (preg_match($providerRegex, $name)) {
  24046. return true;
  24047. }
  24048. }
  24049. }
  24050. return false;
  24051. }
  24052. }
  24053. <?php
  24054. namespace Composer\Repository;
  24055. use Composer\Package\PackageInterface;
  24056. class CompositeRepository implements RepositoryInterface
  24057. {
  24058. private $repositories;
  24059. public function __construct(array $repositories)
  24060. {
  24061. $this->repositories = array();
  24062. foreach ($repositories as $repo) {
  24063. $this->addRepository($repo);
  24064. }
  24065. }
  24066. public function getRepoName()
  24067. {
  24068. return 'composite repo ('.implode(', ', array_map(function ($repo) {
  24069. return $repo->getRepoName();
  24070. }, $this->repositories)).')';
  24071. }
  24072. public function getRepositories()
  24073. {
  24074. return $this->repositories;
  24075. }
  24076. public function hasPackage(PackageInterface $package)
  24077. {
  24078. foreach ($this->repositories as $repository) {
  24079. if ($repository->hasPackage($package)) {
  24080. return true;
  24081. }
  24082. }
  24083. return false;
  24084. }
  24085. public function findPackage($name, $constraint)
  24086. {
  24087. foreach ($this->repositories as $repository) {
  24088. $package = $repository->findPackage($name, $constraint);
  24089. if (null !== $package) {
  24090. return $package;
  24091. }
  24092. }
  24093. return null;
  24094. }
  24095. public function findPackages($name, $constraint = null)
  24096. {
  24097. $packages = array();
  24098. foreach ($this->repositories as $repository) {
  24099. $packages[] = $repository->findPackages($name, $constraint);
  24100. }
  24101. return $packages ? call_user_func_array('array_merge', $packages) : array();
  24102. }
  24103. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  24104. {
  24105. $packages = array();
  24106. $namesFound = array();
  24107. foreach ($this->repositories as $repository) {
  24108. $result = $repository->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24109. $packages[] = $result['packages'];
  24110. $namesFound[] = $result['namesFound'];
  24111. }
  24112. return array(
  24113. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  24114. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  24115. );
  24116. }
  24117. public function search($query, $mode = 0, $type = null)
  24118. {
  24119. $matches = array();
  24120. foreach ($this->repositories as $repository) {
  24121. $matches[] = $repository->search($query, $mode, $type);
  24122. }
  24123. return $matches ? call_user_func_array('array_merge', $matches) : array();
  24124. }
  24125. public function getPackages()
  24126. {
  24127. $packages = array();
  24128. foreach ($this->repositories as $repository) {
  24129. $packages[] = $repository->getPackages();
  24130. }
  24131. return $packages ? call_user_func_array('array_merge', $packages) : array();
  24132. }
  24133. public function getProviders($packageName)
  24134. {
  24135. $results = array();
  24136. foreach ($this->repositories as $repository) {
  24137. $results[] = $repository->getProviders($packageName);
  24138. }
  24139. return $results ? call_user_func_array('array_merge', $results) : array();
  24140. }
  24141. public function removePackage(PackageInterface $package)
  24142. {
  24143. foreach ($this->repositories as $repository) {
  24144. $repository->removePackage($package);
  24145. }
  24146. }
  24147. public function count()
  24148. {
  24149. $total = 0;
  24150. foreach ($this->repositories as $repository) {
  24151. $total += $repository->count();
  24152. }
  24153. return $total;
  24154. }
  24155. public function addRepository(RepositoryInterface $repository)
  24156. {
  24157. if ($repository instanceof self) {
  24158. foreach ($repository->getRepositories() as $repo) {
  24159. $this->addRepository($repo);
  24160. }
  24161. } else {
  24162. $this->repositories[] = $repository;
  24163. }
  24164. }
  24165. }
  24166. <?php
  24167. namespace Composer\Repository;
  24168. interface ConfigurableRepositoryInterface
  24169. {
  24170. public function getRepoConfig();
  24171. }
  24172. <?php
  24173. namespace Composer\Repository;
  24174. use Composer\Json\JsonFile;
  24175. use Composer\Package\Loader\ArrayLoader;
  24176. use Composer\Package\RootPackageInterface;
  24177. use Composer\Package\AliasPackage;
  24178. use Composer\Package\Dumper\ArrayDumper;
  24179. use Composer\Installer\InstallationManager;
  24180. use Composer\Util\Filesystem;
  24181. class FilesystemRepository extends WritableArrayRepository
  24182. {
  24183. protected $file;
  24184. private $dumpVersions;
  24185. private $rootPackage;
  24186. public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null)
  24187. {
  24188. parent::__construct();
  24189. $this->file = $repositoryFile;
  24190. $this->dumpVersions = $dumpVersions;
  24191. $this->rootPackage = $rootPackage;
  24192. if ($dumpVersions && !$rootPackage) {
  24193. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  24194. }
  24195. }
  24196. protected function initialize()
  24197. {
  24198. parent::initialize();
  24199. if (!$this->file->exists()) {
  24200. return;
  24201. }
  24202. try {
  24203. $data = $this->file->read();
  24204. if (isset($data['packages'])) {
  24205. $packages = $data['packages'];
  24206. } else {
  24207. $packages = $data;
  24208. }
  24209. if (isset($data['dev-package-names'])) {
  24210. $this->setDevPackageNames($data['dev-package-names']);
  24211. }
  24212. if (!is_array($packages)) {
  24213. throw new \UnexpectedValueException('Could not parse package list from the repository');
  24214. }
  24215. } catch (\Exception $e) {
  24216. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  24217. }
  24218. $loader = new ArrayLoader(null, true);
  24219. foreach ($packages as $packageData) {
  24220. $package = $loader->load($packageData);
  24221. $this->addPackage($package);
  24222. }
  24223. }
  24224. public function reload()
  24225. {
  24226. $this->packages = null;
  24227. $this->initialize();
  24228. }
  24229. public function write($devMode, InstallationManager $installationManager)
  24230. {
  24231. $data = array('packages' => array(), 'dev' => $devMode, 'dev-package-names' => array());
  24232. $dumper = new ArrayDumper();
  24233. $fs = new Filesystem();
  24234. $repoDir = dirname($fs->normalizePath($this->file->getPath()));
  24235. foreach ($this->getCanonicalPackages() as $package) {
  24236. $pkgArray = $dumper->dump($package);
  24237. $path = $installationManager->getInstallPath($package);
  24238. $pkgArray['install-path'] = ('' !== $path && null !== $path) ? $fs->findShortestPath($repoDir, $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path, true) : null;
  24239. $data['packages'][] = $pkgArray;
  24240. if (in_array($package->getName(), $this->devPackageNames, true)) {
  24241. $data['dev-package-names'][] = $package->getName();
  24242. }
  24243. }
  24244. sort($data['dev-package-names']);
  24245. usort($data['packages'], function ($a, $b) {
  24246. return strcmp($a['name'], $b['name']);
  24247. });
  24248. $this->file->write($data);
  24249. if ($this->dumpVersions) {
  24250. $versions = $this->generateInstalledVersions($installationManager);
  24251. $fs->filePutContentsIfModified($repoDir.'/installed.php', '<?php return '.var_export($versions, true).';'."\n");
  24252. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  24253. $installedVersionsClass = str_replace('private static $installed;', 'private static $installed = '.var_export($versions, true).';', $installedVersionsClass);
  24254. $fs->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  24255. \Composer\InstalledVersions::reload($versions);
  24256. }
  24257. }
  24258. private function generateInstalledVersions(InstallationManager $installationManager)
  24259. {
  24260. if (!$this->dumpVersions) {
  24261. return null;
  24262. }
  24263. $versions = array('versions' => array());
  24264. $packages = $this->getPackages();
  24265. $packages[] = $rootPackage = $this->rootPackage;
  24266. while ($rootPackage instanceof AliasPackage) {
  24267. $rootPackage = $rootPackage->getAliasOf();
  24268. $packages[] = $rootPackage;
  24269. }
  24270. foreach ($packages as $package) {
  24271. if ($package instanceof AliasPackage) {
  24272. continue;
  24273. }
  24274. $reference = null;
  24275. if ($package->getInstallationSource()) {
  24276. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  24277. }
  24278. if (null === $reference) {
  24279. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  24280. }
  24281. $versions['versions'][$package->getName()] = array(
  24282. 'pretty_version' => $package->getPrettyVersion(),
  24283. 'version' => $package->getVersion(),
  24284. 'aliases' => array(),
  24285. 'reference' => $reference,
  24286. );
  24287. if ($package instanceof RootPackageInterface) {
  24288. $versions['root'] = $versions['versions'][$package->getName()];
  24289. $versions['root']['name'] = $package->getName();
  24290. }
  24291. }
  24292. foreach ($packages as $package) {
  24293. foreach ($package->getReplaces() as $replace) {
  24294. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  24295. continue;
  24296. }
  24297. $replaced = $replace->getPrettyConstraint();
  24298. if ($replaced === 'self.version') {
  24299. $replaced = $package->getPrettyVersion();
  24300. }
  24301. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  24302. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  24303. }
  24304. }
  24305. foreach ($package->getProvides() as $provide) {
  24306. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  24307. continue;
  24308. }
  24309. $provided = $provide->getPrettyConstraint();
  24310. if ($provided === 'self.version') {
  24311. $provided = $package->getPrettyVersion();
  24312. }
  24313. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  24314. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  24315. }
  24316. }
  24317. }
  24318. foreach ($packages as $package) {
  24319. if (!$package instanceof AliasPackage) {
  24320. continue;
  24321. }
  24322. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  24323. if ($package instanceof RootPackageInterface) {
  24324. $versions['root']['aliases'][] = $package->getPrettyVersion();
  24325. }
  24326. }
  24327. ksort($versions['versions']);
  24328. ksort($versions);
  24329. return $versions;
  24330. }
  24331. }
  24332. <?php
  24333. namespace Composer\Repository;
  24334. use Composer\Package\PackageInterface;
  24335. use Composer\Package\BasePackage;
  24336. class FilterRepository implements RepositoryInterface
  24337. {
  24338. private $only = array();
  24339. private $exclude = array();
  24340. private $canonical = true;
  24341. private $repo;
  24342. public function __construct(RepositoryInterface $repo, array $options)
  24343. {
  24344. if (isset($options['only'])) {
  24345. if (!is_array($options['only'])) {
  24346. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  24347. }
  24348. $this->only = '{^'.implode('|', array_map(function ($val) {
  24349. return BasePackage::packageNameToRegexp($val, '%s');
  24350. }, $options['only'])) .'$}iD';
  24351. }
  24352. if (isset($options['exclude'])) {
  24353. if (!is_array($options['exclude'])) {
  24354. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  24355. }
  24356. $this->exclude = '{^'.implode('|', array_map(function ($val) {
  24357. return BasePackage::packageNameToRegexp($val, '%s');
  24358. }, $options['exclude'])) .'$}iD';
  24359. }
  24360. if ($this->exclude && $this->only) {
  24361. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  24362. }
  24363. if (isset($options['canonical'])) {
  24364. if (!is_bool($options['canonical'])) {
  24365. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  24366. }
  24367. $this->canonical = $options['canonical'];
  24368. }
  24369. $this->repo = $repo;
  24370. }
  24371. public function getRepoName()
  24372. {
  24373. return $this->repo->getRepoName();
  24374. }
  24375. public function getRepository()
  24376. {
  24377. return $this->repo;
  24378. }
  24379. public function hasPackage(PackageInterface $package)
  24380. {
  24381. return $this->repo->hasPackage($package);
  24382. }
  24383. public function findPackage($name, $constraint)
  24384. {
  24385. if (!$this->isAllowed($name)) {
  24386. return null;
  24387. }
  24388. return $this->repo->findPackage($name, $constraint);
  24389. }
  24390. public function findPackages($name, $constraint = null)
  24391. {
  24392. if (!$this->isAllowed($name)) {
  24393. return array();
  24394. }
  24395. return $this->repo->findPackages($name, $constraint);
  24396. }
  24397. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  24398. {
  24399. foreach ($packageMap as $name => $constraint) {
  24400. if (!$this->isAllowed($name)) {
  24401. unset($packageMap[$name]);
  24402. }
  24403. }
  24404. if (!$packageMap) {
  24405. return array('namesFound' => array(), 'packages' => array());
  24406. }
  24407. $result = $this->repo->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24408. if (!$this->canonical) {
  24409. $result['namesFound'] = array();
  24410. }
  24411. return $result;
  24412. }
  24413. public function search($query, $mode = 0, $type = null)
  24414. {
  24415. $result = array();
  24416. foreach ($this->repo->search($query, $mode, $type) as $package) {
  24417. if ($this->isAllowed($package['name'])) {
  24418. $result[] = $package;
  24419. }
  24420. }
  24421. return $result;
  24422. }
  24423. public function getPackages()
  24424. {
  24425. $result = array();
  24426. foreach ($this->repo->getPackages() as $package) {
  24427. if ($this->isAllowed($package->getName())) {
  24428. $result[] = $package;
  24429. }
  24430. }
  24431. return $result;
  24432. }
  24433. public function getProviders($packageName)
  24434. {
  24435. $result = array();
  24436. foreach ($this->repo->getProviders($packageName) as $provider) {
  24437. if ($this->isAllowed($provider['name'])) {
  24438. $result[] = $provider;
  24439. }
  24440. }
  24441. return $result;
  24442. }
  24443. public function removePackage(PackageInterface $package)
  24444. {
  24445. return $this->repo->removePackage($package);
  24446. }
  24447. public function count()
  24448. {
  24449. if ($this->repo->count() > 0) {
  24450. return count($this->getPackages());
  24451. }
  24452. return 0;
  24453. }
  24454. private function isAllowed($name)
  24455. {
  24456. if (!$this->only && !$this->exclude) {
  24457. return true;
  24458. }
  24459. if ($this->only) {
  24460. return (bool) preg_match($this->only, $name);
  24461. }
  24462. return !preg_match($this->exclude, $name);
  24463. }
  24464. }
  24465. <?php
  24466. namespace Composer\Repository;
  24467. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  24468. {
  24469. public function getRepoName()
  24470. {
  24471. return 'installed '.parent::getRepoName();
  24472. }
  24473. public function isFresh()
  24474. {
  24475. return $this->count() === 0;
  24476. }
  24477. }
  24478. <?php
  24479. namespace Composer\Repository;
  24480. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  24481. {
  24482. public function getRepoName()
  24483. {
  24484. return 'installed '.parent::getRepoName();
  24485. }
  24486. public function isFresh()
  24487. {
  24488. return !$this->file->exists();
  24489. }
  24490. }
  24491. <?php
  24492. namespace Composer\Repository;
  24493. use Composer\Package\Version\VersionParser;
  24494. use Composer\Semver\Constraint\ConstraintInterface;
  24495. use Composer\Semver\Constraint\Constraint;
  24496. use Composer\Semver\Constraint\MatchAllConstraint;
  24497. use Composer\Package\RootPackageInterface;
  24498. use Composer\Package\Link;
  24499. class InstalledRepository extends CompositeRepository
  24500. {
  24501. public function findPackagesWithReplacersAndProviders($name, $constraint = null)
  24502. {
  24503. $name = strtolower($name);
  24504. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  24505. $versionParser = new VersionParser();
  24506. $constraint = $versionParser->parseConstraints($constraint);
  24507. }
  24508. $matches = array();
  24509. foreach ($this->getRepositories() as $repo) {
  24510. foreach ($repo->getPackages() as $candidate) {
  24511. if ($name === $candidate->getName()) {
  24512. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  24513. $matches[] = $candidate;
  24514. }
  24515. continue;
  24516. }
  24517. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  24518. if (
  24519. $name === $link->getTarget()
  24520. && ($constraint === null || $link->getConstraint() === null || $constraint->matches($link->getConstraint()))
  24521. ) {
  24522. $matches[] = $candidate;
  24523. continue 2;
  24524. }
  24525. }
  24526. }
  24527. }
  24528. return $matches;
  24529. }
  24530. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  24531. {
  24532. $needles = array_map('strtolower', (array) $needle);
  24533. $results = array();
  24534. if (null === $packagesFound) {
  24535. $packagesFound = $needles;
  24536. }
  24537. $rootPackage = null;
  24538. foreach ($this->getPackages() as $package) {
  24539. if ($package instanceof RootPackageInterface) {
  24540. $rootPackage = $package;
  24541. break;
  24542. }
  24543. }
  24544. foreach ($this->getPackages() as $package) {
  24545. $links = $package->getRequires();
  24546. $packagesInTree = $packagesFound;
  24547. if (!$invert) {
  24548. $links += $package->getReplaces();
  24549. foreach ($package->getReplaces() as $link) {
  24550. foreach ($needles as $needle) {
  24551. if ($link->getSource() === $needle) {
  24552. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24553. if (in_array($link->getTarget(), $packagesInTree)) {
  24554. $results[] = array($package, $link, false);
  24555. continue;
  24556. }
  24557. $packagesInTree[] = $link->getTarget();
  24558. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  24559. $results[] = array($package, $link, $dependents);
  24560. $needles[] = $link->getTarget();
  24561. }
  24562. }
  24563. }
  24564. }
  24565. }
  24566. if ($package instanceof RootPackageInterface) {
  24567. $links += $package->getDevRequires();
  24568. }
  24569. foreach ($links as $link) {
  24570. foreach ($needles as $needle) {
  24571. if ($link->getTarget() === $needle) {
  24572. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24573. if (in_array($link->getSource(), $packagesInTree)) {
  24574. $results[] = array($package, $link, false);
  24575. continue;
  24576. }
  24577. $packagesInTree[] = $link->getSource();
  24578. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  24579. $results[] = array($package, $link, $dependents);
  24580. }
  24581. }
  24582. }
  24583. }
  24584. if ($invert && in_array($package->getName(), $needles)) {
  24585. foreach ($package->getConflicts() as $link) {
  24586. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  24587. $version = new Constraint('=', $pkg->getVersion());
  24588. if ($link->getConstraint()->matches($version) === $invert) {
  24589. $results[] = array($package, $link, false);
  24590. }
  24591. }
  24592. }
  24593. }
  24594. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  24595. foreach ($package->getRequires() as $link) {
  24596. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  24597. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  24598. continue;
  24599. }
  24600. $platformPkg = $this->findPackage($link->getTarget(), '*');
  24601. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  24602. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  24603. continue;
  24604. }
  24605. foreach ($this->getPackages() as $pkg) {
  24606. if (!in_array($link->getTarget(), $pkg->getNames())) {
  24607. continue;
  24608. }
  24609. $version = new Constraint('=', $pkg->getVersion());
  24610. if ($link->getTarget() !== $pkg->getName()) {
  24611. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  24612. if ($link->getTarget() === $prov->getTarget()) {
  24613. $version = $prov->getConstraint();
  24614. break;
  24615. }
  24616. }
  24617. }
  24618. if (!$link->getConstraint()->matches($version)) {
  24619. if ($rootPackage) {
  24620. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  24621. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  24622. $results[] = array($package, $link, false);
  24623. $results[] = array($rootPackage, $rootReq, false);
  24624. continue 3;
  24625. }
  24626. }
  24627. $results[] = array($package, $link, false);
  24628. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, 'does not require', 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  24629. } else {
  24630. $results[] = array($package, $link, false);
  24631. }
  24632. }
  24633. continue 2;
  24634. }
  24635. }
  24636. }
  24637. }
  24638. ksort($results);
  24639. return $results;
  24640. }
  24641. public function getRepoName()
  24642. {
  24643. return 'installed repo ('.implode(', ', array_map(function ($repo) {
  24644. return $repo->getRepoName();
  24645. }, $this->getRepositories())).')';
  24646. }
  24647. public function addRepository(RepositoryInterface $repository)
  24648. {
  24649. if (
  24650. $repository instanceof LockArrayRepository
  24651. || $repository instanceof InstalledRepositoryInterface
  24652. || $repository instanceof RootPackageRepository
  24653. || $repository instanceof PlatformRepository
  24654. ) {
  24655. return parent::addRepository($repository);
  24656. }
  24657. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  24658. }
  24659. }
  24660. <?php
  24661. namespace Composer\Repository;
  24662. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  24663. {
  24664. public function isFresh();
  24665. }
  24666. <?php
  24667. namespace Composer\Repository;
  24668. class InvalidRepositoryException extends \Exception
  24669. {
  24670. }
  24671. <?php
  24672. namespace Composer\Repository;
  24673. class LockArrayRepository extends ArrayRepository
  24674. {
  24675. public function getRepoName()
  24676. {
  24677. return 'lock repo';
  24678. }
  24679. }
  24680. <?php
  24681. namespace Composer\Repository;
  24682. use Composer\Package\Loader\ArrayLoader;
  24683. use Composer\Package\Loader\ValidatingArrayLoader;
  24684. class PackageRepository extends ArrayRepository
  24685. {
  24686. private $config;
  24687. public function __construct(array $config)
  24688. {
  24689. parent::__construct();
  24690. $this->config = $config['package'];
  24691. if (!is_numeric(key($this->config))) {
  24692. $this->config = array($this->config);
  24693. }
  24694. }
  24695. protected function initialize()
  24696. {
  24697. parent::initialize();
  24698. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
  24699. foreach ($this->config as $package) {
  24700. try {
  24701. $package = $loader->load($package);
  24702. } catch (\Exception $e) {
  24703. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  24704. }
  24705. $this->addPackage($package);
  24706. }
  24707. }
  24708. public function getRepoName()
  24709. {
  24710. return preg_replace('{^array }', 'package ', parent::getRepoName());
  24711. }
  24712. }
  24713. <?php
  24714. namespace Composer\Repository;
  24715. use Composer\Config;
  24716. use Composer\IO\IOInterface;
  24717. use Composer\Json\JsonFile;
  24718. use Composer\Package\Loader\ArrayLoader;
  24719. use Composer\Package\Version\VersionGuesser;
  24720. use Composer\Package\Version\VersionParser;
  24721. use Composer\Util\Platform;
  24722. use Composer\Util\ProcessExecutor;
  24723. use Composer\Util\Filesystem;
  24724. use Composer\Util\Url;
  24725. use Composer\Util\Git as GitUtil;
  24726. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  24727. {
  24728. private $loader;
  24729. private $versionGuesser;
  24730. private $url;
  24731. private $repoConfig;
  24732. private $process;
  24733. private $options;
  24734. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  24735. {
  24736. if (!isset($repoConfig['url'])) {
  24737. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  24738. }
  24739. $this->loader = new ArrayLoader(null, true);
  24740. $this->url = Platform::expandPath($repoConfig['url']);
  24741. $this->process = new ProcessExecutor($io);
  24742. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  24743. $this->repoConfig = $repoConfig;
  24744. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  24745. if (!isset($this->options['relative'])) {
  24746. $filesystem = new Filesystem();
  24747. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  24748. }
  24749. parent::__construct();
  24750. }
  24751. public function getRepoName()
  24752. {
  24753. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  24754. }
  24755. public function getRepoConfig()
  24756. {
  24757. return $this->repoConfig;
  24758. }
  24759. protected function initialize()
  24760. {
  24761. parent::initialize();
  24762. $urlMatches = $this->getUrlMatches();
  24763. if (empty($urlMatches)) {
  24764. if (preg_match('{[*{}]}', $this->url)) {
  24765. $url = $this->url;
  24766. while (preg_match('{[*{}]}', $url)) {
  24767. $url = dirname($url);
  24768. }
  24769. if (is_dir($url)) {
  24770. return;
  24771. }
  24772. }
  24773. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  24774. }
  24775. foreach ($urlMatches as $url) {
  24776. $path = realpath($url) . DIRECTORY_SEPARATOR;
  24777. $composerFilePath = $path.'composer.json';
  24778. if (!file_exists($composerFilePath)) {
  24779. continue;
  24780. }
  24781. $json = file_get_contents($composerFilePath);
  24782. $package = JsonFile::parseJson($json, $composerFilePath);
  24783. $package['dist'] = array(
  24784. 'type' => 'path',
  24785. 'url' => $url,
  24786. 'reference' => sha1($json . serialize($this->options)),
  24787. );
  24788. $package['transport-options'] = $this->options;
  24789. unset($package['transport-options']['versions']);
  24790. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  24791. $package['version'] = $this->options['versions'][$package['name']];
  24792. }
  24793. if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
  24794. if (
  24795. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  24796. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  24797. && $ref1 === $ref2
  24798. ) {
  24799. $package['version'] = $rootVersion;
  24800. }
  24801. }
  24802. $output = '';
  24803. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  24804. $package['dist']['reference'] = trim($output);
  24805. }
  24806. if (!isset($package['version'])) {
  24807. $versionData = $this->versionGuesser->guessVersion($package, $path);
  24808. if (is_array($versionData) && $versionData['pretty_version']) {
  24809. if (!empty($versionData['feature_pretty_version'])) {
  24810. $package['version'] = $versionData['feature_pretty_version'];
  24811. $this->addPackage($this->loader->load($package));
  24812. }
  24813. $package['version'] = $versionData['pretty_version'];
  24814. } else {
  24815. $package['version'] = 'dev-master';
  24816. }
  24817. }
  24818. $package = $this->loader->load($package);
  24819. $this->addPackage($package);
  24820. }
  24821. }
  24822. private function getUrlMatches()
  24823. {
  24824. $flags = GLOB_MARK | GLOB_ONLYDIR;
  24825. if (defined('GLOB_BRACE')) {
  24826. $flags |= GLOB_BRACE;
  24827. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  24828. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  24829. }
  24830. return array_map(function ($val) {
  24831. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  24832. }, glob($this->url, $flags));
  24833. }
  24834. }
  24835. <?php
  24836. namespace Composer\Repository;
  24837. class PearRepository extends ArrayRepository
  24838. {
  24839. public function __construct()
  24840. {
  24841. throw new \RuntimeException('The PEAR repository has been removed from Composer 2.0');
  24842. }
  24843. }
  24844. <?php
  24845. namespace Composer\Repository;
  24846. use Composer\Composer;
  24847. use Composer\Package\CompletePackage;
  24848. use Composer\Package\Link;
  24849. use Composer\Package\PackageInterface;
  24850. use Composer\Package\Version\VersionParser;
  24851. use Composer\Platform\HhvmDetector;
  24852. use Composer\Platform\Runtime;
  24853. use Composer\Platform\Version;
  24854. use Composer\Plugin\PluginInterface;
  24855. use Composer\Semver\Constraint\Constraint;
  24856. use Composer\Util\Silencer;
  24857. use Composer\XdebugHandler\XdebugHandler;
  24858. class PlatformRepository extends ArrayRepository
  24859. {
  24860. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
  24861. private $versionParser;
  24862. private $overrides = array();
  24863. private $runtime;
  24864. private $hhvmDetector;
  24865. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  24866. {
  24867. $this->runtime = $runtime ?: new Runtime();
  24868. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  24869. foreach ($overrides as $name => $version) {
  24870. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  24871. }
  24872. parent::__construct($packages);
  24873. }
  24874. public function getRepoName()
  24875. {
  24876. return 'platform repo';
  24877. }
  24878. protected function initialize()
  24879. {
  24880. parent::initialize();
  24881. $this->versionParser = new VersionParser();
  24882. foreach ($this->overrides as $override) {
  24883. if (!self::isPlatformPackage($override['name'])) {
  24884. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  24885. }
  24886. $this->addOverriddenPackage($override);
  24887. }
  24888. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  24889. $version = $this->versionParser->normalize($prettyVersion);
  24890. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  24891. $composerPluginApi->setDescription('The Composer Plugin API');
  24892. $this->addPackage($composerPluginApi);
  24893. $prettyVersion = Composer::RUNTIME_API_VERSION;
  24894. $version = $this->versionParser->normalize($prettyVersion);
  24895. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  24896. $composerRuntimeApi->setDescription('The Composer Runtime API');
  24897. $this->addPackage($composerRuntimeApi);
  24898. try {
  24899. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  24900. $version = $this->versionParser->normalize($prettyVersion);
  24901. } catch (\UnexpectedValueException $e) {
  24902. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  24903. $version = $this->versionParser->normalize($prettyVersion);
  24904. }
  24905. $php = new CompletePackage('php', $version, $prettyVersion);
  24906. $php->setDescription('The PHP interpreter');
  24907. $this->addPackage($php);
  24908. if ($this->runtime->getConstant('PHP_DEBUG')) {
  24909. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  24910. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  24911. $this->addPackage($phpdebug);
  24912. }
  24913. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  24914. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  24915. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  24916. $this->addPackage($phpzts);
  24917. }
  24918. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  24919. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  24920. $php64->setDescription('The PHP interpreter, 64bit');
  24921. $this->addPackage($php64);
  24922. }
  24923. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  24924. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  24925. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  24926. $this->addPackage($phpIpv6);
  24927. }
  24928. $loadedExtensions = $this->runtime->getExtensions();
  24929. foreach ($loadedExtensions as $name) {
  24930. if (in_array($name, array('standard', 'Core'))) {
  24931. continue;
  24932. }
  24933. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  24934. }
  24935. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  24936. $this->addExtension('xdebug', $prettyVersion);
  24937. }
  24938. foreach ($loadedExtensions as $name) {
  24939. switch ($name) {
  24940. case 'amqp':
  24941. $info = $this->runtime->getExtensionInfo($name);
  24942. if (preg_match('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  24943. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  24944. }
  24945. if (preg_match('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  24946. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  24947. }
  24948. break;
  24949. case 'bz2':
  24950. $info = $this->runtime->getExtensionInfo($name);
  24951. if (preg_match('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  24952. $this->addLibrary($name, $matches['version']);
  24953. }
  24954. break;
  24955. case 'curl':
  24956. $curlVersion = $this->runtime->invoke('curl_version');
  24957. $this->addLibrary($name, $curlVersion['version']);
  24958. $info = $this->runtime->getExtensionInfo($name);
  24959. if (preg_match('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  24960. $library = strtolower($sslMatches['library']);
  24961. if ($library === 'openssl') {
  24962. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  24963. $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl') : array());
  24964. } else {
  24965. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  24966. }
  24967. }
  24968. if (preg_match('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  24969. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  24970. }
  24971. if (preg_match('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  24972. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  24973. }
  24974. break;
  24975. case 'date':
  24976. $info = $this->runtime->getExtensionInfo($name);
  24977. if (preg_match('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  24978. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  24979. }
  24980. if (preg_match('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  24981. $external = $zoneinfoSourceMatches['source'] === 'external';
  24982. if (preg_match('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  24983. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  24984. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  24985. } else {
  24986. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  24987. }
  24988. }
  24989. }
  24990. break;
  24991. case 'fileinfo':
  24992. $info = $this->runtime->getExtensionInfo($name);
  24993. if (preg_match('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  24994. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  24995. }
  24996. break;
  24997. case 'gd':
  24998. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  24999. $info = $this->runtime->getExtensionInfo($name);
  25000. if (preg_match('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  25001. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  25002. }
  25003. if (preg_match('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  25004. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  25005. }
  25006. if (preg_match('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  25007. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  25008. }
  25009. if (preg_match('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  25010. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId($libxpmMatches['versionId']), 'libxpm version for gd');
  25011. }
  25012. break;
  25013. case 'gmp':
  25014. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  25015. break;
  25016. case 'iconv':
  25017. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  25018. break;
  25019. case 'intl':
  25020. $info = $this->runtime->getExtensionInfo($name);
  25021. $description = 'The ICU unicode and globalization support library';
  25022. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  25023. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  25024. } elseif (preg_match('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  25025. $this->addLibrary('icu', $matches['version'], $description);
  25026. }
  25027. if (preg_match('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches)) {
  25028. $this->addLibrary('icu-zoneinfo', Version::parseZoneinfoVersion($zoneinfoMatches['version']), 'zoneinfo ("Olson") database for icu');
  25029. }
  25030. if ($this->runtime->hasClass('ResourceBundle')) {
  25031. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  25032. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  25033. }
  25034. if ($this->runtime->hasClass('IntlChar')) {
  25035. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  25036. }
  25037. break;
  25038. case 'imagick':
  25039. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  25040. preg_match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  25041. $version = $matches['version'];
  25042. if (isset($matches['patch'])) {
  25043. $version .= '.'.$matches['patch'];
  25044. }
  25045. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  25046. break;
  25047. case 'ldap':
  25048. $info = $this->runtime->getExtensionInfo($name);
  25049. if (preg_match('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && preg_match('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  25050. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId($matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  25051. }
  25052. break;
  25053. case 'libxml':
  25054. $libxmlProvides = array_map(function ($extension) {
  25055. return $extension . '-libxml';
  25056. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  25057. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  25058. break;
  25059. case 'mbstring':
  25060. $info = $this->runtime->getExtensionInfo($name);
  25061. if (preg_match('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  25062. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  25063. }
  25064. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  25065. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  25066. } elseif (preg_match('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  25067. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  25068. }
  25069. break;
  25070. case 'memcached':
  25071. $info = $this->runtime->getExtensionInfo($name);
  25072. if (preg_match('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  25073. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  25074. }
  25075. break;
  25076. case 'openssl':
  25077. if (preg_match('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  25078. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  25079. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  25080. }
  25081. break;
  25082. case 'pcre':
  25083. $this->addLibrary($name, preg_replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  25084. $info = $this->runtime->getExtensionInfo($name);
  25085. if (preg_match('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  25086. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  25087. }
  25088. break;
  25089. case 'mysqlnd':
  25090. case 'pdo_mysql':
  25091. $info = $this->runtime->getExtensionInfo($name);
  25092. if (preg_match('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  25093. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  25094. }
  25095. break;
  25096. case 'mongodb':
  25097. $info = $this->runtime->getExtensionInfo($name);
  25098. if (preg_match('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  25099. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  25100. }
  25101. if (preg_match('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  25102. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  25103. }
  25104. break;
  25105. case 'pgsql':
  25106. case 'pdo_pgsql':
  25107. $info = $this->runtime->getExtensionInfo($name);
  25108. if (preg_match('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  25109. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  25110. }
  25111. break;
  25112. case 'libsodium':
  25113. case 'sodium':
  25114. if ($this->runtime->hasConstant('SODIUM_LIBRARY_VERSION')) {
  25115. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  25116. }
  25117. break;
  25118. case 'sqlite3':
  25119. case 'pdo_sqlite':
  25120. $info = $this->runtime->getExtensionInfo($name);
  25121. if (preg_match('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  25122. $this->addLibrary($name.'-sqlite', $matches['version']);
  25123. }
  25124. break;
  25125. case 'ssh2':
  25126. $info = $this->runtime->getExtensionInfo($name);
  25127. if (preg_match('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  25128. $this->addLibrary($name.'-libssh2', $matches['version']);
  25129. }
  25130. break;
  25131. case 'xsl':
  25132. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  25133. $info = $this->runtime->getExtensionInfo('xsl');
  25134. if (preg_match('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  25135. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  25136. }
  25137. break;
  25138. case 'yaml':
  25139. $info = $this->runtime->getExtensionInfo('yaml');
  25140. if (preg_match('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  25141. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  25142. }
  25143. break;
  25144. case 'zip':
  25145. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  25146. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, array('zip'));
  25147. }
  25148. break;
  25149. case 'zlib':
  25150. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  25151. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  25152. } elseif (preg_match('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  25153. $this->addLibrary($name, $matches['version']);
  25154. }
  25155. break;
  25156. default:
  25157. break;
  25158. }
  25159. }
  25160. $hhvmVersion = $this->hhvmDetector->getVersion();
  25161. if ($hhvmVersion) {
  25162. try {
  25163. $prettyVersion = $hhvmVersion;
  25164. $version = $this->versionParser->normalize($prettyVersion);
  25165. } catch (\UnexpectedValueException $e) {
  25166. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  25167. $version = $this->versionParser->normalize($prettyVersion);
  25168. }
  25169. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  25170. $hhvm->setDescription('The HHVM Runtime (64bit)');
  25171. $this->addPackage($hhvm);
  25172. }
  25173. }
  25174. public function addPackage(PackageInterface $package)
  25175. {
  25176. if (isset($this->overrides[$package->getName()])) {
  25177. $overrider = $this->findPackage($package->getName(), '*');
  25178. if ($package->getVersion() === $overrider->getVersion()) {
  25179. $actualText = 'same as actual';
  25180. } else {
  25181. $actualText = 'actual: '.$package->getPrettyVersion();
  25182. }
  25183. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  25184. return;
  25185. }
  25186. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  25187. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  25188. if ($package->getVersion() === $overrider->getVersion()) {
  25189. $actualText = 'same as actual';
  25190. } else {
  25191. $actualText = 'actual: '.$package->getPrettyVersion();
  25192. }
  25193. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  25194. return;
  25195. }
  25196. parent::addPackage($package);
  25197. }
  25198. private function addOverriddenPackage(array $override, $name = null)
  25199. {
  25200. $version = $this->versionParser->normalize($override['version']);
  25201. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  25202. $package->setDescription('Package overridden via config.platform');
  25203. $package->setExtra(array('config.platform' => true));
  25204. parent::addPackage($package);
  25205. return $package;
  25206. }
  25207. private function addExtension($name, $prettyVersion)
  25208. {
  25209. $extraDescription = null;
  25210. try {
  25211. $version = $this->versionParser->normalize($prettyVersion);
  25212. } catch (\UnexpectedValueException $e) {
  25213. $extraDescription = ' (actual version: '.$prettyVersion.')';
  25214. if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  25215. $prettyVersion = $match[1];
  25216. } else {
  25217. $prettyVersion = '0';
  25218. }
  25219. $version = $this->versionParser->normalize($prettyVersion);
  25220. }
  25221. $packageName = $this->buildPackageName($name);
  25222. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  25223. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  25224. if ($name === 'uuid') {
  25225. $ext->setReplaces(array(
  25226. new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  25227. ));
  25228. }
  25229. $this->addPackage($ext);
  25230. }
  25231. private function buildPackageName($name)
  25232. {
  25233. return 'ext-' . str_replace(' ', '-', strtolower($name));
  25234. }
  25235. private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
  25236. {
  25237. try {
  25238. $version = $this->versionParser->normalize($prettyVersion);
  25239. } catch (\UnexpectedValueException $e) {
  25240. return;
  25241. }
  25242. if ($description === null) {
  25243. $description = 'The '.$name.' library';
  25244. }
  25245. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  25246. $lib->setDescription($description);
  25247. $links = function ($alias) use ($name, $version, $lib) {
  25248. return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  25249. };
  25250. $lib->setReplaces(array_map($links, $replaces));
  25251. $lib->setProvides(array_map($links, $provides));
  25252. $this->addPackage($lib);
  25253. }
  25254. public static function isPlatformPackage($name)
  25255. {
  25256. static $cache = array();
  25257. if (isset($cache[$name])) {
  25258. return $cache[$name];
  25259. }
  25260. return $cache[$name] = (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  25261. }
  25262. }
  25263. <?php
  25264. namespace Composer\Repository;
  25265. use Composer\Factory;
  25266. use Composer\IO\IOInterface;
  25267. use Composer\Config;
  25268. use Composer\EventDispatcher\EventDispatcher;
  25269. use Composer\Util\HttpDownloader;
  25270. use Composer\Util\ProcessExecutor;
  25271. use Composer\Json\JsonFile;
  25272. class RepositoryFactory
  25273. {
  25274. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  25275. {
  25276. if (0 === strpos($repository, 'http')) {
  25277. $repoConfig = array('type' => 'composer', 'url' => $repository);
  25278. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  25279. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  25280. $data = $json->read();
  25281. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  25282. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  25283. } elseif ($allowFilesystem) {
  25284. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  25285. } else {
  25286. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  25287. }
  25288. } elseif (strpos($repository, '{') === 0) {
  25289. $repoConfig = JsonFile::parseJson($repository);
  25290. } else {
  25291. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  25292. }
  25293. return $repoConfig;
  25294. }
  25295. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
  25296. {
  25297. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  25298. return static::createRepo($io, $config, $repoConfig, $rm);
  25299. }
  25300. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
  25301. {
  25302. if (!$rm) {
  25303. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25304. }
  25305. $repos = static::createRepos($rm, array($repoConfig));
  25306. return reset($repos);
  25307. }
  25308. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  25309. {
  25310. if (!$config) {
  25311. $config = Factory::createConfig($io);
  25312. }
  25313. if ($io) {
  25314. $io->loadConfiguration($config);
  25315. }
  25316. if (!$rm) {
  25317. if (!$io) {
  25318. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  25319. }
  25320. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25321. }
  25322. return static::createRepos($rm, $config->getRepositories());
  25323. }
  25324. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25325. {
  25326. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  25327. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  25328. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  25329. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  25330. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  25331. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  25332. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  25333. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  25334. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  25335. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  25336. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  25337. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  25338. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  25339. $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
  25340. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  25341. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  25342. return $rm;
  25343. }
  25344. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  25345. {
  25346. $repos = array();
  25347. foreach ($repoConfigs as $index => $repo) {
  25348. if (is_string($repo)) {
  25349. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  25350. }
  25351. if (!is_array($repo)) {
  25352. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  25353. }
  25354. if (!isset($repo['type'])) {
  25355. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  25356. }
  25357. $name = self::generateRepositoryName($index, $repo, $repos);
  25358. if ($repo['type'] === 'filesystem') {
  25359. $repos[$name] = new FilesystemRepository($repo['json']);
  25360. } else {
  25361. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  25362. }
  25363. }
  25364. return $repos;
  25365. }
  25366. public static function generateRepositoryName($index, array $repo, array $existingRepos)
  25367. {
  25368. $name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
  25369. while (isset($existingRepos[$name])) {
  25370. $name .= '2';
  25371. }
  25372. return $name;
  25373. }
  25374. }
  25375. <?php
  25376. namespace Composer\Repository;
  25377. use Composer\Package\PackageInterface;
  25378. use Composer\Package\BasePackage;
  25379. use Composer\Semver\Constraint\ConstraintInterface;
  25380. interface RepositoryInterface extends \Countable
  25381. {
  25382. const SEARCH_FULLTEXT = 0;
  25383. const SEARCH_NAME = 1;
  25384. public function hasPackage(PackageInterface $package);
  25385. public function findPackage($name, $constraint);
  25386. public function findPackages($name, $constraint = null);
  25387. public function getPackages();
  25388. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  25389. public function search($query, $mode = 0, $type = null);
  25390. public function getProviders($packageName);
  25391. public function getRepoName();
  25392. }
  25393. <?php
  25394. namespace Composer\Repository;
  25395. use Composer\IO\IOInterface;
  25396. use Composer\Config;
  25397. use Composer\EventDispatcher\EventDispatcher;
  25398. use Composer\Package\PackageInterface;
  25399. use Composer\Util\HttpDownloader;
  25400. use Composer\Util\ProcessExecutor;
  25401. class RepositoryManager
  25402. {
  25403. private $localRepository;
  25404. private $repositories = array();
  25405. private $repositoryClasses = array();
  25406. private $io;
  25407. private $config;
  25408. private $httpDownloader;
  25409. private $eventDispatcher;
  25410. private $process;
  25411. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25412. {
  25413. $this->io = $io;
  25414. $this->config = $config;
  25415. $this->httpDownloader = $httpDownloader;
  25416. $this->eventDispatcher = $eventDispatcher;
  25417. $this->process = $process ?: new ProcessExecutor($io);
  25418. }
  25419. public function findPackage($name, $constraint)
  25420. {
  25421. foreach ($this->repositories as $repository) {
  25422. if ($package = $repository->findPackage($name, $constraint)) {
  25423. return $package;
  25424. }
  25425. }
  25426. return null;
  25427. }
  25428. public function findPackages($name, $constraint)
  25429. {
  25430. $packages = array();
  25431. foreach ($this->getRepositories() as $repository) {
  25432. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  25433. }
  25434. return $packages;
  25435. }
  25436. public function addRepository(RepositoryInterface $repository)
  25437. {
  25438. $this->repositories[] = $repository;
  25439. }
  25440. public function prependRepository(RepositoryInterface $repository)
  25441. {
  25442. array_unshift($this->repositories, $repository);
  25443. }
  25444. public function createRepository($type, $config, $name = null)
  25445. {
  25446. if (!isset($this->repositoryClasses[$type])) {
  25447. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  25448. }
  25449. if (isset($config['packagist']) && false === $config['packagist']) {
  25450. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  25451. }
  25452. $class = $this->repositoryClasses[$type];
  25453. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  25454. $filterConfig = $config;
  25455. unset($config['only'], $config['exclude'], $config['canonical']);
  25456. }
  25457. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  25458. if (isset($filterConfig)) {
  25459. $repository = new FilterRepository($repository, $filterConfig);
  25460. }
  25461. return $repository;
  25462. }
  25463. public function setRepositoryClass($type, $class)
  25464. {
  25465. $this->repositoryClasses[$type] = $class;
  25466. }
  25467. public function getRepositories()
  25468. {
  25469. return $this->repositories;
  25470. }
  25471. public function setLocalRepository(InstalledRepositoryInterface $repository)
  25472. {
  25473. $this->localRepository = $repository;
  25474. }
  25475. public function getLocalRepository()
  25476. {
  25477. return $this->localRepository;
  25478. }
  25479. }
  25480. <?php
  25481. namespace Composer\Repository;
  25482. class RepositorySecurityException extends \Exception
  25483. {
  25484. }
  25485. <?php
  25486. namespace Composer\Repository;
  25487. use Composer\DependencyResolver\Pool;
  25488. use Composer\DependencyResolver\PoolBuilder;
  25489. use Composer\DependencyResolver\Request;
  25490. use Composer\EventDispatcher\EventDispatcher;
  25491. use Composer\IO\IOInterface;
  25492. use Composer\IO\NullIO;
  25493. use Composer\Package\BasePackage;
  25494. use Composer\Package\AliasPackage;
  25495. use Composer\Semver\Constraint\ConstraintInterface;
  25496. use Composer\Package\Version\StabilityFilter;
  25497. class RepositorySet
  25498. {
  25499. const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  25500. const ALLOW_SHADOWED_REPOSITORIES = 2;
  25501. private $rootAliases;
  25502. private $rootReferences;
  25503. private $repositories = array();
  25504. private $acceptableStabilities;
  25505. private $stabilityFlags;
  25506. private $rootRequires;
  25507. private $locked = false;
  25508. private $allowInstalledRepositories = false;
  25509. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  25510. {
  25511. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  25512. $this->rootReferences = $rootReferences;
  25513. $this->acceptableStabilities = array();
  25514. foreach (BasePackage::$stabilities as $stability => $value) {
  25515. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  25516. $this->acceptableStabilities[$stability] = $value;
  25517. }
  25518. }
  25519. $this->stabilityFlags = $stabilityFlags;
  25520. $this->rootRequires = $rootRequires;
  25521. foreach ($rootRequires as $name => $constraint) {
  25522. if (PlatformRepository::isPlatformPackage($name)) {
  25523. unset($this->rootRequires[$name]);
  25524. }
  25525. }
  25526. }
  25527. public function allowInstalledRepositories($allow = true)
  25528. {
  25529. $this->allowInstalledRepositories = $allow;
  25530. }
  25531. public function getRootRequires()
  25532. {
  25533. return $this->rootRequires;
  25534. }
  25535. public function addRepository(RepositoryInterface $repo)
  25536. {
  25537. if ($this->locked) {
  25538. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  25539. }
  25540. if ($repo instanceof CompositeRepository) {
  25541. $repos = $repo->getRepositories();
  25542. } else {
  25543. $repos = array($repo);
  25544. }
  25545. foreach ($repos as $repo) {
  25546. $this->repositories[] = $repo;
  25547. }
  25548. }
  25549. public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
  25550. {
  25551. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  25552. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  25553. $packages = array();
  25554. if ($loadFromAllRepos) {
  25555. foreach ($this->repositories as $repository) {
  25556. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  25557. }
  25558. } else {
  25559. foreach ($this->repositories as $repository) {
  25560. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  25561. $packages[] = $result['packages'];
  25562. foreach ($result['namesFound'] as $nameFound) {
  25563. if ($name === $nameFound) {
  25564. break 2;
  25565. }
  25566. }
  25567. }
  25568. }
  25569. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  25570. if ($ignoreStability || !$loadFromAllRepos) {
  25571. return $candidates;
  25572. }
  25573. $result = array();
  25574. foreach ($candidates as $candidate) {
  25575. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  25576. $result[] = $candidate;
  25577. }
  25578. }
  25579. return $result;
  25580. }
  25581. public function getProviders($packageName)
  25582. {
  25583. $providers = array();
  25584. foreach ($this->repositories as $repository) {
  25585. if ($repoProviders = $repository->getProviders($packageName)) {
  25586. $providers = array_merge($providers, $repoProviders);
  25587. }
  25588. }
  25589. return $providers;
  25590. }
  25591. public function isPackageAcceptable($names, $stability)
  25592. {
  25593. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  25594. }
  25595. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null)
  25596. {
  25597. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher);
  25598. foreach ($this->repositories as $repo) {
  25599. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25600. throw new \LogicException('The pool can not accept packages from an installed repository');
  25601. }
  25602. }
  25603. $this->locked = true;
  25604. return $poolBuilder->buildPool($this->repositories, $request);
  25605. }
  25606. public function createPoolWithAllPackages()
  25607. {
  25608. foreach ($this->repositories as $repo) {
  25609. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25610. throw new \LogicException('The pool can not accept packages from an installed repository');
  25611. }
  25612. }
  25613. $this->locked = true;
  25614. $packages = array();
  25615. foreach ($this->repositories as $repository) {
  25616. foreach ($repository->getPackages() as $package) {
  25617. $packages[] = $package;
  25618. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  25619. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  25620. while ($package instanceof AliasPackage) {
  25621. $package = $package->getAliasOf();
  25622. }
  25623. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  25624. $aliasPackage->setRootPackageAlias(true);
  25625. $packages[] = $aliasPackage;
  25626. }
  25627. }
  25628. }
  25629. return new Pool($packages);
  25630. }
  25631. public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
  25632. {
  25633. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  25634. }
  25635. public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
  25636. {
  25637. $request = new Request($lockedRepo);
  25638. foreach ($packageNames as $packageName) {
  25639. if (PlatformRepository::isPlatformPackage($packageName)) {
  25640. 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.');
  25641. }
  25642. $request->requireName($packageName);
  25643. }
  25644. return $this->createPool($request, new NullIO());
  25645. }
  25646. private static function getRootAliasesPerPackage(array $aliases)
  25647. {
  25648. $normalizedAliases = array();
  25649. foreach ($aliases as $alias) {
  25650. $normalizedAliases[$alias['package']][$alias['version']] = array(
  25651. 'alias' => $alias['alias'],
  25652. 'alias_normalized' => $alias['alias_normalized'],
  25653. );
  25654. }
  25655. return $normalizedAliases;
  25656. }
  25657. }
  25658. <?php
  25659. namespace Composer\Repository;
  25660. use Composer\Package\RootPackageInterface;
  25661. class RootPackageRepository extends ArrayRepository
  25662. {
  25663. public function __construct(RootPackageInterface $package)
  25664. {
  25665. parent::__construct(array($package));
  25666. }
  25667. public function getRepoName()
  25668. {
  25669. return 'root package repo';
  25670. }
  25671. }
  25672. <?php
  25673. namespace Composer\Repository\Vcs;
  25674. use Composer\Cache;
  25675. use Composer\Downloader\TransportException;
  25676. use Composer\Json\JsonFile;
  25677. use Composer\Util\Bitbucket;
  25678. use Composer\Util\Http\Response;
  25679. abstract class BitbucketDriver extends VcsDriver
  25680. {
  25681. protected $owner;
  25682. protected $repository;
  25683. protected $hasIssues;
  25684. protected $rootIdentifier;
  25685. protected $tags;
  25686. protected $branches;
  25687. protected $branchesUrl = '';
  25688. protected $tagsUrl = '';
  25689. protected $homeUrl = '';
  25690. protected $website = '';
  25691. protected $cloneHttpsUrl = '';
  25692. protected $fallbackDriver;
  25693. protected $vcsType;
  25694. public function initialize()
  25695. {
  25696. preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)$#i', $this->url, $match);
  25697. $this->owner = $match[1];
  25698. $this->repository = $match[2];
  25699. $this->originUrl = 'bitbucket.org';
  25700. $this->cache = new Cache(
  25701. $this->io,
  25702. implode('/', array(
  25703. $this->config->get('cache-repo-dir'),
  25704. $this->originUrl,
  25705. $this->owner,
  25706. $this->repository,
  25707. ))
  25708. );
  25709. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25710. }
  25711. public function getUrl()
  25712. {
  25713. if ($this->fallbackDriver) {
  25714. return $this->fallbackDriver->getUrl();
  25715. }
  25716. return $this->cloneHttpsUrl;
  25717. }
  25718. protected function getRepoData()
  25719. {
  25720. $resource = sprintf(
  25721. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  25722. $this->owner,
  25723. $this->repository,
  25724. http_build_query(
  25725. array('fields' => '-project,-owner'),
  25726. null,
  25727. '&'
  25728. )
  25729. );
  25730. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  25731. if ($this->fallbackDriver) {
  25732. return false;
  25733. }
  25734. $this->parseCloneUrls($repoData['links']['clone']);
  25735. $this->hasIssues = !empty($repoData['has_issues']);
  25736. $this->branchesUrl = $repoData['links']['branches']['href'];
  25737. $this->tagsUrl = $repoData['links']['tags']['href'];
  25738. $this->homeUrl = $repoData['links']['html']['href'];
  25739. $this->website = $repoData['website'];
  25740. $this->vcsType = $repoData['scm'];
  25741. return true;
  25742. }
  25743. public function getComposerInformation($identifier)
  25744. {
  25745. if ($this->fallbackDriver) {
  25746. return $this->fallbackDriver->getComposerInformation($identifier);
  25747. }
  25748. if (!isset($this->infoCache[$identifier])) {
  25749. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  25750. $composer = JsonFile::parseJson($res);
  25751. } else {
  25752. $composer = $this->getBaseComposerInformation($identifier);
  25753. if ($this->shouldCache($identifier)) {
  25754. $this->cache->write($identifier, json_encode($composer));
  25755. }
  25756. }
  25757. if ($composer) {
  25758. if (!isset($composer['support']['source'])) {
  25759. $label = array_search(
  25760. $identifier,
  25761. $this->getTags()
  25762. ) ?: array_search(
  25763. $identifier,
  25764. $this->getBranches()
  25765. ) ?: $identifier;
  25766. if (array_key_exists($label, $tags = $this->getTags())) {
  25767. $hash = $tags[$label];
  25768. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  25769. $hash = $branches[$label];
  25770. }
  25771. if (!isset($hash)) {
  25772. $composer['support']['source'] = sprintf(
  25773. 'https://%s/%s/%s/src',
  25774. $this->originUrl,
  25775. $this->owner,
  25776. $this->repository
  25777. );
  25778. } else {
  25779. $composer['support']['source'] = sprintf(
  25780. 'https://%s/%s/%s/src/%s/?at=%s',
  25781. $this->originUrl,
  25782. $this->owner,
  25783. $this->repository,
  25784. $hash,
  25785. $label
  25786. );
  25787. }
  25788. }
  25789. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  25790. $composer['support']['issues'] = sprintf(
  25791. 'https://%s/%s/%s/issues',
  25792. $this->originUrl,
  25793. $this->owner,
  25794. $this->repository
  25795. );
  25796. }
  25797. if (!isset($composer['homepage'])) {
  25798. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  25799. }
  25800. }
  25801. $this->infoCache[$identifier] = $composer;
  25802. }
  25803. return $this->infoCache[$identifier];
  25804. }
  25805. public function getFileContent($file, $identifier)
  25806. {
  25807. if ($this->fallbackDriver) {
  25808. return $this->fallbackDriver->getFileContent($file, $identifier);
  25809. }
  25810. if (strpos($identifier, '/') !== false) {
  25811. $branches = $this->getBranches();
  25812. if (isset($branches[$identifier])) {
  25813. $identifier = $branches[$identifier];
  25814. }
  25815. }
  25816. $resource = sprintf(
  25817. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  25818. $this->owner,
  25819. $this->repository,
  25820. $identifier,
  25821. $file
  25822. );
  25823. return $this->fetchWithOAuthCredentials($resource)->getBody();
  25824. }
  25825. public function getChangeDate($identifier)
  25826. {
  25827. if ($this->fallbackDriver) {
  25828. return $this->fallbackDriver->getChangeDate($identifier);
  25829. }
  25830. if (strpos($identifier, '/') !== false) {
  25831. $branches = $this->getBranches();
  25832. if (isset($branches[$identifier])) {
  25833. $identifier = $branches[$identifier];
  25834. }
  25835. }
  25836. $resource = sprintf(
  25837. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  25838. $this->owner,
  25839. $this->repository,
  25840. $identifier
  25841. );
  25842. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25843. return new \DateTime($commit['date']);
  25844. }
  25845. public function getSource($identifier)
  25846. {
  25847. if ($this->fallbackDriver) {
  25848. return $this->fallbackDriver->getSource($identifier);
  25849. }
  25850. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  25851. }
  25852. public function getDist($identifier)
  25853. {
  25854. if ($this->fallbackDriver) {
  25855. return $this->fallbackDriver->getDist($identifier);
  25856. }
  25857. $url = sprintf(
  25858. 'https://bitbucket.org/%s/%s/get/%s.zip',
  25859. $this->owner,
  25860. $this->repository,
  25861. $identifier
  25862. );
  25863. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  25864. }
  25865. public function getTags()
  25866. {
  25867. if ($this->fallbackDriver) {
  25868. return $this->fallbackDriver->getTags();
  25869. }
  25870. if (null === $this->tags) {
  25871. $this->tags = array();
  25872. $resource = sprintf(
  25873. '%s?%s',
  25874. $this->tagsUrl,
  25875. http_build_query(
  25876. array(
  25877. 'pagelen' => 100,
  25878. 'fields' => 'values.name,values.target.hash,next',
  25879. 'sort' => '-target.date',
  25880. ),
  25881. null,
  25882. '&'
  25883. )
  25884. );
  25885. $hasNext = true;
  25886. while ($hasNext) {
  25887. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25888. foreach ($tagsData['values'] as $data) {
  25889. $this->tags[$data['name']] = $data['target']['hash'];
  25890. }
  25891. if (empty($tagsData['next'])) {
  25892. $hasNext = false;
  25893. } else {
  25894. $resource = $tagsData['next'];
  25895. }
  25896. }
  25897. if ($this->vcsType === 'hg') {
  25898. unset($this->tags['tip']);
  25899. }
  25900. }
  25901. return $this->tags;
  25902. }
  25903. public function getBranches()
  25904. {
  25905. if ($this->fallbackDriver) {
  25906. return $this->fallbackDriver->getBranches();
  25907. }
  25908. if (null === $this->branches) {
  25909. $this->branches = array();
  25910. $resource = sprintf(
  25911. '%s?%s',
  25912. $this->branchesUrl,
  25913. http_build_query(
  25914. array(
  25915. 'pagelen' => 100,
  25916. 'fields' => 'values.name,values.target.hash,values.heads,next',
  25917. 'sort' => '-target.date',
  25918. ),
  25919. null,
  25920. '&'
  25921. )
  25922. );
  25923. $hasNext = true;
  25924. while ($hasNext) {
  25925. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25926. foreach ($branchData['values'] as $data) {
  25927. if ($this->vcsType === 'hg' && empty($data['heads'])) {
  25928. continue;
  25929. }
  25930. $this->branches[$data['name']] = $data['target']['hash'];
  25931. }
  25932. if (empty($branchData['next'])) {
  25933. $hasNext = false;
  25934. } else {
  25935. $resource = $branchData['next'];
  25936. }
  25937. }
  25938. }
  25939. return $this->branches;
  25940. }
  25941. protected function fetchWithOAuthCredentials($url, $fetchingRepoData = false)
  25942. {
  25943. try {
  25944. return parent::getContents($url);
  25945. } catch (TransportException $e) {
  25946. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  25947. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  25948. if (!$this->io->hasAuthentication($this->originUrl)
  25949. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  25950. ) {
  25951. return parent::getContents($url);
  25952. }
  25953. if (!$this->io->isInteractive() && $fetchingRepoData) {
  25954. if ($this->attemptCloneFallback()) {
  25955. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  25956. }
  25957. }
  25958. }
  25959. throw $e;
  25960. }
  25961. }
  25962. abstract protected function generateSshUrl();
  25963. protected function attemptCloneFallback()
  25964. {
  25965. try {
  25966. $this->setupFallbackDriver($this->generateSshUrl());
  25967. return true;
  25968. } catch (\RuntimeException $e) {
  25969. $this->fallbackDriver = null;
  25970. $this->io->writeError(
  25971. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  25972. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  25973. );
  25974. throw $e;
  25975. }
  25976. }
  25977. abstract protected function setupFallbackDriver($url);
  25978. protected function parseCloneUrls(array $cloneLinks)
  25979. {
  25980. foreach ($cloneLinks as $cloneLink) {
  25981. if ($cloneLink['name'] === 'https') {
  25982. $this->cloneHttpsUrl = preg_replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  25983. }
  25984. }
  25985. }
  25986. protected function getMainBranchData()
  25987. {
  25988. $resource = sprintf(
  25989. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  25990. $this->owner,
  25991. $this->repository
  25992. );
  25993. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25994. if (isset($data['mainbranch'])) {
  25995. return $data['mainbranch'];
  25996. }
  25997. return null;
  25998. }
  25999. }
  26000. <?php
  26001. namespace Composer\Repository\Vcs;
  26002. use Composer\Cache;
  26003. use Composer\Config;
  26004. use Composer\Util\ProcessExecutor;
  26005. use Composer\Util\Filesystem;
  26006. use Composer\IO\IOInterface;
  26007. class FossilDriver extends VcsDriver
  26008. {
  26009. protected $tags;
  26010. protected $branches;
  26011. protected $rootIdentifier;
  26012. protected $repoFile;
  26013. protected $checkoutDir;
  26014. public function initialize()
  26015. {
  26016. $this->checkFossil();
  26017. $this->config->prohibitUrlByConfig($this->url, $this->io);
  26018. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  26019. $this->checkoutDir = $this->url;
  26020. } else {
  26021. if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26022. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26023. }
  26024. $localName = preg_replace('{[^a-z0-9]}i', '-', $this->url);
  26025. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  26026. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  26027. $this->updateLocalRepo();
  26028. }
  26029. $this->getTags();
  26030. $this->getBranches();
  26031. }
  26032. protected function checkFossil()
  26033. {
  26034. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  26035. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  26036. }
  26037. }
  26038. protected function updateLocalRepo()
  26039. {
  26040. $fs = new Filesystem();
  26041. $fs->ensureDirectoryExists($this->checkoutDir);
  26042. if (!is_writable(dirname($this->checkoutDir))) {
  26043. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  26044. }
  26045. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  26046. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  26047. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  26048. }
  26049. } else {
  26050. $fs->removeDirectory($this->checkoutDir);
  26051. $fs->remove($this->repoFile);
  26052. $fs->ensureDirectoryExists($this->checkoutDir);
  26053. if (0 !== $this->process->execute(sprintf('fossil clone -- %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  26054. $output = $this->process->getErrorOutput();
  26055. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  26056. }
  26057. if (0 !== $this->process->execute(sprintf('fossil open --nested -- %s', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  26058. $output = $this->process->getErrorOutput();
  26059. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  26060. }
  26061. }
  26062. }
  26063. public function getRootIdentifier()
  26064. {
  26065. if (null === $this->rootIdentifier) {
  26066. $this->rootIdentifier = 'trunk';
  26067. }
  26068. return $this->rootIdentifier;
  26069. }
  26070. public function getUrl()
  26071. {
  26072. return $this->url;
  26073. }
  26074. public function getSource($identifier)
  26075. {
  26076. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  26077. }
  26078. public function getDist($identifier)
  26079. {
  26080. return null;
  26081. }
  26082. public function getFileContent($file, $identifier)
  26083. {
  26084. $command = sprintf('fossil cat -r %s -- %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26085. $this->process->execute($command, $content, $this->checkoutDir);
  26086. if (!trim($content)) {
  26087. return null;
  26088. }
  26089. return $content;
  26090. }
  26091. public function getChangeDate($identifier)
  26092. {
  26093. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  26094. list(, $date) = explode(' ', trim($output), 3);
  26095. return new \DateTime($date, new \DateTimeZone('UTC'));
  26096. }
  26097. public function getTags()
  26098. {
  26099. if (null === $this->tags) {
  26100. $tags = array();
  26101. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  26102. foreach ($this->process->splitLines($output) as $tag) {
  26103. $tags[$tag] = $tag;
  26104. }
  26105. $this->tags = $tags;
  26106. }
  26107. return $this->tags;
  26108. }
  26109. public function getBranches()
  26110. {
  26111. if (null === $this->branches) {
  26112. $branches = array();
  26113. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  26114. foreach ($this->process->splitLines($output) as $branch) {
  26115. $branch = trim(preg_replace('/^\*/', '', trim($branch)));
  26116. $branches[$branch] = $branch;
  26117. }
  26118. $this->branches = $branches;
  26119. }
  26120. return $this->branches;
  26121. }
  26122. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26123. {
  26124. if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  26125. return true;
  26126. }
  26127. if (preg_match('!/fossil/|\.fossil!', $url)) {
  26128. return true;
  26129. }
  26130. if (Filesystem::isLocalPath($url)) {
  26131. $url = Filesystem::getPlatformPath($url);
  26132. if (!is_dir($url)) {
  26133. return false;
  26134. }
  26135. $process = new ProcessExecutor($io);
  26136. if ($process->execute('fossil info', $output, $url) === 0) {
  26137. return true;
  26138. }
  26139. }
  26140. return false;
  26141. }
  26142. }
  26143. <?php
  26144. namespace Composer\Repository\Vcs;
  26145. use Composer\Config;
  26146. use Composer\IO\IOInterface;
  26147. class GitBitbucketDriver extends BitbucketDriver
  26148. {
  26149. public function getRootIdentifier()
  26150. {
  26151. if ($this->fallbackDriver) {
  26152. return $this->fallbackDriver->getRootIdentifier();
  26153. }
  26154. if (null === $this->rootIdentifier) {
  26155. if (!$this->getRepoData()) {
  26156. return $this->fallbackDriver->getRootIdentifier();
  26157. }
  26158. if ($this->vcsType !== 'git') {
  26159. throw new \RuntimeException(
  26160. $this->url.' does not appear to be a git repository, use '.
  26161. $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository'
  26162. );
  26163. }
  26164. $mainBranchData = $this->getMainBranchData();
  26165. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  26166. }
  26167. return $this->rootIdentifier;
  26168. }
  26169. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26170. {
  26171. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/(.+?)\.git$#i', $url)) {
  26172. return false;
  26173. }
  26174. if (!extension_loaded('openssl')) {
  26175. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26176. return false;
  26177. }
  26178. return true;
  26179. }
  26180. protected function setupFallbackDriver($url)
  26181. {
  26182. $this->fallbackDriver = new GitDriver(
  26183. array('url' => $url),
  26184. $this->io,
  26185. $this->config,
  26186. $this->httpDownloader,
  26187. $this->process
  26188. );
  26189. $this->fallbackDriver->initialize();
  26190. }
  26191. protected function generateSshUrl()
  26192. {
  26193. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  26194. }
  26195. }
  26196. <?php
  26197. namespace Composer\Repository\Vcs;
  26198. use Composer\Util\ProcessExecutor;
  26199. use Composer\Util\Filesystem;
  26200. use Composer\Util\Url;
  26201. use Composer\Util\Git as GitUtil;
  26202. use Composer\IO\IOInterface;
  26203. use Composer\Cache;
  26204. use Composer\Config;
  26205. class GitDriver extends VcsDriver
  26206. {
  26207. protected $tags;
  26208. protected $branches;
  26209. protected $rootIdentifier;
  26210. protected $repoDir;
  26211. public function initialize()
  26212. {
  26213. if (Filesystem::isLocalPath($this->url)) {
  26214. $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url);
  26215. if (!is_dir($this->url)) {
  26216. throw new \RuntimeException('Failed to read package information from '.$this->url.' as the path does not exist');
  26217. }
  26218. $this->repoDir = $this->url;
  26219. $cacheUrl = realpath($this->url);
  26220. } else {
  26221. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26222. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26223. }
  26224. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  26225. GitUtil::cleanEnv();
  26226. $fs = new Filesystem();
  26227. $fs->ensureDirectoryExists(dirname($this->repoDir));
  26228. if (!is_writable(dirname($this->repoDir))) {
  26229. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  26230. }
  26231. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  26232. 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.');
  26233. }
  26234. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  26235. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  26236. if (!is_dir($this->repoDir)) {
  26237. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  26238. }
  26239. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  26240. }
  26241. $cacheUrl = $this->url;
  26242. }
  26243. $this->getTags();
  26244. $this->getBranches();
  26245. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  26246. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26247. }
  26248. public function getRootIdentifier()
  26249. {
  26250. if (null === $this->rootIdentifier) {
  26251. $this->rootIdentifier = 'master';
  26252. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  26253. $branches = $this->process->splitLines($output);
  26254. if (!in_array('* master', $branches)) {
  26255. foreach ($branches as $branch) {
  26256. if ($branch && preg_match('{^\* +(\S+)}', $branch, $match)) {
  26257. $this->rootIdentifier = $match[1];
  26258. break;
  26259. }
  26260. }
  26261. }
  26262. }
  26263. return $this->rootIdentifier;
  26264. }
  26265. public function getUrl()
  26266. {
  26267. return $this->url;
  26268. }
  26269. public function getSource($identifier)
  26270. {
  26271. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  26272. }
  26273. public function getDist($identifier)
  26274. {
  26275. return null;
  26276. }
  26277. public function getFileContent($file, $identifier)
  26278. {
  26279. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26280. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  26281. if (!trim($content)) {
  26282. return null;
  26283. }
  26284. return $content;
  26285. }
  26286. public function getChangeDate($identifier)
  26287. {
  26288. $this->process->execute(sprintf(
  26289. 'git -c log.showSignature=false log -1 --format=%%at %s',
  26290. ProcessExecutor::escape($identifier)
  26291. ), $output, $this->repoDir);
  26292. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  26293. }
  26294. public function getTags()
  26295. {
  26296. if (null === $this->tags) {
  26297. $this->tags = array();
  26298. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  26299. foreach ($output = $this->process->splitLines($output) as $tag) {
  26300. if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  26301. $this->tags[$match[2]] = $match[1];
  26302. }
  26303. }
  26304. }
  26305. return $this->tags;
  26306. }
  26307. public function getBranches()
  26308. {
  26309. if (null === $this->branches) {
  26310. $branches = array();
  26311. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  26312. foreach ($this->process->splitLines($output) as $branch) {
  26313. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  26314. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  26315. $branches[$match[1]] = $match[2];
  26316. }
  26317. }
  26318. }
  26319. $this->branches = $branches;
  26320. }
  26321. return $this->branches;
  26322. }
  26323. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26324. {
  26325. if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  26326. return true;
  26327. }
  26328. if (Filesystem::isLocalPath($url)) {
  26329. $url = Filesystem::getPlatformPath($url);
  26330. if (!is_dir($url)) {
  26331. return false;
  26332. }
  26333. $process = new ProcessExecutor($io);
  26334. if ($process->execute('git tag', $output, $url) === 0) {
  26335. return true;
  26336. }
  26337. }
  26338. if (!$deep) {
  26339. return false;
  26340. }
  26341. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  26342. GitUtil::cleanEnv();
  26343. try {
  26344. $gitUtil->runCommand(function ($url) {
  26345. return 'git ls-remote --heads -- ' . ProcessExecutor::escape($url);
  26346. }, $url, sys_get_temp_dir());
  26347. } catch (\RuntimeException $e) {
  26348. return false;
  26349. }
  26350. return true;
  26351. }
  26352. }
  26353. <?php
  26354. namespace Composer\Repository\Vcs;
  26355. use Composer\Config;
  26356. use Composer\Downloader\TransportException;
  26357. use Composer\Json\JsonFile;
  26358. use Composer\Cache;
  26359. use Composer\IO\IOInterface;
  26360. use Composer\Util\GitHub;
  26361. use Composer\Util\Http\Response;
  26362. class GitHubDriver extends VcsDriver
  26363. {
  26364. protected $owner;
  26365. protected $repository;
  26366. protected $tags;
  26367. protected $branches;
  26368. protected $rootIdentifier;
  26369. protected $repoData;
  26370. protected $hasIssues;
  26371. protected $isPrivate = false;
  26372. private $isArchived = false;
  26373. private $fundingInfo;
  26374. protected $gitDriver;
  26375. public function initialize()
  26376. {
  26377. preg_match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  26378. $this->owner = $match[3];
  26379. $this->repository = $match[4];
  26380. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  26381. if ($this->originUrl === 'www.github.com') {
  26382. $this->originUrl = 'github.com';
  26383. }
  26384. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  26385. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26386. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  26387. $this->setupGitDriver($this->url);
  26388. return;
  26389. }
  26390. $this->fetchRootIdentifier();
  26391. }
  26392. public function getRepositoryUrl()
  26393. {
  26394. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  26395. }
  26396. public function getRootIdentifier()
  26397. {
  26398. if ($this->gitDriver) {
  26399. return $this->gitDriver->getRootIdentifier();
  26400. }
  26401. return $this->rootIdentifier;
  26402. }
  26403. public function getUrl()
  26404. {
  26405. if ($this->gitDriver) {
  26406. return $this->gitDriver->getUrl();
  26407. }
  26408. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26409. }
  26410. protected function getApiUrl()
  26411. {
  26412. if ('github.com' === $this->originUrl) {
  26413. $apiUrl = 'api.github.com';
  26414. } else {
  26415. $apiUrl = $this->originUrl . '/api/v3';
  26416. }
  26417. return 'https://' . $apiUrl;
  26418. }
  26419. public function getSource($identifier)
  26420. {
  26421. if ($this->gitDriver) {
  26422. return $this->gitDriver->getSource($identifier);
  26423. }
  26424. if ($this->isPrivate) {
  26425. $url = $this->generateSshUrl();
  26426. } else {
  26427. $url = $this->getUrl();
  26428. }
  26429. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  26430. }
  26431. public function getDist($identifier)
  26432. {
  26433. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  26434. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26435. }
  26436. public function getComposerInformation($identifier)
  26437. {
  26438. if ($this->gitDriver) {
  26439. return $this->gitDriver->getComposerInformation($identifier);
  26440. }
  26441. if (!isset($this->infoCache[$identifier])) {
  26442. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26443. $composer = JsonFile::parseJson($res);
  26444. } else {
  26445. $composer = $this->getBaseComposerInformation($identifier);
  26446. if ($this->shouldCache($identifier)) {
  26447. $this->cache->write($identifier, json_encode($composer));
  26448. }
  26449. }
  26450. if ($composer) {
  26451. if (!isset($composer['support']['source'])) {
  26452. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  26453. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  26454. }
  26455. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  26456. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  26457. }
  26458. if (!isset($composer['abandoned']) && $this->isArchived) {
  26459. $composer['abandoned'] = true;
  26460. }
  26461. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  26462. $composer['funding'] = $funding;
  26463. }
  26464. }
  26465. $this->infoCache[$identifier] = $composer;
  26466. }
  26467. return $this->infoCache[$identifier];
  26468. }
  26469. private function getFundingInfo()
  26470. {
  26471. if (null !== $this->fundingInfo) {
  26472. return $this->fundingInfo;
  26473. }
  26474. if ($this->originUrl !== 'github.com') {
  26475. return $this->fundingInfo = false;
  26476. }
  26477. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  26478. try {
  26479. $response = $this->httpDownloader->get($file, array(
  26480. 'retry-auth-failure' => false,
  26481. ))->decodeJson();
  26482. } catch (TransportException $e) {
  26483. continue;
  26484. }
  26485. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  26486. continue;
  26487. }
  26488. break;
  26489. }
  26490. if (empty($funding)) {
  26491. return $this->fundingInfo = false;
  26492. }
  26493. $result = array();
  26494. $key = null;
  26495. foreach (preg_split('{\r?\n}', $funding) as $line) {
  26496. $line = trim($line);
  26497. if (preg_match('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  26498. if (preg_match('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  26499. foreach (array_map('trim', preg_split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  26500. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  26501. }
  26502. } elseif (preg_match('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  26503. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  26504. }
  26505. $key = null;
  26506. } elseif (preg_match('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  26507. $key = $match[1];
  26508. } elseif ($key && preg_match('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  26509. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  26510. }
  26511. }
  26512. foreach ($result as $key => $item) {
  26513. switch ($item['type']) {
  26514. case 'tidelift':
  26515. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  26516. break;
  26517. case 'github':
  26518. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  26519. break;
  26520. case 'patreon':
  26521. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  26522. break;
  26523. case 'otechie':
  26524. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  26525. break;
  26526. case 'open_collective':
  26527. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  26528. break;
  26529. case 'liberapay':
  26530. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  26531. break;
  26532. case 'ko_fi':
  26533. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  26534. break;
  26535. case 'issuehunt':
  26536. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  26537. break;
  26538. case 'community_bridge':
  26539. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  26540. break;
  26541. }
  26542. }
  26543. return $this->fundingInfo = $result;
  26544. }
  26545. public function getFileContent($file, $identifier)
  26546. {
  26547. if ($this->gitDriver) {
  26548. return $this->gitDriver->getFileContent($file, $identifier);
  26549. }
  26550. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  26551. $resource = $this->getContents($resource)->decodeJson();
  26552. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  26553. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  26554. }
  26555. return $content;
  26556. }
  26557. public function getChangeDate($identifier)
  26558. {
  26559. if ($this->gitDriver) {
  26560. return $this->gitDriver->getChangeDate($identifier);
  26561. }
  26562. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  26563. $commit = $this->getContents($resource)->decodeJson();
  26564. return new \DateTime($commit['commit']['committer']['date']);
  26565. }
  26566. public function getTags()
  26567. {
  26568. if ($this->gitDriver) {
  26569. return $this->gitDriver->getTags();
  26570. }
  26571. if (null === $this->tags) {
  26572. $this->tags = array();
  26573. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  26574. do {
  26575. $response = $this->getContents($resource);
  26576. $tagsData = $response->decodeJson();
  26577. foreach ($tagsData as $tag) {
  26578. $this->tags[$tag['name']] = $tag['commit']['sha'];
  26579. }
  26580. $resource = $this->getNextPage($response);
  26581. } while ($resource);
  26582. }
  26583. return $this->tags;
  26584. }
  26585. public function getBranches()
  26586. {
  26587. if ($this->gitDriver) {
  26588. return $this->gitDriver->getBranches();
  26589. }
  26590. if (null === $this->branches) {
  26591. $this->branches = array();
  26592. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  26593. do {
  26594. $response = $this->getContents($resource);
  26595. $branchData = $response->decodeJson();
  26596. foreach ($branchData as $branch) {
  26597. $name = substr($branch['ref'], 11);
  26598. if ($name !== 'gh-pages') {
  26599. $this->branches[$name] = $branch['object']['sha'];
  26600. }
  26601. }
  26602. $resource = $this->getNextPage($response);
  26603. } while ($resource);
  26604. }
  26605. return $this->branches;
  26606. }
  26607. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26608. {
  26609. if (!preg_match('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  26610. return false;
  26611. }
  26612. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  26613. if (!in_array(strtolower(preg_replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  26614. return false;
  26615. }
  26616. if (!extension_loaded('openssl')) {
  26617. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26618. return false;
  26619. }
  26620. return true;
  26621. }
  26622. public function getRepoData()
  26623. {
  26624. $this->fetchRootIdentifier();
  26625. return $this->repoData;
  26626. }
  26627. protected function generateSshUrl()
  26628. {
  26629. if (false !== strpos($this->originUrl, ':')) {
  26630. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26631. }
  26632. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  26633. }
  26634. protected function getContents($url, $fetchingRepoData = false)
  26635. {
  26636. try {
  26637. return parent::getContents($url);
  26638. } catch (TransportException $e) {
  26639. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  26640. switch ($e->getCode()) {
  26641. case 401:
  26642. case 404:
  26643. if (!$fetchingRepoData) {
  26644. throw $e;
  26645. }
  26646. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  26647. return parent::getContents($url);
  26648. }
  26649. if (!$this->io->isInteractive()) {
  26650. if ($this->attemptCloneFallback()) {
  26651. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26652. }
  26653. }
  26654. $scopesIssued = array();
  26655. $scopesNeeded = array();
  26656. if ($headers = $e->getHeaders()) {
  26657. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  26658. $scopesIssued = explode(' ', $scopes);
  26659. }
  26660. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  26661. $scopesNeeded = explode(' ', $scopes);
  26662. }
  26663. }
  26664. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  26665. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  26666. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26667. }
  26668. return parent::getContents($url);
  26669. case 403:
  26670. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  26671. return parent::getContents($url);
  26672. }
  26673. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26674. if ($this->attemptCloneFallback()) {
  26675. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26676. }
  26677. }
  26678. $rateLimited = $gitHubUtil->isRateLimited($e->getHeaders());
  26679. if (!$this->io->hasAuthentication($this->originUrl)) {
  26680. if (!$this->io->isInteractive()) {
  26681. $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>');
  26682. throw $e;
  26683. }
  26684. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  26685. return parent::getContents($url);
  26686. }
  26687. if ($rateLimited) {
  26688. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  26689. $this->io->writeError(sprintf(
  26690. '<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>',
  26691. $rateLimit['limit'],
  26692. $rateLimit['reset']
  26693. ));
  26694. }
  26695. throw $e;
  26696. default:
  26697. throw $e;
  26698. }
  26699. }
  26700. }
  26701. protected function fetchRootIdentifier()
  26702. {
  26703. if ($this->repoData) {
  26704. return;
  26705. }
  26706. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  26707. try {
  26708. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  26709. } catch (TransportException $e) {
  26710. if ($e->getCode() === 499) {
  26711. $this->attemptCloneFallback();
  26712. } else {
  26713. throw $e;
  26714. }
  26715. }
  26716. if (null === $this->repoData && null !== $this->gitDriver) {
  26717. return;
  26718. }
  26719. $this->owner = $this->repoData['owner']['login'];
  26720. $this->repository = $this->repoData['name'];
  26721. $this->isPrivate = !empty($this->repoData['private']);
  26722. if (isset($this->repoData['default_branch'])) {
  26723. $this->rootIdentifier = $this->repoData['default_branch'];
  26724. } elseif (isset($this->repoData['master_branch'])) {
  26725. $this->rootIdentifier = $this->repoData['master_branch'];
  26726. } else {
  26727. $this->rootIdentifier = 'master';
  26728. }
  26729. $this->hasIssues = !empty($this->repoData['has_issues']);
  26730. $this->isArchived = !empty($this->repoData['archived']);
  26731. }
  26732. protected function attemptCloneFallback()
  26733. {
  26734. $this->isPrivate = true;
  26735. try {
  26736. $this->setupGitDriver($this->generateSshUrl());
  26737. return true;
  26738. } catch (\RuntimeException $e) {
  26739. $this->gitDriver = null;
  26740. $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>');
  26741. throw $e;
  26742. }
  26743. }
  26744. protected function setupGitDriver($url)
  26745. {
  26746. $this->gitDriver = new GitDriver(
  26747. array('url' => $url),
  26748. $this->io,
  26749. $this->config,
  26750. $this->httpDownloader,
  26751. $this->process
  26752. );
  26753. $this->gitDriver->initialize();
  26754. }
  26755. protected function getNextPage(Response $response)
  26756. {
  26757. $header = $response->getHeader('link');
  26758. $links = explode(',', $header);
  26759. foreach ($links as $link) {
  26760. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26761. return $match[1];
  26762. }
  26763. }
  26764. }
  26765. }
  26766. <?php
  26767. namespace Composer\Repository\Vcs;
  26768. use Composer\Config;
  26769. use Composer\Cache;
  26770. use Composer\IO\IOInterface;
  26771. use Composer\Json\JsonFile;
  26772. use Composer\Downloader\TransportException;
  26773. use Composer\Util\HttpDownloader;
  26774. use Composer\Util\GitLab;
  26775. use Composer\Util\Http\Response;
  26776. class GitLabDriver extends VcsDriver
  26777. {
  26778. private $scheme;
  26779. private $namespace;
  26780. private $repository;
  26781. private $project;
  26782. private $commits = array();
  26783. private $tags;
  26784. private $branches;
  26785. protected $gitDriver;
  26786. private $isPrivate = true;
  26787. private $hasNonstandardOrigin = false;
  26788. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  26789. public function initialize()
  26790. {
  26791. if (!preg_match(self::URL_REGEX, $this->url, $match)) {
  26792. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  26793. }
  26794. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26795. $configuredDomains = $this->config->get('gitlab-domains');
  26796. $urlParts = explode('/', $match['parts']);
  26797. $this->scheme = !empty($match['scheme'])
  26798. ? $match['scheme']
  26799. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  26800. ;
  26801. $this->originUrl = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  26802. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  26803. $this->hasNonstandardOrigin = true;
  26804. }
  26805. $this->namespace = implode('/', $urlParts);
  26806. $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
  26807. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  26808. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26809. $this->fetchProject();
  26810. }
  26811. public function setHttpDownloader(HttpDownloader $httpDownloader)
  26812. {
  26813. $this->httpDownloader = $httpDownloader;
  26814. }
  26815. public function getComposerInformation($identifier)
  26816. {
  26817. if ($this->gitDriver) {
  26818. return $this->gitDriver->getComposerInformation($identifier);
  26819. }
  26820. if (!isset($this->infoCache[$identifier])) {
  26821. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26822. $composer = JsonFile::parseJson($res);
  26823. } else {
  26824. $composer = $this->getBaseComposerInformation($identifier);
  26825. if ($this->shouldCache($identifier)) {
  26826. $this->cache->write($identifier, json_encode($composer));
  26827. }
  26828. }
  26829. if ($composer) {
  26830. if (!isset($composer['support']['issues']) && isset($this->project['_links']['issues'])) {
  26831. $composer['support']['issues'] = $this->project['_links']['issues'];
  26832. }
  26833. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  26834. $composer['abandoned'] = true;
  26835. }
  26836. }
  26837. $this->infoCache[$identifier] = $composer;
  26838. }
  26839. return $this->infoCache[$identifier];
  26840. }
  26841. public function getFileContent($file, $identifier)
  26842. {
  26843. if ($this->gitDriver) {
  26844. return $this->gitDriver->getFileContent($file, $identifier);
  26845. }
  26846. if (!preg_match('{[a-f0-9]{40}}i', $identifier)) {
  26847. $branches = $this->getBranches();
  26848. if (isset($branches[$identifier])) {
  26849. $identifier = $branches[$identifier];
  26850. }
  26851. }
  26852. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  26853. try {
  26854. $content = $this->getContents($resource)->getBody();
  26855. } catch (TransportException $e) {
  26856. if ($e->getCode() !== 404) {
  26857. throw $e;
  26858. }
  26859. return null;
  26860. }
  26861. return $content;
  26862. }
  26863. public function getChangeDate($identifier)
  26864. {
  26865. if ($this->gitDriver) {
  26866. return $this->gitDriver->getChangeDate($identifier);
  26867. }
  26868. if (isset($this->commits[$identifier])) {
  26869. return new \DateTime($this->commits[$identifier]['committed_date']);
  26870. }
  26871. return new \DateTime();
  26872. }
  26873. public function getRepositoryUrl()
  26874. {
  26875. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  26876. }
  26877. public function getUrl()
  26878. {
  26879. if ($this->gitDriver) {
  26880. return $this->gitDriver->getUrl();
  26881. }
  26882. return $this->project['web_url'];
  26883. }
  26884. public function getDist($identifier)
  26885. {
  26886. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  26887. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26888. }
  26889. public function getSource($identifier)
  26890. {
  26891. if ($this->gitDriver) {
  26892. return $this->gitDriver->getSource($identifier);
  26893. }
  26894. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  26895. }
  26896. public function getRootIdentifier()
  26897. {
  26898. if ($this->gitDriver) {
  26899. return $this->gitDriver->getRootIdentifier();
  26900. }
  26901. return $this->project['default_branch'];
  26902. }
  26903. public function getBranches()
  26904. {
  26905. if ($this->gitDriver) {
  26906. return $this->gitDriver->getBranches();
  26907. }
  26908. if (!$this->branches) {
  26909. $this->branches = $this->getReferences('branches');
  26910. }
  26911. return $this->branches;
  26912. }
  26913. public function getTags()
  26914. {
  26915. if ($this->gitDriver) {
  26916. return $this->gitDriver->getTags();
  26917. }
  26918. if (!$this->tags) {
  26919. $this->tags = $this->getReferences('tags');
  26920. }
  26921. return $this->tags;
  26922. }
  26923. public function getApiUrl()
  26924. {
  26925. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  26926. }
  26927. private function urlEncodeAll($string)
  26928. {
  26929. $encoded = '';
  26930. for ($i = 0; isset($string[$i]); $i++) {
  26931. $character = $string[$i];
  26932. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  26933. $character = '%' . sprintf('%02X', ord($character));
  26934. }
  26935. $encoded .= $character;
  26936. }
  26937. return $encoded;
  26938. }
  26939. protected function getReferences($type)
  26940. {
  26941. $perPage = 100;
  26942. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  26943. $references = array();
  26944. do {
  26945. $response = $this->getContents($resource);
  26946. $data = $response->decodeJson();
  26947. foreach ($data as $datum) {
  26948. $references[$datum['name']] = $datum['commit']['id'];
  26949. $this->commits[$datum['commit']['id']] = $datum['commit'];
  26950. }
  26951. if (count($data) >= $perPage) {
  26952. $resource = $this->getNextPage($response);
  26953. } else {
  26954. $resource = false;
  26955. }
  26956. } while ($resource);
  26957. return $references;
  26958. }
  26959. protected function fetchProject()
  26960. {
  26961. $resource = $this->getApiUrl();
  26962. $this->project = $this->getContents($resource, true)->decodeJson();
  26963. if (isset($this->project['visibility'])) {
  26964. $this->isPrivate = $this->project['visibility'] !== 'public';
  26965. } else {
  26966. $this->isPrivate = false;
  26967. }
  26968. }
  26969. protected function attemptCloneFallback()
  26970. {
  26971. if ($this->isPrivate === false) {
  26972. $url = $this->generatePublicUrl();
  26973. } else {
  26974. $url = $this->generateSshUrl();
  26975. }
  26976. try {
  26977. $this->setupGitDriver($url);
  26978. return true;
  26979. } catch (\RuntimeException $e) {
  26980. $this->gitDriver = null;
  26981. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  26982. throw $e;
  26983. }
  26984. }
  26985. protected function generateSshUrl()
  26986. {
  26987. if ($this->hasNonstandardOrigin) {
  26988. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  26989. }
  26990. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  26991. }
  26992. protected function generatePublicUrl()
  26993. {
  26994. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  26995. }
  26996. protected function setupGitDriver($url)
  26997. {
  26998. $this->gitDriver = new GitDriver(
  26999. array('url' => $url),
  27000. $this->io,
  27001. $this->config,
  27002. $this->httpDownloader,
  27003. $this->process
  27004. );
  27005. $this->gitDriver->initialize();
  27006. }
  27007. protected function getContents($url, $fetchingRepoData = false)
  27008. {
  27009. try {
  27010. $response = parent::getContents($url);
  27011. if ($fetchingRepoData) {
  27012. $json = $response->decodeJson();
  27013. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  27014. $this->isPrivate = $json['visibility'] !== 'public';
  27015. $moreThanGuestAccess = false;
  27016. foreach ($json['permissions'] as $permission) {
  27017. if ($permission && $permission['access_level'] > 10) {
  27018. $moreThanGuestAccess = true;
  27019. }
  27020. }
  27021. if (!$moreThanGuestAccess) {
  27022. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  27023. return $this->attemptCloneFallback();
  27024. }
  27025. }
  27026. if (!isset($json['default_branch'])) {
  27027. if (!empty($json['id'])) {
  27028. $this->isPrivate = false;
  27029. }
  27030. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  27031. }
  27032. }
  27033. return $response;
  27034. } catch (TransportException $e) {
  27035. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  27036. switch ($e->getCode()) {
  27037. case 401:
  27038. case 404:
  27039. if (!$fetchingRepoData) {
  27040. throw $e;
  27041. }
  27042. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  27043. return parent::getContents($url);
  27044. }
  27045. if (!$this->io->isInteractive()) {
  27046. if ($this->attemptCloneFallback()) {
  27047. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  27048. }
  27049. }
  27050. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  27051. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  27052. return parent::getContents($url);
  27053. case 403:
  27054. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  27055. return parent::getContents($url);
  27056. }
  27057. if (!$this->io->isInteractive() && $fetchingRepoData) {
  27058. if ($this->attemptCloneFallback()) {
  27059. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  27060. }
  27061. }
  27062. throw $e;
  27063. default:
  27064. throw $e;
  27065. }
  27066. }
  27067. }
  27068. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27069. {
  27070. if (!preg_match(self::URL_REGEX, $url, $match)) {
  27071. return false;
  27072. }
  27073. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  27074. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  27075. $urlParts = explode('/', $match['parts']);
  27076. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  27077. return false;
  27078. }
  27079. if ('https' === $scheme && !extension_loaded('openssl')) {
  27080. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  27081. return false;
  27082. }
  27083. return true;
  27084. }
  27085. protected function getNextPage(Response $response)
  27086. {
  27087. $header = $response->getHeader('link');
  27088. $links = explode(',', $header);
  27089. foreach ($links as $link) {
  27090. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  27091. return $match[1];
  27092. }
  27093. }
  27094. }
  27095. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
  27096. {
  27097. $guessedDomain = strtolower($guessedDomain);
  27098. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  27099. if ($portNumber) {
  27100. return $guessedDomain.':'.$portNumber;
  27101. }
  27102. return $guessedDomain;
  27103. }
  27104. if ($portNumber) {
  27105. $guessedDomain .= ':'.$portNumber;
  27106. }
  27107. while (null !== ($part = array_shift($urlParts))) {
  27108. $guessedDomain .= '/' . $part;
  27109. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array(preg_replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  27110. return $guessedDomain;
  27111. }
  27112. }
  27113. return false;
  27114. }
  27115. }
  27116. <?php
  27117. namespace Composer\Repository\Vcs;
  27118. use Composer\Config;
  27119. use Composer\IO\IOInterface;
  27120. class HgBitbucketDriver extends BitbucketDriver
  27121. {
  27122. public function getRootIdentifier()
  27123. {
  27124. if ($this->fallbackDriver) {
  27125. return $this->fallbackDriver->getRootIdentifier();
  27126. }
  27127. if (null === $this->rootIdentifier) {
  27128. if (!$this->getRepoData()) {
  27129. return $this->fallbackDriver->getRootIdentifier();
  27130. }
  27131. if ($this->vcsType !== 'hg') {
  27132. throw new \RuntimeException(
  27133. $this->url.' does not appear to be a mercurial repository, use '.
  27134. $this->cloneHttpsUrl.' if this is a git bitbucket repository'
  27135. );
  27136. }
  27137. $mainBranchData = $this->getMainBranchData();
  27138. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default';
  27139. }
  27140. return $this->rootIdentifier;
  27141. }
  27142. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27143. {
  27144. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#i', $url)) {
  27145. return false;
  27146. }
  27147. if (!extension_loaded('openssl')) {
  27148. $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  27149. return false;
  27150. }
  27151. return true;
  27152. }
  27153. protected function setupFallbackDriver($url)
  27154. {
  27155. $this->fallbackDriver = new HgDriver(
  27156. array('url' => $url),
  27157. $this->io,
  27158. $this->config,
  27159. $this->httpDownloader,
  27160. $this->process
  27161. );
  27162. $this->fallbackDriver->initialize();
  27163. }
  27164. protected function generateSshUrl()
  27165. {
  27166. return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository;
  27167. }
  27168. }
  27169. <?php
  27170. namespace Composer\Repository\Vcs;
  27171. use Composer\Config;
  27172. use Composer\Cache;
  27173. use Composer\Util\Hg as HgUtils;
  27174. use Composer\Util\ProcessExecutor;
  27175. use Composer\Util\Filesystem;
  27176. use Composer\IO\IOInterface;
  27177. class HgDriver extends VcsDriver
  27178. {
  27179. protected $tags;
  27180. protected $branches;
  27181. protected $rootIdentifier;
  27182. protected $repoDir;
  27183. public function initialize()
  27184. {
  27185. if (Filesystem::isLocalPath($this->url)) {
  27186. $this->repoDir = $this->url;
  27187. } else {
  27188. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  27189. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27190. }
  27191. $cacheDir = $this->config->get('cache-vcs-dir');
  27192. $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  27193. $fs = new Filesystem();
  27194. $fs->ensureDirectoryExists($cacheDir);
  27195. if (!is_writable(dirname($this->repoDir))) {
  27196. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  27197. }
  27198. $this->config->prohibitUrlByConfig($this->url, $this->io);
  27199. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  27200. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  27201. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  27202. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  27203. }
  27204. } else {
  27205. $fs->removeDirectory($this->repoDir);
  27206. $repoDir = $this->repoDir;
  27207. $command = function ($url) use ($repoDir) {
  27208. return sprintf('hg clone --noupdate -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  27209. };
  27210. $hgUtils->runCommand($command, $this->url, null);
  27211. }
  27212. }
  27213. $this->getTags();
  27214. $this->getBranches();
  27215. }
  27216. public function getRootIdentifier()
  27217. {
  27218. if (null === $this->rootIdentifier) {
  27219. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  27220. $output = $this->process->splitLines($output);
  27221. $this->rootIdentifier = $output[0];
  27222. }
  27223. return $this->rootIdentifier;
  27224. }
  27225. public function getUrl()
  27226. {
  27227. return $this->url;
  27228. }
  27229. public function getSource($identifier)
  27230. {
  27231. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  27232. }
  27233. public function getDist($identifier)
  27234. {
  27235. return null;
  27236. }
  27237. public function getFileContent($file, $identifier)
  27238. {
  27239. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  27240. $this->process->execute($resource, $content, $this->repoDir);
  27241. if (!trim($content)) {
  27242. return;
  27243. }
  27244. return $content;
  27245. }
  27246. public function getChangeDate($identifier)
  27247. {
  27248. $this->process->execute(
  27249. sprintf(
  27250. 'hg log --template "{date|rfc3339date}" -r %s',
  27251. ProcessExecutor::escape($identifier)
  27252. ),
  27253. $output,
  27254. $this->repoDir
  27255. );
  27256. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  27257. }
  27258. public function getTags()
  27259. {
  27260. if (null === $this->tags) {
  27261. $tags = array();
  27262. $this->process->execute('hg tags', $output, $this->repoDir);
  27263. foreach ($this->process->splitLines($output) as $tag) {
  27264. if ($tag && preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  27265. $tags[$match[1]] = $match[2];
  27266. }
  27267. }
  27268. unset($tags['tip']);
  27269. $this->tags = $tags;
  27270. }
  27271. return $this->tags;
  27272. }
  27273. public function getBranches()
  27274. {
  27275. if (null === $this->branches) {
  27276. $branches = array();
  27277. $bookmarks = array();
  27278. $this->process->execute('hg branches', $output, $this->repoDir);
  27279. foreach ($this->process->splitLines($output) as $branch) {
  27280. if ($branch && preg_match('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  27281. $branches[$match[1]] = $match[2];
  27282. }
  27283. }
  27284. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  27285. foreach ($this->process->splitLines($output) as $branch) {
  27286. if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  27287. $bookmarks[$match[1]] = $match[2];
  27288. }
  27289. }
  27290. $this->branches = array_merge($bookmarks, $branches);
  27291. }
  27292. return $this->branches;
  27293. }
  27294. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27295. {
  27296. if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  27297. return true;
  27298. }
  27299. if (Filesystem::isLocalPath($url)) {
  27300. $url = Filesystem::getPlatformPath($url);
  27301. if (!is_dir($url)) {
  27302. return false;
  27303. }
  27304. $process = new ProcessExecutor($io);
  27305. if ($process->execute('hg summary', $output, $url) === 0) {
  27306. return true;
  27307. }
  27308. }
  27309. if (!$deep) {
  27310. return false;
  27311. }
  27312. $process = new ProcessExecutor($io);
  27313. $exit = $process->execute(sprintf('hg identify -- %s', ProcessExecutor::escape($url)), $ignored);
  27314. return $exit === 0;
  27315. }
  27316. }
  27317. <?php
  27318. namespace Composer\Repository\Vcs;
  27319. use Composer\Config;
  27320. use Composer\Cache;
  27321. use Composer\IO\IOInterface;
  27322. use Composer\Util\ProcessExecutor;
  27323. use Composer\Util\Perforce;
  27324. class PerforceDriver extends VcsDriver
  27325. {
  27326. protected $depot;
  27327. protected $branch;
  27328. protected $perforce;
  27329. public function initialize()
  27330. {
  27331. $this->depot = $this->repoConfig['depot'];
  27332. $this->branch = '';
  27333. if (!empty($this->repoConfig['branch'])) {
  27334. $this->branch = $this->repoConfig['branch'];
  27335. }
  27336. $this->initPerforce($this->repoConfig);
  27337. $this->perforce->p4Login();
  27338. $this->perforce->checkStream();
  27339. $this->perforce->writeP4ClientSpec();
  27340. $this->perforce->connectClient();
  27341. return true;
  27342. }
  27343. private function initPerforce($repoConfig)
  27344. {
  27345. if (!empty($this->perforce)) {
  27346. return;
  27347. }
  27348. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  27349. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27350. }
  27351. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  27352. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  27353. }
  27354. public function getFileContent($file, $identifier)
  27355. {
  27356. return $this->perforce->getFileContent($file, $identifier);
  27357. }
  27358. public function getChangeDate($identifier)
  27359. {
  27360. return null;
  27361. }
  27362. public function getRootIdentifier()
  27363. {
  27364. return $this->branch;
  27365. }
  27366. public function getBranches()
  27367. {
  27368. return $this->perforce->getBranches();
  27369. }
  27370. public function getTags()
  27371. {
  27372. return $this->perforce->getTags();
  27373. }
  27374. public function getDist($identifier)
  27375. {
  27376. return null;
  27377. }
  27378. public function getSource($identifier)
  27379. {
  27380. return array(
  27381. 'type' => 'perforce',
  27382. 'url' => $this->repoConfig['url'],
  27383. 'reference' => $identifier,
  27384. 'p4user' => $this->perforce->getUser(),
  27385. );
  27386. }
  27387. public function getUrl()
  27388. {
  27389. return $this->url;
  27390. }
  27391. public function hasComposerFile($identifier)
  27392. {
  27393. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  27394. return !empty($composerInfo);
  27395. }
  27396. public function getContents($url)
  27397. {
  27398. return false;
  27399. }
  27400. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27401. {
  27402. if ($deep || preg_match('#\b(perforce|p4)\b#i', $url)) {
  27403. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  27404. }
  27405. return false;
  27406. }
  27407. public function cleanup()
  27408. {
  27409. $this->perforce->cleanupClientSpec();
  27410. $this->perforce = null;
  27411. }
  27412. public function getDepot()
  27413. {
  27414. return $this->depot;
  27415. }
  27416. public function getBranch()
  27417. {
  27418. return $this->branch;
  27419. }
  27420. }
  27421. <?php
  27422. namespace Composer\Repository\Vcs;
  27423. use Composer\Cache;
  27424. use Composer\Config;
  27425. use Composer\Json\JsonFile;
  27426. use Composer\Util\ProcessExecutor;
  27427. use Composer\Util\Filesystem;
  27428. use Composer\Util\Url;
  27429. use Composer\Util\Svn as SvnUtil;
  27430. use Composer\IO\IOInterface;
  27431. use Composer\Downloader\TransportException;
  27432. class SvnDriver extends VcsDriver
  27433. {
  27434. protected $baseUrl;
  27435. protected $tags;
  27436. protected $branches;
  27437. protected $rootIdentifier;
  27438. protected $trunkPath = 'trunk';
  27439. protected $branchesPath = 'branches';
  27440. protected $tagsPath = 'tags';
  27441. protected $packagePath = '';
  27442. protected $cacheCredentials = true;
  27443. private $util;
  27444. public function initialize()
  27445. {
  27446. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  27447. SvnUtil::cleanEnv();
  27448. if (isset($this->repoConfig['trunk-path'])) {
  27449. $this->trunkPath = $this->repoConfig['trunk-path'];
  27450. }
  27451. if (isset($this->repoConfig['branches-path'])) {
  27452. $this->branchesPath = $this->repoConfig['branches-path'];
  27453. }
  27454. if (isset($this->repoConfig['tags-path'])) {
  27455. $this->tagsPath = $this->repoConfig['tags-path'];
  27456. }
  27457. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  27458. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  27459. }
  27460. if (isset($this->repoConfig['package-path'])) {
  27461. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  27462. }
  27463. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  27464. $this->baseUrl = substr($this->url, 0, $pos);
  27465. }
  27466. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  27467. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27468. $this->getBranches();
  27469. $this->getTags();
  27470. }
  27471. public function getRootIdentifier()
  27472. {
  27473. return $this->rootIdentifier ?: $this->trunkPath;
  27474. }
  27475. public function getUrl()
  27476. {
  27477. return $this->url;
  27478. }
  27479. public function getSource($identifier)
  27480. {
  27481. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  27482. }
  27483. public function getDist($identifier)
  27484. {
  27485. return null;
  27486. }
  27487. protected function shouldCache($identifier)
  27488. {
  27489. return $this->cache && preg_match('{@\d+$}', $identifier);
  27490. }
  27491. public function getComposerInformation($identifier)
  27492. {
  27493. if (!isset($this->infoCache[$identifier])) {
  27494. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  27495. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27496. }
  27497. try {
  27498. $composer = $this->getBaseComposerInformation($identifier);
  27499. } catch (TransportException $e) {
  27500. $message = $e->getMessage();
  27501. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  27502. throw $e;
  27503. }
  27504. $composer = '';
  27505. }
  27506. if ($this->shouldCache($identifier)) {
  27507. $this->cache->write($identifier.'.json', json_encode($composer));
  27508. }
  27509. $this->infoCache[$identifier] = $composer;
  27510. }
  27511. return $this->infoCache[$identifier];
  27512. }
  27513. public function getFileContent($file, $identifier)
  27514. {
  27515. $identifier = '/' . trim($identifier, '/') . '/';
  27516. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27517. if (!empty($match[2])) {
  27518. $path = $match[1];
  27519. $rev = $match[2];
  27520. } else {
  27521. $path = $identifier;
  27522. $rev = '';
  27523. }
  27524. try {
  27525. $resource = $path.$file;
  27526. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  27527. if (!trim($output)) {
  27528. return null;
  27529. }
  27530. } catch (\RuntimeException $e) {
  27531. throw new TransportException($e->getMessage());
  27532. }
  27533. return $output;
  27534. }
  27535. public function getChangeDate($identifier)
  27536. {
  27537. $identifier = '/' . trim($identifier, '/') . '/';
  27538. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27539. if (!empty($match[2])) {
  27540. $path = $match[1];
  27541. $rev = $match[2];
  27542. } else {
  27543. $path = $identifier;
  27544. $rev = '';
  27545. }
  27546. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  27547. foreach ($this->process->splitLines($output) as $line) {
  27548. if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  27549. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  27550. }
  27551. }
  27552. return null;
  27553. }
  27554. public function getTags()
  27555. {
  27556. if (null === $this->tags) {
  27557. $this->tags = array();
  27558. if ($this->tagsPath !== false) {
  27559. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  27560. if ($output) {
  27561. foreach ($this->process->splitLines($output) as $line) {
  27562. $line = trim($line);
  27563. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27564. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27565. $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  27566. '/' . $this->tagsPath . '/' . $match[2],
  27567. $match[1]
  27568. );
  27569. }
  27570. }
  27571. }
  27572. }
  27573. }
  27574. }
  27575. return $this->tags;
  27576. }
  27577. public function getBranches()
  27578. {
  27579. if (null === $this->branches) {
  27580. $this->branches = array();
  27581. if (false === $this->trunkPath) {
  27582. $trunkParent = $this->baseUrl . '/';
  27583. } else {
  27584. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  27585. }
  27586. $output = $this->execute('svn ls --verbose', $trunkParent);
  27587. if ($output) {
  27588. foreach ($this->process->splitLines($output) as $line) {
  27589. $line = trim($line);
  27590. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27591. if (isset($match[1], $match[2]) && $match[2] === './') {
  27592. $this->branches['trunk'] = $this->buildIdentifier(
  27593. '/' . $this->trunkPath,
  27594. $match[1]
  27595. );
  27596. $this->rootIdentifier = $this->branches['trunk'];
  27597. break;
  27598. }
  27599. }
  27600. }
  27601. }
  27602. unset($output);
  27603. if ($this->branchesPath !== false) {
  27604. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  27605. if ($output) {
  27606. foreach ($this->process->splitLines(trim($output)) as $line) {
  27607. $line = trim($line);
  27608. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27609. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27610. $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  27611. '/' . $this->branchesPath . '/' . $match[2],
  27612. $match[1]
  27613. );
  27614. }
  27615. }
  27616. }
  27617. }
  27618. }
  27619. }
  27620. return $this->branches;
  27621. }
  27622. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27623. {
  27624. $url = self::normalizeUrl($url);
  27625. if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  27626. return true;
  27627. }
  27628. if (!$deep && !Filesystem::isLocalPath($url)) {
  27629. return false;
  27630. }
  27631. $process = new ProcessExecutor($io);
  27632. $exit = $process->execute(
  27633. "svn info --non-interactive -- ".ProcessExecutor::escape($url),
  27634. $ignoredOutput
  27635. );
  27636. if ($exit === 0) {
  27637. return true;
  27638. }
  27639. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  27640. return true;
  27641. }
  27642. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  27643. return true;
  27644. }
  27645. return false;
  27646. }
  27647. protected static function normalizeUrl($url)
  27648. {
  27649. $fs = new Filesystem();
  27650. if ($fs->isAbsolutePath($url)) {
  27651. return 'file://' . strtr($url, '\\', '/');
  27652. }
  27653. return $url;
  27654. }
  27655. protected function execute($command, $url)
  27656. {
  27657. if (null === $this->util) {
  27658. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  27659. $this->util->setCacheCredentials($this->cacheCredentials);
  27660. }
  27661. try {
  27662. return $this->util->execute($command, $url);
  27663. } catch (\RuntimeException $e) {
  27664. if (null === $this->util->binaryVersion()) {
  27665. 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());
  27666. }
  27667. throw new \RuntimeException(
  27668. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  27669. );
  27670. }
  27671. }
  27672. protected function buildIdentifier($baseDir, $revision)
  27673. {
  27674. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  27675. }
  27676. }
  27677. <?php
  27678. namespace Composer\Repository\Vcs;
  27679. use Composer\Cache;
  27680. use Composer\Downloader\TransportException;
  27681. use Composer\Config;
  27682. use Composer\IO\IOInterface;
  27683. use Composer\Json\JsonFile;
  27684. use Composer\Util\ProcessExecutor;
  27685. use Composer\Util\HttpDownloader;
  27686. use Composer\Util\Filesystem;
  27687. use Composer\Util\Http\Response;
  27688. abstract class VcsDriver implements VcsDriverInterface
  27689. {
  27690. protected $url;
  27691. protected $originUrl;
  27692. protected $repoConfig;
  27693. protected $io;
  27694. protected $config;
  27695. protected $process;
  27696. protected $httpDownloader;
  27697. protected $infoCache = array();
  27698. protected $cache;
  27699. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  27700. {
  27701. if (Filesystem::isLocalPath($repoConfig['url'])) {
  27702. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  27703. }
  27704. $this->url = $repoConfig['url'];
  27705. $this->originUrl = $repoConfig['url'];
  27706. $this->repoConfig = $repoConfig;
  27707. $this->io = $io;
  27708. $this->config = $config;
  27709. $this->httpDownloader = $httpDownloader;
  27710. $this->process = $process;
  27711. }
  27712. protected function shouldCache($identifier)
  27713. {
  27714. return $this->cache && preg_match('{^[a-f0-9]{40}$}iD', $identifier);
  27715. }
  27716. public function getComposerInformation($identifier)
  27717. {
  27718. if (!isset($this->infoCache[$identifier])) {
  27719. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  27720. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27721. }
  27722. $composer = $this->getBaseComposerInformation($identifier);
  27723. if ($this->shouldCache($identifier)) {
  27724. $this->cache->write($identifier, json_encode($composer));
  27725. }
  27726. $this->infoCache[$identifier] = $composer;
  27727. }
  27728. return $this->infoCache[$identifier];
  27729. }
  27730. protected function getBaseComposerInformation($identifier)
  27731. {
  27732. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  27733. if (!$composerFileContent) {
  27734. return null;
  27735. }
  27736. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  27737. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  27738. $composer['time'] = $changeDate->format(DATE_RFC3339);
  27739. }
  27740. return $composer;
  27741. }
  27742. public function hasComposerFile($identifier)
  27743. {
  27744. try {
  27745. return (bool) $this->getComposerInformation($identifier);
  27746. } catch (TransportException $e) {
  27747. }
  27748. return false;
  27749. }
  27750. protected function getScheme()
  27751. {
  27752. if (extension_loaded('openssl')) {
  27753. return 'https';
  27754. }
  27755. return 'http';
  27756. }
  27757. protected function getContents($url)
  27758. {
  27759. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  27760. return $this->httpDownloader->get($url, $options);
  27761. }
  27762. public function cleanup()
  27763. {
  27764. return;
  27765. }
  27766. }
  27767. <?php
  27768. namespace Composer\Repository\Vcs;
  27769. use Composer\Config;
  27770. use Composer\IO\IOInterface;
  27771. interface VcsDriverInterface
  27772. {
  27773. public function initialize();
  27774. public function getComposerInformation($identifier);
  27775. public function getFileContent($file, $identifier);
  27776. public function getChangeDate($identifier);
  27777. public function getRootIdentifier();
  27778. public function getBranches();
  27779. public function getTags();
  27780. public function getDist($identifier);
  27781. public function getSource($identifier);
  27782. public function getUrl();
  27783. public function hasComposerFile($identifier);
  27784. public function cleanup();
  27785. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  27786. }
  27787. <?php
  27788. namespace Composer\Repository;
  27789. use Composer\Downloader\TransportException;
  27790. use Composer\Repository\Vcs\VcsDriverInterface;
  27791. use Composer\Package\Version\VersionParser;
  27792. use Composer\Package\Loader\ArrayLoader;
  27793. use Composer\Package\Loader\ValidatingArrayLoader;
  27794. use Composer\Package\Loader\InvalidPackageException;
  27795. use Composer\Package\Loader\LoaderInterface;
  27796. use Composer\EventDispatcher\EventDispatcher;
  27797. use Composer\Util\ProcessExecutor;
  27798. use Composer\Util\HttpDownloader;
  27799. use Composer\Util\Url;
  27800. use Composer\Semver\Constraint\Constraint;
  27801. use Composer\IO\IOInterface;
  27802. use Composer\Config;
  27803. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27804. {
  27805. protected $url;
  27806. protected $packageName;
  27807. protected $isVerbose;
  27808. protected $isVeryVerbose;
  27809. protected $io;
  27810. protected $config;
  27811. protected $versionParser;
  27812. protected $type;
  27813. protected $loader;
  27814. protected $repoConfig;
  27815. protected $httpDownloader;
  27816. protected $processExecutor;
  27817. protected $branchErrorOccurred = false;
  27818. private $drivers;
  27819. private $driver;
  27820. private $versionCache;
  27821. private $emptyReferences = array();
  27822. private $versionTransportExceptions = array();
  27823. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  27824. {
  27825. parent::__construct();
  27826. $this->drivers = $drivers ?: array(
  27827. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  27828. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  27829. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  27830. 'git' => 'Composer\Repository\Vcs\GitDriver',
  27831. 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
  27832. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  27833. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  27834. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  27835. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  27836. );
  27837. $this->url = $repoConfig['url'];
  27838. $this->io = $io;
  27839. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  27840. $this->isVerbose = $io->isVerbose();
  27841. $this->isVeryVerbose = $io->isVeryVerbose();
  27842. $this->config = $config;
  27843. $this->repoConfig = $repoConfig;
  27844. $this->versionCache = $versionCache;
  27845. $this->httpDownloader = $httpDownloader;
  27846. $this->processExecutor = $process ?: new ProcessExecutor($io);
  27847. }
  27848. public function getRepoName()
  27849. {
  27850. $driverClass = get_class($this->getDriver());
  27851. $driverType = array_search($driverClass, $this->drivers);
  27852. if (!$driverType) {
  27853. $driverType = $driverClass;
  27854. }
  27855. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  27856. }
  27857. public function getRepoConfig()
  27858. {
  27859. return $this->repoConfig;
  27860. }
  27861. public function setLoader(LoaderInterface $loader)
  27862. {
  27863. $this->loader = $loader;
  27864. }
  27865. public function getDriver()
  27866. {
  27867. if ($this->driver) {
  27868. return $this->driver;
  27869. }
  27870. if (isset($this->drivers[$this->type])) {
  27871. $class = $this->drivers[$this->type];
  27872. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27873. $this->driver->initialize();
  27874. return $this->driver;
  27875. }
  27876. foreach ($this->drivers as $driver) {
  27877. if ($driver::supports($this->io, $this->config, $this->url)) {
  27878. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27879. $this->driver->initialize();
  27880. return $this->driver;
  27881. }
  27882. }
  27883. foreach ($this->drivers as $driver) {
  27884. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  27885. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27886. $this->driver->initialize();
  27887. return $this->driver;
  27888. }
  27889. }
  27890. }
  27891. public function hadInvalidBranches()
  27892. {
  27893. return $this->branchErrorOccurred;
  27894. }
  27895. public function getEmptyReferences()
  27896. {
  27897. return $this->emptyReferences;
  27898. }
  27899. public function getVersionTransportExceptions()
  27900. {
  27901. return $this->versionTransportExceptions;
  27902. }
  27903. protected function initialize()
  27904. {
  27905. parent::initialize();
  27906. $isVerbose = $this->isVerbose;
  27907. $isVeryVerbose = $this->isVeryVerbose;
  27908. $driver = $this->getDriver();
  27909. if (!$driver) {
  27910. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  27911. }
  27912. $this->versionParser = new VersionParser;
  27913. if (!$this->loader) {
  27914. $this->loader = new ArrayLoader($this->versionParser);
  27915. }
  27916. $hasRootIdentifierComposerJson = false;
  27917. try {
  27918. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  27919. if ($hasRootIdentifierComposerJson) {
  27920. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  27921. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  27922. }
  27923. } catch (\Exception $e) {
  27924. if ($isVeryVerbose) {
  27925. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  27926. }
  27927. }
  27928. foreach ($driver->getTags() as $tag => $identifier) {
  27929. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  27930. if ($isVeryVerbose) {
  27931. $this->io->writeError($msg);
  27932. } elseif ($isVerbose) {
  27933. $this->io->overwriteError($msg, false);
  27934. }
  27935. $tag = str_replace('release-', '', $tag);
  27936. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  27937. if ($cachedPackage) {
  27938. $this->addPackage($cachedPackage);
  27939. continue;
  27940. }
  27941. if ($cachedPackage === false) {
  27942. $this->emptyReferences[] = $identifier;
  27943. continue;
  27944. }
  27945. if (!$parsedTag = $this->validateTag($tag)) {
  27946. if ($isVeryVerbose) {
  27947. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  27948. }
  27949. continue;
  27950. }
  27951. try {
  27952. if (!$data = $driver->getComposerInformation($identifier)) {
  27953. if ($isVeryVerbose) {
  27954. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  27955. }
  27956. $this->emptyReferences[] = $identifier;
  27957. continue;
  27958. }
  27959. if (isset($data['version'])) {
  27960. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  27961. } else {
  27962. $data['version'] = $tag;
  27963. $data['version_normalized'] = $parsedTag;
  27964. }
  27965. $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
  27966. $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  27967. unset($data['default-branch']);
  27968. if ($data['version_normalized'] !== $parsedTag) {
  27969. if ($isVeryVerbose) {
  27970. if (preg_match('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  27971. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  27972. } else {
  27973. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  27974. }
  27975. }
  27976. continue;
  27977. }
  27978. $tagPackageName = $this->packageName ?: (isset($data['name']) ? $data['name'] : '');
  27979. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  27980. if ($isVeryVerbose) {
  27981. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  27982. }
  27983. continue;
  27984. }
  27985. if ($isVeryVerbose) {
  27986. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  27987. }
  27988. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  27989. } catch (\Exception $e) {
  27990. if ($e instanceof TransportException) {
  27991. $this->versionTransportExceptions['tags'][$tag] = $e;
  27992. if ($e->getCode() === 404) {
  27993. $this->emptyReferences[] = $identifier;
  27994. }
  27995. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27996. throw $e;
  27997. }
  27998. }
  27999. if ($isVeryVerbose) {
  28000. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  28001. }
  28002. continue;
  28003. }
  28004. }
  28005. if (!$isVeryVerbose) {
  28006. $this->io->overwriteError('', false);
  28007. }
  28008. $branches = $driver->getBranches();
  28009. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  28010. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  28011. }
  28012. foreach ($branches as $branch => $identifier) {
  28013. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  28014. if ($isVeryVerbose) {
  28015. $this->io->writeError($msg);
  28016. } elseif ($isVerbose) {
  28017. $this->io->overwriteError($msg, false);
  28018. }
  28019. if (!$parsedBranch = $this->validateBranch($branch)) {
  28020. if ($isVeryVerbose) {
  28021. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  28022. }
  28023. continue;
  28024. }
  28025. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  28026. $version = 'dev-' . $branch;
  28027. } else {
  28028. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  28029. $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
  28030. }
  28031. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  28032. if ($cachedPackage) {
  28033. $this->addPackage($cachedPackage);
  28034. continue;
  28035. }
  28036. if ($cachedPackage === false) {
  28037. $this->emptyReferences[] = $identifier;
  28038. continue;
  28039. }
  28040. try {
  28041. if (!$data = $driver->getComposerInformation($identifier)) {
  28042. if ($isVeryVerbose) {
  28043. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  28044. }
  28045. $this->emptyReferences[] = $identifier;
  28046. continue;
  28047. }
  28048. $data['version'] = $version;
  28049. $data['version_normalized'] = $parsedBranch;
  28050. unset($data['default-branch']);
  28051. if ($driver->getRootIdentifier() === $branch) {
  28052. $data['default-branch'] = true;
  28053. }
  28054. if ($isVeryVerbose) {
  28055. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  28056. }
  28057. $packageData = $this->preProcess($driver, $data, $identifier);
  28058. $package = $this->loader->load($packageData);
  28059. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  28060. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  28061. }
  28062. $this->addPackage($package);
  28063. } catch (TransportException $e) {
  28064. $this->versionTransportExceptions['branches'][$branch] = $e;
  28065. if ($e->getCode() === 404) {
  28066. $this->emptyReferences[] = $identifier;
  28067. }
  28068. if ($e->getCode() === 401 || $e->getCode() === 403) {
  28069. throw $e;
  28070. }
  28071. if ($isVeryVerbose) {
  28072. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  28073. }
  28074. continue;
  28075. } catch (\Exception $e) {
  28076. if (!$isVeryVerbose) {
  28077. $this->io->writeError('');
  28078. }
  28079. $this->branchErrorOccurred = true;
  28080. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  28081. $this->io->writeError('');
  28082. continue;
  28083. }
  28084. }
  28085. $driver->cleanup();
  28086. if (!$isVeryVerbose) {
  28087. $this->io->overwriteError('', false);
  28088. }
  28089. if (!$this->getPackages()) {
  28090. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  28091. }
  28092. }
  28093. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  28094. {
  28095. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  28096. $data['name'] = $this->packageName ?: $dataPackageName;
  28097. if (!isset($data['dist'])) {
  28098. $data['dist'] = $driver->getDist($identifier);
  28099. }
  28100. if (!isset($data['source'])) {
  28101. $data['source'] = $driver->getSource($identifier);
  28102. }
  28103. return $data;
  28104. }
  28105. private function validateBranch($branch)
  28106. {
  28107. try {
  28108. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  28109. $this->versionParser->parseConstraints($normalizedBranch);
  28110. return $normalizedBranch;
  28111. } catch (\Exception $e) {
  28112. }
  28113. return false;
  28114. }
  28115. private function validateTag($version)
  28116. {
  28117. try {
  28118. return $this->versionParser->normalize($version);
  28119. } catch (\Exception $e) {
  28120. }
  28121. return false;
  28122. }
  28123. private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
  28124. {
  28125. if (!$this->versionCache) {
  28126. return;
  28127. }
  28128. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  28129. if ($cachedPackage === false) {
  28130. if ($isVeryVerbose) {
  28131. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  28132. }
  28133. return false;
  28134. }
  28135. if ($cachedPackage) {
  28136. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  28137. if ($isVeryVerbose) {
  28138. $this->io->writeError($msg);
  28139. } elseif ($isVerbose) {
  28140. $this->io->overwriteError($msg, false);
  28141. }
  28142. unset($cachedPackage['default-branch']);
  28143. if ($isDefaultBranch) {
  28144. $cachedPackage['default-branch'] = true;
  28145. }
  28146. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  28147. if ($isVeryVerbose) {
  28148. $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>');
  28149. }
  28150. $cachedPackage = null;
  28151. }
  28152. }
  28153. if ($cachedPackage) {
  28154. return $this->loader->load($cachedPackage);
  28155. }
  28156. return null;
  28157. }
  28158. }
  28159. <?php
  28160. namespace Composer\Repository;
  28161. interface VersionCacheInterface
  28162. {
  28163. public function getVersionPackage($version, $identifier);
  28164. }
  28165. <?php
  28166. namespace Composer\Repository;
  28167. use Composer\Package\AliasPackage;
  28168. use Composer\Installer\InstallationManager;
  28169. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  28170. {
  28171. protected $devPackageNames = array();
  28172. public function setDevPackageNames(array $devPackageNames)
  28173. {
  28174. $this->devPackageNames = $devPackageNames;
  28175. }
  28176. public function getDevPackageNames()
  28177. {
  28178. return $this->devPackageNames;
  28179. }
  28180. public function write($devMode, InstallationManager $installationManager)
  28181. {
  28182. }
  28183. public function reload()
  28184. {
  28185. }
  28186. public function getCanonicalPackages()
  28187. {
  28188. $packages = $this->getPackages();
  28189. $packagesByName = array();
  28190. foreach ($packages as $package) {
  28191. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  28192. $packagesByName[$package->getName()] = $package;
  28193. }
  28194. }
  28195. $canonicalPackages = array();
  28196. foreach ($packagesByName as $package) {
  28197. while ($package instanceof AliasPackage) {
  28198. $package = $package->getAliasOf();
  28199. }
  28200. $canonicalPackages[] = $package;
  28201. }
  28202. return $canonicalPackages;
  28203. }
  28204. }
  28205. <?php
  28206. namespace Composer\Repository;
  28207. use Composer\Package\PackageInterface;
  28208. use Composer\Installer\InstallationManager;
  28209. interface WritableRepositoryInterface extends RepositoryInterface
  28210. {
  28211. public function write($devMode, InstallationManager $installationManager);
  28212. public function addPackage(PackageInterface $package);
  28213. public function removePackage(PackageInterface $package);
  28214. public function getCanonicalPackages();
  28215. public function reload();
  28216. public function setDevPackageNames(array $devPackageNames);
  28217. public function getDevPackageNames();
  28218. }
  28219. <?php
  28220. namespace Composer\Script;
  28221. use Composer\Composer;
  28222. use Composer\IO\IOInterface;
  28223. use Composer\EventDispatcher\Event as BaseEvent;
  28224. class Event extends BaseEvent
  28225. {
  28226. private $composer;
  28227. private $io;
  28228. private $devMode;
  28229. private $originatingEvent;
  28230. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  28231. {
  28232. parent::__construct($name, $args, $flags);
  28233. $this->composer = $composer;
  28234. $this->io = $io;
  28235. $this->devMode = $devMode;
  28236. }
  28237. public function getComposer()
  28238. {
  28239. return $this->composer;
  28240. }
  28241. public function getIO()
  28242. {
  28243. return $this->io;
  28244. }
  28245. public function isDevMode()
  28246. {
  28247. return $this->devMode;
  28248. }
  28249. public function getOriginatingEvent()
  28250. {
  28251. return $this->originatingEvent;
  28252. }
  28253. public function setOriginatingEvent(BaseEvent $event)
  28254. {
  28255. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  28256. return $this;
  28257. }
  28258. private function calculateOriginatingEvent(BaseEvent $event)
  28259. {
  28260. if ($event instanceof Event && $event->getOriginatingEvent()) {
  28261. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  28262. }
  28263. return $event;
  28264. }
  28265. }
  28266. <?php
  28267. namespace Composer\Script;
  28268. class ScriptEvents
  28269. {
  28270. const PRE_INSTALL_CMD = 'pre-install-cmd';
  28271. const POST_INSTALL_CMD = 'post-install-cmd';
  28272. const PRE_UPDATE_CMD = 'pre-update-cmd';
  28273. const POST_UPDATE_CMD = 'post-update-cmd';
  28274. const PRE_STATUS_CMD = 'pre-status-cmd';
  28275. const POST_STATUS_CMD = 'post-status-cmd';
  28276. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  28277. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  28278. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  28279. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  28280. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  28281. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  28282. }
  28283. <?php
  28284. namespace Composer\SelfUpdate;
  28285. class Keys
  28286. {
  28287. public static function fingerprint($path)
  28288. {
  28289. $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path))));
  28290. return implode(' ', array(
  28291. substr($hash, 0, 8),
  28292. substr($hash, 8, 8),
  28293. substr($hash, 16, 8),
  28294. substr($hash, 24, 8),
  28295. '',
  28296. substr($hash, 32, 8),
  28297. substr($hash, 40, 8),
  28298. substr($hash, 48, 8),
  28299. substr($hash, 56, 8),
  28300. ));
  28301. }
  28302. }
  28303. <?php
  28304. namespace Composer\SelfUpdate;
  28305. use Composer\Util\HttpDownloader;
  28306. use Composer\Config;
  28307. class Versions
  28308. {
  28309. public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
  28310. private $httpDownloader;
  28311. private $config;
  28312. private $channel;
  28313. private $versionsData;
  28314. public function __construct(Config $config, HttpDownloader $httpDownloader)
  28315. {
  28316. $this->httpDownloader = $httpDownloader;
  28317. $this->config = $config;
  28318. }
  28319. public function getChannel()
  28320. {
  28321. if ($this->channel) {
  28322. return $this->channel;
  28323. }
  28324. $channelFile = $this->config->get('home').'/update-channel';
  28325. if (file_exists($channelFile)) {
  28326. $channel = trim(file_get_contents($channelFile));
  28327. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  28328. return $this->channel = $channel;
  28329. }
  28330. }
  28331. return $this->channel = 'stable';
  28332. }
  28333. public function setChannel($channel)
  28334. {
  28335. if (!in_array($channel, self::$channels, true)) {
  28336. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  28337. }
  28338. $channelFile = $this->config->get('home').'/update-channel';
  28339. $this->channel = $channel;
  28340. file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
  28341. }
  28342. public function getLatest($channel = null)
  28343. {
  28344. $versions = $this->getVersionsData();
  28345. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  28346. if ($version['min-php'] <= PHP_VERSION_ID) {
  28347. return $version;
  28348. }
  28349. }
  28350. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  28351. }
  28352. private function getVersionsData()
  28353. {
  28354. if (!$this->versionsData) {
  28355. if ($this->config->get('disable-tls') === true) {
  28356. $protocol = 'http';
  28357. } else {
  28358. $protocol = 'https';
  28359. }
  28360. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  28361. }
  28362. return $this->versionsData;
  28363. }
  28364. }
  28365. <?php
  28366. namespace Composer\Util;
  28367. use Composer\Config;
  28368. use Composer\IO\IOInterface;
  28369. use Composer\Downloader\TransportException;
  28370. class AuthHelper
  28371. {
  28372. protected $io;
  28373. protected $config;
  28374. private $displayedOriginAuthentications = array();
  28375. public function __construct(IOInterface $io, Config $config)
  28376. {
  28377. $this->io = $io;
  28378. $this->config = $config;
  28379. }
  28380. public function storeAuth($origin, $storeAuth)
  28381. {
  28382. $store = false;
  28383. $configSource = $this->config->getAuthConfigSource();
  28384. if ($storeAuth === true) {
  28385. $store = $configSource;
  28386. } elseif ($storeAuth === 'prompt') {
  28387. $answer = $this->io->askAndValidate(
  28388. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  28389. function ($value) {
  28390. $input = strtolower(substr(trim($value), 0, 1));
  28391. if (in_array($input, array('y','n'))) {
  28392. return $input;
  28393. }
  28394. throw new \RuntimeException('Please answer (y)es or (n)o');
  28395. },
  28396. null,
  28397. 'y'
  28398. );
  28399. if ($answer === 'y') {
  28400. $store = $configSource;
  28401. }
  28402. }
  28403. if ($store) {
  28404. $store->addConfigSetting(
  28405. 'http-basic.'.$origin,
  28406. $this->io->getAuthentication($origin)
  28407. );
  28408. }
  28409. }
  28410. public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
  28411. {
  28412. $storeAuth = false;
  28413. if (in_array($origin, $this->config->get('github-domains'), true)) {
  28414. $gitHubUtil = new GitHub($this->io, $this->config, null);
  28415. $message = "\n";
  28416. $rateLimited = $gitHubUtil->isRateLimited($headers);
  28417. if ($rateLimited) {
  28418. $rateLimit = $gitHubUtil->getRateLimit($headers);
  28419. if ($this->io->hasAuthentication($origin)) {
  28420. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  28421. } else {
  28422. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  28423. }
  28424. $message = sprintf(
  28425. '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.',
  28426. $rateLimit['limit'],
  28427. $rateLimit['reset']
  28428. )."\n";
  28429. } else {
  28430. $message .= 'Could not fetch '.$url.', please ';
  28431. if ($this->io->hasAuthentication($origin)) {
  28432. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  28433. } else {
  28434. $message .= 'create a GitHub OAuth token to access private repos';
  28435. }
  28436. }
  28437. if (!$gitHubUtil->authorizeOAuth($origin)
  28438. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  28439. ) {
  28440. throw new TransportException('Could not authenticate against '.$origin, 401);
  28441. }
  28442. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  28443. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  28444. $gitLabUtil = new GitLab($this->io, $this->config, null);
  28445. if ($this->io->hasAuthentication($origin) && ($auth = $this->io->getAuthentication($origin)) && in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  28446. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28447. }
  28448. if (!$gitLabUtil->authorizeOAuth($origin)
  28449. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  28450. ) {
  28451. throw new TransportException('Could not authenticate against '.$origin, 401);
  28452. }
  28453. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  28454. $askForOAuthToken = true;
  28455. $origin = 'bitbucket.org';
  28456. if ($this->io->hasAuthentication($origin)) {
  28457. $auth = $this->io->getAuthentication($origin);
  28458. if ($auth['username'] !== 'x-token-auth') {
  28459. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  28460. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  28461. if (!empty($accessToken)) {
  28462. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  28463. $askForOAuthToken = false;
  28464. }
  28465. } else {
  28466. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28467. }
  28468. }
  28469. if ($askForOAuthToken) {
  28470. $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');
  28471. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  28472. if (!$bitBucketUtil->authorizeOAuth($origin)
  28473. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  28474. ) {
  28475. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28476. }
  28477. }
  28478. } else {
  28479. if ($statusCode === 404) {
  28480. return;
  28481. }
  28482. if (!$this->io->isInteractive()) {
  28483. if ($statusCode === 401) {
  28484. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  28485. } elseif ($statusCode === 403) {
  28486. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  28487. } else {
  28488. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  28489. }
  28490. throw new TransportException($message, $statusCode);
  28491. }
  28492. if ($this->io->hasAuthentication($origin)) {
  28493. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28494. }
  28495. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  28496. $username = $this->io->ask(' Username: ');
  28497. $password = $this->io->askAndHideAnswer(' Password: ');
  28498. $this->io->setAuthentication($origin, $username, $password);
  28499. $storeAuth = $this->config->get('store-auths');
  28500. }
  28501. return array('retry' => true, 'storeAuth' => $storeAuth);
  28502. }
  28503. public function addAuthenticationHeader(array $headers, $origin, $url)
  28504. {
  28505. if ($this->io->hasAuthentication($origin)) {
  28506. $authenticationDisplayMessage = null;
  28507. $auth = $this->io->getAuthentication($origin);
  28508. if ($auth['password'] === 'bearer') {
  28509. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28510. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  28511. if (preg_match('{^https?://api\.github\.com/}', $url)) {
  28512. $headers[] = 'Authorization: token '.$auth['username'];
  28513. $authenticationDisplayMessage = 'Using GitHub token authentication';
  28514. }
  28515. } elseif (
  28516. in_array($origin, $this->config->get('gitlab-domains'), true)
  28517. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  28518. ) {
  28519. if ($auth['password'] === 'oauth2') {
  28520. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28521. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  28522. } elseif ($auth['password'] === 'private-token' || $auth['password'] === 'gitlab-ci-token') {
  28523. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  28524. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  28525. }
  28526. } elseif (
  28527. 'bitbucket.org' === $origin
  28528. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  28529. && 'x-token-auth' === $auth['username']
  28530. ) {
  28531. if (!$this->isPublicBitBucketDownload($url)) {
  28532. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  28533. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  28534. }
  28535. } else {
  28536. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  28537. $headers[] = 'Authorization: Basic '.$authStr;
  28538. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  28539. }
  28540. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  28541. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  28542. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  28543. }
  28544. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  28545. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  28546. }
  28547. return $headers;
  28548. }
  28549. public function isPublicBitBucketDownload($urlToBitBucketFile)
  28550. {
  28551. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  28552. if (strpos($domain, 'bitbucket.org') === false) {
  28553. return true;
  28554. }
  28555. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  28556. $pathParts = explode('/', $path);
  28557. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  28558. }
  28559. }
  28560. <?php
  28561. namespace Composer\Util;
  28562. use Composer\Factory;
  28563. use Composer\IO\IOInterface;
  28564. use Composer\Config;
  28565. use Composer\Downloader\TransportException;
  28566. class Bitbucket
  28567. {
  28568. private $io;
  28569. private $config;
  28570. private $process;
  28571. private $httpDownloader;
  28572. private $token = array();
  28573. private $time;
  28574. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  28575. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null)
  28576. {
  28577. $this->io = $io;
  28578. $this->config = $config;
  28579. $this->process = $process ?: new ProcessExecutor($io);
  28580. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  28581. $this->time = $time;
  28582. }
  28583. public function getToken()
  28584. {
  28585. if (!isset($this->token['access_token'])) {
  28586. return '';
  28587. }
  28588. return $this->token['access_token'];
  28589. }
  28590. public function authorizeOAuth($originUrl)
  28591. {
  28592. if ($originUrl !== 'bitbucket.org') {
  28593. return false;
  28594. }
  28595. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  28596. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  28597. return true;
  28598. }
  28599. return false;
  28600. }
  28601. private function requestAccessToken()
  28602. {
  28603. try {
  28604. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  28605. 'retry-auth-failure' => false,
  28606. 'http' => array(
  28607. 'method' => 'POST',
  28608. 'content' => 'grant_type=client_credentials',
  28609. ),
  28610. ));
  28611. $this->token = $response->decodeJson();
  28612. } catch (TransportException $e) {
  28613. if ($e->getCode() === 400) {
  28614. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28615. $this->io->writeError('This can have two reasons:');
  28616. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  28617. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  28618. return false;
  28619. }
  28620. if (in_array($e->getCode(), array(403, 401))) {
  28621. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28622. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28623. return false;
  28624. }
  28625. throw $e;
  28626. }
  28627. return true;
  28628. }
  28629. public function authorizeOAuthInteractively($originUrl, $message = null)
  28630. {
  28631. if ($message) {
  28632. $this->io->writeError($message);
  28633. }
  28634. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  28635. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  28636. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  28637. $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)');
  28638. $consumerKey = trim($this->io->askAndHideAnswer('Consumer Key (hidden): '));
  28639. if (!$consumerKey) {
  28640. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  28641. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28642. return false;
  28643. }
  28644. $consumerSecret = trim($this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  28645. if (!$consumerSecret) {
  28646. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  28647. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28648. return false;
  28649. }
  28650. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28651. if (!$this->requestAccessToken()) {
  28652. return false;
  28653. }
  28654. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28655. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  28656. $this->io->writeError('<info>Consumer stored successfully.</info>');
  28657. return true;
  28658. }
  28659. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  28660. {
  28661. if (!empty($this->token) || $this->getTokenFromConfig($originUrl)) {
  28662. return $this->token['access_token'];
  28663. }
  28664. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28665. if (!$this->requestAccessToken()) {
  28666. return '';
  28667. }
  28668. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28669. return $this->token['access_token'];
  28670. }
  28671. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  28672. {
  28673. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  28674. $time = null === $this->time ? time() : $this->time;
  28675. $consumer = array(
  28676. "consumer-key" => $consumerKey,
  28677. "consumer-secret" => $consumerSecret,
  28678. "access-token" => $this->token['access_token'],
  28679. "access-token-expiration" => $time + $this->token['expires_in'],
  28680. );
  28681. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  28682. }
  28683. private function getTokenFromConfig($originUrl)
  28684. {
  28685. $authConfig = $this->config->get('bitbucket-oauth');
  28686. if (
  28687. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  28688. || time() > $authConfig[$originUrl]['access-token-expiration']
  28689. ) {
  28690. return false;
  28691. }
  28692. $this->token = array(
  28693. 'access_token' => $authConfig[$originUrl]['access-token'],
  28694. );
  28695. return true;
  28696. }
  28697. }
  28698. <?php
  28699. namespace Composer\Util;
  28700. class ComposerMirror
  28701. {
  28702. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)
  28703. {
  28704. if ($reference) {
  28705. $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  28706. }
  28707. $version = strpos($version, '/') === false ? $version : md5($version);
  28708. return str_replace(
  28709. array('%package%', '%version%', '%reference%', '%type%'),
  28710. array($packageName, $version, $reference, $type),
  28711. $mirrorUrl
  28712. );
  28713. }
  28714. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  28715. {
  28716. if (preg_match('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  28717. $url = 'gh-'.$match[1].'/'.$match[2];
  28718. } elseif (preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  28719. $url = 'bb-'.$match[1].'/'.$match[2];
  28720. } else {
  28721. $url = preg_replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  28722. }
  28723. return str_replace(
  28724. array('%package%', '%normalizedUrl%', '%type%'),
  28725. array($packageName, $url, $type),
  28726. $mirrorUrl
  28727. );
  28728. }
  28729. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  28730. {
  28731. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  28732. }
  28733. }
  28734. <?php
  28735. namespace Composer\Util;
  28736. use Composer\Package\Loader\ArrayLoader;
  28737. use Composer\Package\Loader\ValidatingArrayLoader;
  28738. use Composer\Package\Loader\InvalidPackageException;
  28739. use Composer\Json\JsonValidationException;
  28740. use Composer\IO\IOInterface;
  28741. use Composer\Json\JsonFile;
  28742. use Composer\Spdx\SpdxLicenses;
  28743. class ConfigValidator
  28744. {
  28745. const CHECK_VERSION = 1;
  28746. private $io;
  28747. public function __construct(IOInterface $io)
  28748. {
  28749. $this->io = $io;
  28750. }
  28751. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
  28752. {
  28753. $errors = array();
  28754. $publishErrors = array();
  28755. $warnings = array();
  28756. $laxValid = false;
  28757. try {
  28758. $json = new JsonFile($file, null, $this->io);
  28759. $manifest = $json->read();
  28760. $json->validateSchema(JsonFile::LAX_SCHEMA);
  28761. $laxValid = true;
  28762. $json->validateSchema();
  28763. } catch (JsonValidationException $e) {
  28764. foreach ($e->getErrors() as $message) {
  28765. if ($laxValid) {
  28766. $publishErrors[] = $message;
  28767. } else {
  28768. $errors[] = $message;
  28769. }
  28770. }
  28771. } catch (\Exception $e) {
  28772. $errors[] = $e->getMessage();
  28773. return array($errors, $publishErrors, $warnings);
  28774. }
  28775. if (empty($manifest['license'])) {
  28776. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  28777. } else {
  28778. $licenses = (array) $manifest['license'];
  28779. foreach ($licenses as $key => $license) {
  28780. if ('proprietary' === $license) {
  28781. unset($licenses[$key]);
  28782. }
  28783. }
  28784. $licenseValidator = new SpdxLicenses();
  28785. foreach ($licenses as $license) {
  28786. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  28787. if ($spdxLicense && $spdxLicense[3]) {
  28788. if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  28789. $warnings[] = sprintf(
  28790. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  28791. $license
  28792. );
  28793. } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  28794. $warnings[] = sprintf(
  28795. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  28796. $license
  28797. );
  28798. } else {
  28799. $warnings[] = sprintf(
  28800. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  28801. $license
  28802. );
  28803. }
  28804. }
  28805. }
  28806. }
  28807. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  28808. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  28809. }
  28810. if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {
  28811. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  28812. $suggestName = strtolower($suggestName);
  28813. $publishErrors[] = sprintf(
  28814. '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.',
  28815. $manifest['name'],
  28816. $suggestName
  28817. );
  28818. }
  28819. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  28820. $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.";
  28821. }
  28822. if (isset($manifest['require'], $manifest['require-dev'])) {
  28823. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  28824. if (!empty($requireOverrides)) {
  28825. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  28826. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  28827. }
  28828. }
  28829. foreach (array('provide', 'replace') as $linkType) {
  28830. if (isset($manifest[$linkType])) {
  28831. foreach (array('require', 'require-dev') as $requireType) {
  28832. if (isset($manifest[$requireType])) {
  28833. foreach ($manifest[$linkType] as $provide => $constraint) {
  28834. if (isset($manifest[$requireType][$provide])) {
  28835. $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.';
  28836. }
  28837. }
  28838. }
  28839. }
  28840. }
  28841. }
  28842. $require = isset($manifest['require']) ? $manifest['require'] : array();
  28843. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  28844. $packages = array_merge($require, $requireDev);
  28845. foreach ($packages as $package => $version) {
  28846. if (preg_match('/#/', $version) === 1) {
  28847. $warnings[] = sprintf(
  28848. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  28849. $package
  28850. );
  28851. }
  28852. }
  28853. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  28854. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  28855. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  28856. if (!array_key_exists($scriptName, $scripts)) {
  28857. $warnings[] = sprintf(
  28858. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  28859. $scriptName
  28860. );
  28861. }
  28862. }
  28863. if (isset($manifest['autoload']['psr-0'][''])) {
  28864. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  28865. }
  28866. if (isset($manifest['autoload']['psr-4'][''])) {
  28867. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  28868. }
  28869. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  28870. try {
  28871. if (!isset($manifest['version'])) {
  28872. $manifest['version'] = '1.0.0';
  28873. }
  28874. if (!isset($manifest['name'])) {
  28875. $manifest['name'] = 'dummy/dummy';
  28876. }
  28877. $loader->load($manifest);
  28878. } catch (InvalidPackageException $e) {
  28879. $errors = array_merge($errors, $e->getErrors());
  28880. }
  28881. $warnings = array_merge($warnings, $loader->getWarnings());
  28882. return array($errors, $publishErrors, $warnings);
  28883. }
  28884. }
  28885. <?php
  28886. namespace Composer\Util;
  28887. use Composer\IO\IOInterface;
  28888. class ErrorHandler
  28889. {
  28890. private static $io;
  28891. public static function handle($level, $message, $file, $line)
  28892. {
  28893. if (!(error_reporting() & $level)) {
  28894. return;
  28895. }
  28896. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  28897. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  28898. "\na legitimately suppressed error that you were not supposed to see.";
  28899. }
  28900. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  28901. throw new \ErrorException($message, 0, $level, $file, $line);
  28902. }
  28903. if (self::$io) {
  28904. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  28905. if (self::$io->isVerbose()) {
  28906. self::$io->writeError('<warning>Stack trace:</warning>');
  28907. self::$io->writeError(array_filter(array_map(function ($a) {
  28908. if (isset($a['line'], $a['file'])) {
  28909. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  28910. }
  28911. return null;
  28912. }, array_slice(debug_backtrace(), 2))));
  28913. }
  28914. }
  28915. return true;
  28916. }
  28917. public static function register(IOInterface $io = null)
  28918. {
  28919. set_error_handler(array(__CLASS__, 'handle'));
  28920. error_reporting(E_ALL | E_STRICT);
  28921. self::$io = $io;
  28922. }
  28923. }
  28924. <?php
  28925. namespace Composer\Util;
  28926. use RecursiveDirectoryIterator;
  28927. use RecursiveIteratorIterator;
  28928. use Symfony\Component\Filesystem\Exception\IOException;
  28929. use Symfony\Component\Finder\Finder;
  28930. class Filesystem
  28931. {
  28932. private $processExecutor;
  28933. public function __construct(ProcessExecutor $executor = null)
  28934. {
  28935. $this->processExecutor = $executor;
  28936. }
  28937. public function remove($file)
  28938. {
  28939. if (is_dir($file)) {
  28940. return $this->removeDirectory($file);
  28941. }
  28942. if (file_exists($file)) {
  28943. return $this->unlink($file);
  28944. }
  28945. return false;
  28946. }
  28947. public function isDirEmpty($dir)
  28948. {
  28949. $finder = Finder::create()
  28950. ->ignoreVCS(false)
  28951. ->ignoreDotFiles(false)
  28952. ->depth(0)
  28953. ->in($dir);
  28954. return \count($finder) === 0;
  28955. }
  28956. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  28957. {
  28958. if (is_link($dir) && file_exists($dir)) {
  28959. $this->unlink($dir);
  28960. }
  28961. if ($ensureDirectoryExists) {
  28962. $this->ensureDirectoryExists($dir);
  28963. }
  28964. if (is_dir($dir)) {
  28965. $finder = Finder::create()
  28966. ->ignoreVCS(false)
  28967. ->ignoreDotFiles(false)
  28968. ->depth(0)
  28969. ->in($dir);
  28970. foreach ($finder as $path) {
  28971. $this->remove((string) $path);
  28972. }
  28973. }
  28974. }
  28975. public function removeDirectory($directory)
  28976. {
  28977. if ($this->isSymlinkedDirectory($directory)) {
  28978. return $this->unlinkSymlinkedDirectory($directory);
  28979. }
  28980. if ($this->isJunction($directory)) {
  28981. return $this->removeJunction($directory);
  28982. }
  28983. if (is_link($directory)) {
  28984. return unlink($directory);
  28985. }
  28986. if (!is_dir($directory) || !file_exists($directory)) {
  28987. return true;
  28988. }
  28989. if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  28990. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  28991. }
  28992. if (!\function_exists('proc_open')) {
  28993. return $this->removeDirectoryPhp($directory);
  28994. }
  28995. if (Platform::isWindows()) {
  28996. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  28997. } else {
  28998. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  28999. }
  29000. $result = $this->getProcess()->execute($cmd, $output) === 0;
  29001. clearstatcache();
  29002. if ($result && !is_dir($directory)) {
  29003. return true;
  29004. }
  29005. return $this->removeDirectoryPhp($directory);
  29006. }
  29007. public function removeDirectoryPhp($directory)
  29008. {
  29009. try {
  29010. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29011. } catch (\UnexpectedValueException $e) {
  29012. clearstatcache();
  29013. usleep(100000);
  29014. if (!is_dir($directory)) {
  29015. return true;
  29016. }
  29017. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29018. }
  29019. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  29020. foreach ($ri as $file) {
  29021. if ($file->isDir()) {
  29022. $this->rmdir($file->getPathname());
  29023. } else {
  29024. $this->unlink($file->getPathname());
  29025. }
  29026. }
  29027. return $this->rmdir($directory);
  29028. }
  29029. public function ensureDirectoryExists($directory)
  29030. {
  29031. if (!is_dir($directory)) {
  29032. if (file_exists($directory)) {
  29033. throw new \RuntimeException(
  29034. $directory.' exists and is not a directory.'
  29035. );
  29036. }
  29037. if (!@mkdir($directory, 0777, true)) {
  29038. throw new \RuntimeException(
  29039. $directory.' does not exist and could not be created.'
  29040. );
  29041. }
  29042. }
  29043. }
  29044. public function unlink($path)
  29045. {
  29046. $unlinked = @$this->unlinkImplementation($path);
  29047. if (!$unlinked) {
  29048. if (Platform::isWindows()) {
  29049. usleep(350000);
  29050. $unlinked = @$this->unlinkImplementation($path);
  29051. }
  29052. if (!$unlinked) {
  29053. $error = error_get_last();
  29054. $message = 'Could not delete '.$path.': ' . @$error['message'];
  29055. if (Platform::isWindows()) {
  29056. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  29057. }
  29058. throw new \RuntimeException($message);
  29059. }
  29060. }
  29061. return true;
  29062. }
  29063. public function rmdir($path)
  29064. {
  29065. $deleted = @rmdir($path);
  29066. if (!$deleted) {
  29067. if (Platform::isWindows()) {
  29068. usleep(350000);
  29069. $deleted = @rmdir($path);
  29070. }
  29071. if (!$deleted) {
  29072. $error = error_get_last();
  29073. $message = 'Could not delete '.$path.': ' . @$error['message'];
  29074. if (Platform::isWindows()) {
  29075. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  29076. }
  29077. throw new \RuntimeException($message);
  29078. }
  29079. }
  29080. return true;
  29081. }
  29082. public function copyThenRemove($source, $target)
  29083. {
  29084. $this->copy($source, $target);
  29085. if (!is_dir($source)) {
  29086. $this->unlink($source);
  29087. return;
  29088. }
  29089. $this->removeDirectoryPhp($source);
  29090. }
  29091. public function copy($source, $target)
  29092. {
  29093. if (!is_dir($source)) {
  29094. return copy($source, $target);
  29095. }
  29096. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  29097. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  29098. $this->ensureDirectoryExists($target);
  29099. $result = true;
  29100. foreach ($ri as $file) {
  29101. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  29102. if ($file->isDir()) {
  29103. $this->ensureDirectoryExists($targetPath);
  29104. } else {
  29105. $result = $result && copy($file->getPathname(), $targetPath);
  29106. }
  29107. }
  29108. return $result;
  29109. }
  29110. public function rename($source, $target)
  29111. {
  29112. if (true === @rename($source, $target)) {
  29113. return;
  29114. }
  29115. if (!\function_exists('proc_open')) {
  29116. $this->copyThenRemove($source, $target);
  29117. return;
  29118. }
  29119. if (Platform::isWindows()) {
  29120. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  29121. $result = $this->getProcess()->execute($command, $output);
  29122. clearstatcache();
  29123. if (0 === $result) {
  29124. $this->remove($source);
  29125. return;
  29126. }
  29127. } else {
  29128. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  29129. $result = $this->getProcess()->execute($command, $output);
  29130. clearstatcache();
  29131. if (0 === $result) {
  29132. return;
  29133. }
  29134. }
  29135. $this->copyThenRemove($source, $target);
  29136. }
  29137. public function findShortestPath($from, $to, $directories = false)
  29138. {
  29139. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  29140. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  29141. }
  29142. $from = lcfirst($this->normalizePath($from));
  29143. $to = lcfirst($this->normalizePath($to));
  29144. if ($directories) {
  29145. $from = rtrim($from, '/') . '/dummy_file';
  29146. }
  29147. if (\dirname($from) === \dirname($to)) {
  29148. return './'.basename($to);
  29149. }
  29150. $commonPath = $to;
  29151. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
  29152. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  29153. }
  29154. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  29155. return $to;
  29156. }
  29157. $commonPath = rtrim($commonPath, '/') . '/';
  29158. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
  29159. $commonPathCode = str_repeat('../', $sourcePathDepth);
  29160. return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
  29161. }
  29162. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  29163. {
  29164. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  29165. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  29166. }
  29167. $from = lcfirst($this->normalizePath($from));
  29168. $to = lcfirst($this->normalizePath($to));
  29169. if ($from === $to) {
  29170. return $directories ? '__DIR__' : '__FILE__';
  29171. }
  29172. $commonPath = $to;
  29173. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  29174. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  29175. }
  29176. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  29177. return var_export($to, true);
  29178. }
  29179. $commonPath = rtrim($commonPath, '/') . '/';
  29180. if (strpos($to, $from.'/') === 0) {
  29181. return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
  29182. }
  29183. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
  29184. if ($staticCode) {
  29185. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  29186. } else {
  29187. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  29188. }
  29189. $relTarget = substr($to, \strlen($commonPath));
  29190. return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  29191. }
  29192. public function isAbsolutePath($path)
  29193. {
  29194. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  29195. }
  29196. public function size($path)
  29197. {
  29198. if (!file_exists($path)) {
  29199. throw new \RuntimeException("$path does not exist.");
  29200. }
  29201. if (is_dir($path)) {
  29202. return $this->directorySize($path);
  29203. }
  29204. return filesize($path);
  29205. }
  29206. public function normalizePath($path)
  29207. {
  29208. $parts = array();
  29209. $path = strtr($path, '\\', '/');
  29210. $prefix = '';
  29211. $absolute = false;
  29212. if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  29213. $prefix = $match[1];
  29214. $path = substr($path, \strlen($prefix));
  29215. }
  29216. if (strpos($path, '/') === 0) {
  29217. $absolute = true;
  29218. $path = substr($path, 1);
  29219. }
  29220. $up = false;
  29221. foreach (explode('/', $path) as $chunk) {
  29222. if ('..' === $chunk && ($absolute || $up)) {
  29223. array_pop($parts);
  29224. $up = !(empty($parts) || '..' === end($parts));
  29225. } elseif ('.' !== $chunk && '' !== $chunk) {
  29226. $parts[] = $chunk;
  29227. $up = '..' !== $chunk;
  29228. }
  29229. }
  29230. return $prefix.($absolute ? '/' : '').implode('/', $parts);
  29231. }
  29232. public static function trimTrailingSlash($path)
  29233. {
  29234. if (!preg_match('{^[/\\\\]+$}', $path)) {
  29235. $path = rtrim($path, '/\\');
  29236. }
  29237. return $path;
  29238. }
  29239. public static function isLocalPath($path)
  29240. {
  29241. return (bool) preg_match('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  29242. }
  29243. public static function getPlatformPath($path)
  29244. {
  29245. if (Platform::isWindows()) {
  29246. $path = preg_replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  29247. }
  29248. return preg_replace('{^file://}i', '', $path);
  29249. }
  29250. protected function directorySize($directory)
  29251. {
  29252. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29253. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  29254. $size = 0;
  29255. foreach ($ri as $file) {
  29256. if ($file->isFile()) {
  29257. $size += $file->getSize();
  29258. }
  29259. }
  29260. return $size;
  29261. }
  29262. protected function getProcess()
  29263. {
  29264. if (!$this->processExecutor) {
  29265. $this->processExecutor = new ProcessExecutor();
  29266. }
  29267. return $this->processExecutor;
  29268. }
  29269. private function unlinkImplementation($path)
  29270. {
  29271. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  29272. return rmdir($path);
  29273. }
  29274. return unlink($path);
  29275. }
  29276. public function relativeSymlink($target, $link)
  29277. {
  29278. if (!function_exists('symlink')) {
  29279. return false;
  29280. }
  29281. $cwd = getcwd();
  29282. $relativePath = $this->findShortestPath($link, $target);
  29283. chdir(\dirname($link));
  29284. $result = @symlink($relativePath, $link);
  29285. chdir($cwd);
  29286. return $result;
  29287. }
  29288. public function isSymlinkedDirectory($directory)
  29289. {
  29290. if (!is_dir($directory)) {
  29291. return false;
  29292. }
  29293. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29294. return is_link($resolved);
  29295. }
  29296. private function unlinkSymlinkedDirectory($directory)
  29297. {
  29298. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29299. return $this->unlink($resolved);
  29300. }
  29301. private function resolveSymlinkedDirectorySymlink($pathname)
  29302. {
  29303. if (!is_dir($pathname)) {
  29304. return $pathname;
  29305. }
  29306. $resolved = rtrim($pathname, '/');
  29307. if (!\strlen($resolved)) {
  29308. return $pathname;
  29309. }
  29310. return $resolved;
  29311. }
  29312. public function junction($target, $junction)
  29313. {
  29314. if (!Platform::isWindows()) {
  29315. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  29316. }
  29317. if (!is_dir($target)) {
  29318. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  29319. }
  29320. $cmd = sprintf(
  29321. 'mklink /J %s %s',
  29322. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  29323. ProcessExecutor::escape(realpath($target))
  29324. );
  29325. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  29326. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  29327. }
  29328. clearstatcache(true, $junction);
  29329. }
  29330. public function isJunction($junction)
  29331. {
  29332. if (!Platform::isWindows()) {
  29333. return false;
  29334. }
  29335. clearstatcache(true, $junction);
  29336. if (!is_dir($junction) || is_link($junction)) {
  29337. return false;
  29338. }
  29339. $stat = lstat($junction);
  29340. return $stat ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  29341. }
  29342. public function removeJunction($junction)
  29343. {
  29344. if (!Platform::isWindows()) {
  29345. return false;
  29346. }
  29347. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  29348. if (!$this->isJunction($junction)) {
  29349. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  29350. }
  29351. return $this->rmdir($junction);
  29352. }
  29353. public function filePutContentsIfModified($path, $content)
  29354. {
  29355. $currentContent = @file_get_contents($path);
  29356. if (!$currentContent || ($currentContent != $content)) {
  29357. return file_put_contents($path, $content);
  29358. }
  29359. return 0;
  29360. }
  29361. public function safeCopy($source, $target)
  29362. {
  29363. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  29364. $source = fopen($source, 'r');
  29365. $target = fopen($target, 'w+');
  29366. stream_copy_to_stream($source, $target);
  29367. fclose($source);
  29368. fclose($target);
  29369. }
  29370. }
  29371. private function filesAreEqual($a, $b)
  29372. {
  29373. if (filesize($a) !== filesize($b)) {
  29374. return false;
  29375. }
  29376. $ah = fopen($a, 'rb');
  29377. $bh = fopen($b, 'rb');
  29378. $result = true;
  29379. while (!feof($ah)) {
  29380. if (fread($ah, 8192) != fread($bh, 8192)) {
  29381. $result = false;
  29382. break;
  29383. }
  29384. }
  29385. fclose($ah);
  29386. fclose($bh);
  29387. return $result;
  29388. }
  29389. }
  29390. <?php
  29391. namespace Composer\Util;
  29392. use Composer\Config;
  29393. use Composer\IO\IOInterface;
  29394. class Git
  29395. {
  29396. private static $version = false;
  29397. protected $io;
  29398. protected $config;
  29399. protected $process;
  29400. protected $filesystem;
  29401. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  29402. {
  29403. $this->io = $io;
  29404. $this->config = $config;
  29405. $this->process = $process;
  29406. $this->filesystem = $fs;
  29407. }
  29408. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  29409. {
  29410. $this->config->prohibitUrlByConfig($url, $this->io);
  29411. if ($initialClone) {
  29412. $origCwd = $cwd;
  29413. $cwd = null;
  29414. }
  29415. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  29416. 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.');
  29417. }
  29418. if (!$initialClone) {
  29419. $this->process->execute('git remote -v', $output, $cwd);
  29420. if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  29421. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  29422. }
  29423. }
  29424. $protocols = $this->config->get('github-protocols');
  29425. if (!is_array($protocols)) {
  29426. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  29427. }
  29428. if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  29429. $messages = array();
  29430. foreach ($protocols as $protocol) {
  29431. if ('ssh' === $protocol) {
  29432. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  29433. } else {
  29434. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  29435. }
  29436. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  29437. return;
  29438. }
  29439. $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
  29440. if ($initialClone && isset($origCwd)) {
  29441. $this->filesystem->removeDirectory($origCwd);
  29442. }
  29443. }
  29444. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  29445. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  29446. }
  29447. }
  29448. $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  29449. $command = call_user_func($commandCallable, $url);
  29450. $auth = null;
  29451. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  29452. $errorMsg = $this->process->getErrorOutput();
  29453. if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  29454. || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}i', $url, $match)
  29455. ) {
  29456. if (!$this->io->hasAuthentication($match[1])) {
  29457. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  29458. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  29459. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29460. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  29461. }
  29462. }
  29463. if ($this->io->hasAuthentication($match[1])) {
  29464. $auth = $this->io->getAuthentication($match[1]);
  29465. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29466. $command = call_user_func($commandCallable, $authUrl);
  29467. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29468. return;
  29469. }
  29470. $errorMsg = $this->process->getErrorOutput();
  29471. }
  29472. } elseif (preg_match('{^https://(bitbucket\.org)/(.*?)(?:\.git)?$}i', $url, $match)) {
  29473. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  29474. if (!$this->io->hasAuthentication($match[1])) {
  29475. $message = 'Enter your Bitbucket credentials to access private repos';
  29476. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29477. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  29478. $accessToken = $bitbucketUtil->getToken();
  29479. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29480. }
  29481. } else {
  29482. $auth = $this->io->getAuthentication($match[1]);
  29483. if ($auth['username'] !== 'x-token-auth') {
  29484. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  29485. if (!empty($accessToken)) {
  29486. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29487. }
  29488. }
  29489. }
  29490. if ($this->io->hasAuthentication($match[1])) {
  29491. $auth = $this->io->getAuthentication($match[1]);
  29492. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29493. $command = call_user_func($commandCallable, $authUrl);
  29494. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29495. return;
  29496. }
  29497. $errorMsg = $this->process->getErrorOutput();
  29498. } else {
  29499. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  29500. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  29501. $command = call_user_func($commandCallable, $sshUrl);
  29502. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29503. return;
  29504. }
  29505. $errorMsg = $this->process->getErrorOutput();
  29506. }
  29507. } elseif (
  29508. preg_match('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  29509. || preg_match('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}i', $url, $match)
  29510. ) {
  29511. if ($match[1] === 'git') {
  29512. $match[1] = 'https';
  29513. }
  29514. if (!$this->io->hasAuthentication($match[2])) {
  29515. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  29516. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  29517. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  29518. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  29519. }
  29520. }
  29521. if ($this->io->hasAuthentication($match[2])) {
  29522. $auth = $this->io->getAuthentication($match[2]);
  29523. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  29524. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  29525. } else {
  29526. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  29527. }
  29528. $command = call_user_func($commandCallable, $authUrl);
  29529. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29530. return;
  29531. }
  29532. $errorMsg = $this->process->getErrorOutput();
  29533. }
  29534. } elseif ($this->isAuthenticationFailure($url, $match)) {
  29535. if (strpos($match[2], '@')) {
  29536. list($authParts, $match[2]) = explode('@', $match[2], 2);
  29537. }
  29538. $storeAuth = false;
  29539. if ($this->io->hasAuthentication($match[2])) {
  29540. $auth = $this->io->getAuthentication($match[2]);
  29541. } elseif ($this->io->isInteractive()) {
  29542. $defaultUsername = null;
  29543. if (isset($authParts) && $authParts) {
  29544. if (false !== strpos($authParts, ':')) {
  29545. list($defaultUsername, ) = explode(':', $authParts, 2);
  29546. } else {
  29547. $defaultUsername = $authParts;
  29548. }
  29549. }
  29550. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  29551. $auth = array(
  29552. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  29553. 'password' => $this->io->askAndHideAnswer(' Password: '),
  29554. );
  29555. $storeAuth = $this->config->get('store-auths');
  29556. }
  29557. if ($auth) {
  29558. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  29559. $command = call_user_func($commandCallable, $authUrl);
  29560. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29561. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  29562. $authHelper = new AuthHelper($this->io, $this->config);
  29563. $authHelper->storeAuth($match[2], $storeAuth);
  29564. return;
  29565. }
  29566. $errorMsg = $this->process->getErrorOutput();
  29567. }
  29568. }
  29569. if ($initialClone && isset($origCwd)) {
  29570. $this->filesystem->removeDirectory($origCwd);
  29571. }
  29572. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  29573. }
  29574. }
  29575. public function syncMirror($url, $dir)
  29576. {
  29577. if (getenv('COMPOSER_DISABLE_NETWORK') && getenv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  29578. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  29579. return false;
  29580. }
  29581. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29582. try {
  29583. $commandCallable = function ($url) {
  29584. $sanitizedUrl = preg_replace('{://([^@]+?):(.+?)@}', '://', $url);
  29585. 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));
  29586. };
  29587. $this->runCommand($commandCallable, $url, $dir);
  29588. } catch (\Exception $e) {
  29589. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  29590. return false;
  29591. }
  29592. return true;
  29593. }
  29594. $this->filesystem->removeDirectory($dir);
  29595. $commandCallable = function ($url) use ($dir) {
  29596. return sprintf('git clone --mirror -- %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  29597. };
  29598. $this->runCommand($commandCallable, $url, $dir, true);
  29599. return true;
  29600. }
  29601. public function fetchRefOrSyncMirror($url, $dir, $ref)
  29602. {
  29603. if ($this->checkRefIsInMirror($dir, $ref)) {
  29604. return true;
  29605. }
  29606. if ($this->syncMirror($url, $dir)) {
  29607. return $this->checkRefIsInMirror($dir, $ref);
  29608. }
  29609. return false;
  29610. }
  29611. public static function getNoShowSignatureFlag(ProcessExecutor $process)
  29612. {
  29613. $gitVersion = self::getVersion($process);
  29614. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  29615. return ' --no-show-signature';
  29616. }
  29617. return '';
  29618. }
  29619. private function checkRefIsInMirror($dir, $ref)
  29620. {
  29621. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29622. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  29623. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  29624. if ($exitCode === 0) {
  29625. return true;
  29626. }
  29627. }
  29628. return false;
  29629. }
  29630. private function isAuthenticationFailure($url, &$match)
  29631. {
  29632. if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  29633. return false;
  29634. }
  29635. $authFailures = array(
  29636. 'fatal: Authentication failed',
  29637. 'remote error: Invalid username or password.',
  29638. 'error: 401 Unauthorized',
  29639. 'fatal: unable to access',
  29640. 'fatal: could not read Username',
  29641. );
  29642. $errorOutput = $this->process->getErrorOutput();
  29643. foreach ($authFailures as $authFailure) {
  29644. if (strpos($errorOutput, $authFailure) !== false) {
  29645. return true;
  29646. }
  29647. }
  29648. return false;
  29649. }
  29650. public static function cleanEnv()
  29651. {
  29652. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  29653. 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');
  29654. }
  29655. if (getenv('GIT_ASKPASS') !== 'echo') {
  29656. putenv('GIT_ASKPASS=echo');
  29657. $_SERVER['GIT_ASKPASS'] = 'echo';
  29658. }
  29659. if (getenv('GIT_DIR')) {
  29660. putenv('GIT_DIR');
  29661. unset($_SERVER['GIT_DIR']);
  29662. }
  29663. if (getenv('GIT_WORK_TREE')) {
  29664. putenv('GIT_WORK_TREE');
  29665. unset($_SERVER['GIT_WORK_TREE']);
  29666. }
  29667. if (getenv('LANGUAGE') !== 'C') {
  29668. putenv('LANGUAGE=C');
  29669. $_SERVER['LANGUAGE'] = 'C';
  29670. }
  29671. putenv("DYLD_LIBRARY_PATH");
  29672. unset($_SERVER['DYLD_LIBRARY_PATH']);
  29673. }
  29674. public static function getGitHubDomainsRegex(Config $config)
  29675. {
  29676. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  29677. }
  29678. public static function getGitLabDomainsRegex(Config $config)
  29679. {
  29680. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  29681. }
  29682. private function throwException($message, $url)
  29683. {
  29684. clearstatcache();
  29685. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  29686. 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()));
  29687. }
  29688. throw new \RuntimeException(Url::sanitize($message));
  29689. }
  29690. public static function getVersion(ProcessExecutor $process)
  29691. {
  29692. if (false === self::$version) {
  29693. self::$version = null;
  29694. if (0 === $process->execute('git --version', $output) && preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  29695. self::$version = $matches[1];
  29696. }
  29697. }
  29698. return self::$version;
  29699. }
  29700. }
  29701. <?php
  29702. namespace Composer\Util;
  29703. use Composer\Factory;
  29704. use Composer\IO\IOInterface;
  29705. use Composer\Config;
  29706. use Composer\Downloader\TransportException;
  29707. class GitHub
  29708. {
  29709. protected $io;
  29710. protected $config;
  29711. protected $process;
  29712. protected $httpDownloader;
  29713. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29714. {
  29715. $this->io = $io;
  29716. $this->config = $config;
  29717. $this->process = $process ?: new ProcessExecutor($io);
  29718. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29719. }
  29720. public function authorizeOAuth($originUrl)
  29721. {
  29722. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  29723. return false;
  29724. }
  29725. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  29726. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  29727. return true;
  29728. }
  29729. return false;
  29730. }
  29731. public function authorizeOAuthInteractively($originUrl, $message = null)
  29732. {
  29733. if ($message) {
  29734. $this->io->writeError($message);
  29735. }
  29736. $note = 'Composer';
  29737. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  29738. $note .= ' on ' . trim($output);
  29739. }
  29740. $note .= ' ' . date('Y-m-d Hi');
  29741. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  29742. $this->io->writeError(sprintf('Head to %s', $url));
  29743. $this->io->writeError(sprintf('to retrieve a token. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  29744. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  29745. if (!$token) {
  29746. $this->io->writeError('<warning>No token given, aborting.</warning>');
  29747. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29748. return false;
  29749. }
  29750. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  29751. try {
  29752. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  29753. $this->httpDownloader->get('https://'. $apiUrl, array(
  29754. 'retry-auth-failure' => false,
  29755. ));
  29756. } catch (TransportException $e) {
  29757. if (in_array($e->getCode(), array(403, 401))) {
  29758. $this->io->writeError('<error>Invalid token provided.</error>');
  29759. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29760. return false;
  29761. }
  29762. throw $e;
  29763. }
  29764. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  29765. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  29766. $this->io->writeError('<info>Token stored successfully.</info>');
  29767. return true;
  29768. }
  29769. public function getRateLimit(array $headers)
  29770. {
  29771. $rateLimit = array(
  29772. 'limit' => '?',
  29773. 'reset' => '?',
  29774. );
  29775. foreach ($headers as $header) {
  29776. $header = trim($header);
  29777. if (false === strpos($header, 'X-RateLimit-')) {
  29778. continue;
  29779. }
  29780. list($type, $value) = explode(':', $header, 2);
  29781. switch ($type) {
  29782. case 'X-RateLimit-Limit':
  29783. $rateLimit['limit'] = (int) trim($value);
  29784. break;
  29785. case 'X-RateLimit-Reset':
  29786. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  29787. break;
  29788. }
  29789. }
  29790. return $rateLimit;
  29791. }
  29792. public function isRateLimited(array $headers)
  29793. {
  29794. foreach ($headers as $header) {
  29795. if (preg_match('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  29796. return true;
  29797. }
  29798. }
  29799. return false;
  29800. }
  29801. }
  29802. <?php
  29803. namespace Composer\Util;
  29804. use Composer\IO\IOInterface;
  29805. use Composer\Config;
  29806. use Composer\Factory;
  29807. use Composer\Downloader\TransportException;
  29808. class GitLab
  29809. {
  29810. protected $io;
  29811. protected $config;
  29812. protected $process;
  29813. protected $httpDownloader;
  29814. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29815. {
  29816. $this->io = $io;
  29817. $this->config = $config;
  29818. $this->process = $process ?: new ProcessExecutor($io);
  29819. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29820. }
  29821. public function authorizeOAuth($originUrl)
  29822. {
  29823. $bcOriginUrl = preg_replace('{:\d+}', '', $originUrl);
  29824. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  29825. return false;
  29826. }
  29827. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  29828. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  29829. return true;
  29830. }
  29831. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  29832. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  29833. return true;
  29834. }
  29835. $authTokens = $this->config->get('gitlab-token');
  29836. if (isset($authTokens[$originUrl])) {
  29837. $token = $authTokens[$originUrl];
  29838. }
  29839. if (isset($authTokens[$bcOriginUrl])) {
  29840. $token = $authTokens[$bcOriginUrl];
  29841. }
  29842. if (isset($token)) {
  29843. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  29844. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  29845. $this->io->setAuthentication($originUrl, $username, $password);
  29846. return true;
  29847. }
  29848. return false;
  29849. }
  29850. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  29851. {
  29852. if ($message) {
  29853. $this->io->writeError($message);
  29854. }
  29855. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  29856. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/profile/applications');
  29857. $attemptCounter = 0;
  29858. while ($attemptCounter++ < 5) {
  29859. try {
  29860. $response = $this->createToken($scheme, $originUrl);
  29861. } catch (TransportException $e) {
  29862. if (in_array($e->getCode(), array(403, 401))) {
  29863. if (401 === $e->getCode()) {
  29864. $response = json_decode($e->getResponse(), true);
  29865. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  29866. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  29867. } else {
  29868. $this->io->writeError('Bad credentials.');
  29869. }
  29870. } else {
  29871. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  29872. }
  29873. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  29874. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  29875. continue;
  29876. }
  29877. throw $e;
  29878. }
  29879. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  29880. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  29881. return true;
  29882. }
  29883. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  29884. }
  29885. private function createToken($scheme, $originUrl)
  29886. {
  29887. $username = $this->io->ask('Username: ');
  29888. $password = $this->io->askAndHideAnswer('Password: ');
  29889. $headers = array('Content-Type: application/x-www-form-urlencoded');
  29890. $apiUrl = $originUrl;
  29891. $data = http_build_query(array(
  29892. 'username' => $username,
  29893. 'password' => $password,
  29894. 'grant_type' => 'password',
  29895. ), null, '&');
  29896. $options = array(
  29897. 'retry-auth-failure' => false,
  29898. 'http' => array(
  29899. 'method' => 'POST',
  29900. 'header' => $headers,
  29901. 'content' => $data,
  29902. ),
  29903. );
  29904. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  29905. $this->io->writeError('Token successfully created');
  29906. return $token;
  29907. }
  29908. }
  29909. <?php
  29910. namespace Composer\Util;
  29911. use Composer\Config;
  29912. use Composer\IO\IOInterface;
  29913. class Hg
  29914. {
  29915. private static $version = false;
  29916. private $io;
  29917. private $config;
  29918. private $process;
  29919. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  29920. {
  29921. $this->io = $io;
  29922. $this->config = $config;
  29923. $this->process = $process;
  29924. }
  29925. public function runCommand($commandCallable, $url, $cwd)
  29926. {
  29927. $this->config->prohibitUrlByConfig($url, $this->io);
  29928. $command = call_user_func($commandCallable, $url);
  29929. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29930. return;
  29931. }
  29932. if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  29933. $auth = $this->io->getAuthentication($match[5]);
  29934. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  29935. $command = call_user_func($commandCallable, $authenticatedUrl);
  29936. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29937. return;
  29938. }
  29939. $error = $this->process->getErrorOutput();
  29940. } else {
  29941. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  29942. }
  29943. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  29944. }
  29945. private function throwException($message, $url)
  29946. {
  29947. if (null === self::getVersion($this->process)) {
  29948. 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()));
  29949. }
  29950. throw new \RuntimeException(Url::sanitize($message));
  29951. }
  29952. public static function getVersion(ProcessExecutor $process)
  29953. {
  29954. if (false === self::$version) {
  29955. self::$version = null;
  29956. if (0 === $process->execute('hg --version', $output) && preg_match('/^.+? (\d+(?:\.\d+)+)\)?\r?\n/', $output, $matches)) {
  29957. self::$version = $matches[1];
  29958. }
  29959. }
  29960. return self::$version;
  29961. }
  29962. }
  29963. <?php
  29964. namespace Composer\Util\Http;
  29965. use Composer\Config;
  29966. use Composer\Downloader\MaxFileSizeExceededException;
  29967. use Composer\IO\IOInterface;
  29968. use Composer\Downloader\TransportException;
  29969. use Composer\Util\StreamContextFactory;
  29970. use Composer\Util\AuthHelper;
  29971. use Composer\Util\Url;
  29972. use Composer\Util\HttpDownloader;
  29973. use React\Promise\Promise;
  29974. class CurlDownloader
  29975. {
  29976. private $multiHandle;
  29977. private $shareHandle;
  29978. private $jobs = array();
  29979. private $io;
  29980. private $config;
  29981. private $authHelper;
  29982. private $selectTimeout = 5.0;
  29983. private $maxRedirects = 20;
  29984. private $proxyManager;
  29985. private $supportsSecureProxy;
  29986. protected $multiErrors = array(
  29987. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  29988. 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."),
  29989. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  29990. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'),
  29991. );
  29992. private static $options = array(
  29993. 'http' => array(
  29994. 'method' => CURLOPT_CUSTOMREQUEST,
  29995. 'content' => CURLOPT_POSTFIELDS,
  29996. 'header' => CURLOPT_HTTPHEADER,
  29997. 'timeout' => CURLOPT_TIMEOUT,
  29998. ),
  29999. 'ssl' => array(
  30000. 'cafile' => CURLOPT_CAINFO,
  30001. 'capath' => CURLOPT_CAPATH,
  30002. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  30003. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  30004. 'local_cert' => CURLOPT_SSLCERT,
  30005. 'local_pk' => CURLOPT_SSLKEY,
  30006. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  30007. ),
  30008. );
  30009. private static $timeInfo = array(
  30010. 'total_time' => true,
  30011. 'namelookup_time' => true,
  30012. 'connect_time' => true,
  30013. 'pretransfer_time' => true,
  30014. 'starttransfer_time' => true,
  30015. 'redirect_time' => true,
  30016. );
  30017. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  30018. {
  30019. $this->io = $io;
  30020. $this->config = $config;
  30021. $this->multiHandle = $mh = curl_multi_init();
  30022. if (function_exists('curl_multi_setopt')) {
  30023. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  30024. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  30025. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  30026. }
  30027. }
  30028. if (function_exists('curl_share_init')) {
  30029. $this->shareHandle = $sh = curl_share_init();
  30030. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  30031. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  30032. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  30033. }
  30034. $this->authHelper = new AuthHelper($io, $config);
  30035. $this->proxyManager = ProxyManager::getInstance();
  30036. $version = curl_version();
  30037. $features = $version['features'];
  30038. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  30039. }
  30040. public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
  30041. {
  30042. $attributes = array();
  30043. if (isset($options['retry-auth-failure'])) {
  30044. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  30045. unset($options['retry-auth-failure']);
  30046. }
  30047. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  30048. }
  30049. private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
  30050. {
  30051. $attributes = array_merge(array(
  30052. 'retryAuthFailure' => true,
  30053. 'redirects' => 0,
  30054. 'storeAuth' => false,
  30055. ), $attributes);
  30056. $originalOptions = $options;
  30057. if (!preg_match('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  30058. $this->config->prohibitUrlByConfig($url, $this->io);
  30059. }
  30060. $curlHandle = curl_init();
  30061. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  30062. if ($copyTo) {
  30063. $errorMessage = '';
  30064. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  30065. if ($errorMessage) {
  30066. $errorMessage .= "\n";
  30067. }
  30068. $errorMessage .= preg_replace('{^fopen\(.*?\): }', '', $msg);
  30069. });
  30070. $bodyHandle = fopen($copyTo.'~', 'w+b');
  30071. restore_error_handler();
  30072. if (!$bodyHandle) {
  30073. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  30074. }
  30075. } else {
  30076. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  30077. }
  30078. curl_setopt($curlHandle, CURLOPT_URL, $url);
  30079. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  30080. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  30081. curl_setopt($curlHandle, CURLOPT_TIMEOUT, 300);
  30082. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  30083. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  30084. curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip");
  30085. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  30086. if (function_exists('curl_share_init')) {
  30087. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  30088. }
  30089. if (!isset($options['http']['header'])) {
  30090. $options['http']['header'] = array();
  30091. }
  30092. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  30093. $options['http']['header'][] = 'Connection: keep-alive';
  30094. $version = curl_version();
  30095. $features = $version['features'];
  30096. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  30097. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  30098. }
  30099. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  30100. $options = StreamContextFactory::initOptions($url, $options, true);
  30101. foreach (self::$options as $type => $curlOptions) {
  30102. foreach ($curlOptions as $name => $curlOption) {
  30103. if (isset($options[$type][$name])) {
  30104. if ($type === 'ssl' && $name === 'verify_peer_name') {
  30105. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  30106. } else {
  30107. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  30108. }
  30109. }
  30110. }
  30111. }
  30112. $proxy = $this->proxyManager->getProxyForRequest($url);
  30113. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  30114. if ($proxy->isSecure()) {
  30115. if (!$this->supportsSecureProxy) {
  30116. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  30117. }
  30118. if (!empty($options['ssl']['cafile'])) {
  30119. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  30120. }
  30121. if (!empty($options['ssl']['capath'])) {
  30122. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  30123. }
  30124. }
  30125. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  30126. $this->jobs[(int) $curlHandle] = array(
  30127. 'url' => $url,
  30128. 'origin' => $origin,
  30129. 'attributes' => $attributes,
  30130. 'options' => $originalOptions,
  30131. 'progress' => $progress,
  30132. 'curlHandle' => $curlHandle,
  30133. 'filename' => $copyTo,
  30134. 'headerHandle' => $headerHandle,
  30135. 'bodyHandle' => $bodyHandle,
  30136. 'resolve' => $resolve,
  30137. 'reject' => $reject,
  30138. );
  30139. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  30140. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  30141. if ($attributes['redirects'] === 0) {
  30142. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  30143. }
  30144. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  30145. return (int) $curlHandle;
  30146. }
  30147. public function abortRequest($id)
  30148. {
  30149. if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) {
  30150. $job = $this->jobs[$id];
  30151. curl_multi_remove_handle($this->multiHandle, $job['handle']);
  30152. curl_close($job['handle']);
  30153. if (is_resource($job['headerHandle'])) {
  30154. fclose($job['headerHandle']);
  30155. }
  30156. if (is_resource($job['bodyHandle'])) {
  30157. fclose($job['bodyHandle']);
  30158. }
  30159. if ($job['filename']) {
  30160. @unlink($job['filename'].'~');
  30161. }
  30162. unset($this->jobs[$id]);
  30163. }
  30164. }
  30165. public function tick()
  30166. {
  30167. if (!$this->jobs) {
  30168. return;
  30169. }
  30170. $active = true;
  30171. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  30172. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  30173. usleep(150);
  30174. }
  30175. while ($progress = curl_multi_info_read($this->multiHandle)) {
  30176. $curlHandle = $progress['handle'];
  30177. $result = $progress['result'];
  30178. $i = (int) $curlHandle;
  30179. if (!isset($this->jobs[$i])) {
  30180. continue;
  30181. }
  30182. $progress = curl_getinfo($curlHandle);
  30183. $job = $this->jobs[$i];
  30184. unset($this->jobs[$i]);
  30185. $error = curl_error($curlHandle);
  30186. $errno = curl_errno($curlHandle);
  30187. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  30188. curl_close($curlHandle);
  30189. $headers = null;
  30190. $statusCode = null;
  30191. $response = null;
  30192. try {
  30193. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  30194. $errno = $errno ?: $result;
  30195. if (!$error && function_exists('curl_strerror')) {
  30196. $error = curl_strerror($errno);
  30197. }
  30198. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  30199. }
  30200. $statusCode = $progress['http_code'];
  30201. rewind($job['headerHandle']);
  30202. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  30203. fclose($job['headerHandle']);
  30204. if ($statusCode === 0) {
  30205. 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));
  30206. }
  30207. if ($job['filename']) {
  30208. $contents = $job['filename'].'~';
  30209. if ($statusCode >= 300) {
  30210. rewind($job['bodyHandle']);
  30211. $contents = stream_get_contents($job['bodyHandle']);
  30212. }
  30213. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  30214. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  30215. } else {
  30216. rewind($job['bodyHandle']);
  30217. $contents = stream_get_contents($job['bodyHandle']);
  30218. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  30219. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  30220. }
  30221. fclose($job['bodyHandle']);
  30222. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  30223. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  30224. }
  30225. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  30226. if ($result['retry']) {
  30227. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  30228. continue;
  30229. }
  30230. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  30231. $location = $this->handleRedirect($job, $response);
  30232. if ($location) {
  30233. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  30234. continue;
  30235. }
  30236. }
  30237. if ($statusCode >= 400 && $statusCode <= 599) {
  30238. throw $this->failResponse($job, $response, $response->getStatusMessage());
  30239. }
  30240. if ($job['attributes']['storeAuth']) {
  30241. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  30242. }
  30243. if ($job['filename']) {
  30244. rename($job['filename'].'~', $job['filename']);
  30245. call_user_func($job['resolve'], $response);
  30246. } else {
  30247. call_user_func($job['resolve'], $response);
  30248. }
  30249. } catch (\Exception $e) {
  30250. if ($e instanceof TransportException && $headers) {
  30251. $e->setHeaders($headers);
  30252. $e->setStatusCode($statusCode);
  30253. }
  30254. if ($e instanceof TransportException && $response) {
  30255. $e->setResponse($response->getBody());
  30256. }
  30257. if ($e instanceof TransportException && $progress) {
  30258. $e->setResponseInfo($progress);
  30259. }
  30260. $this->rejectJob($job, $e);
  30261. }
  30262. }
  30263. foreach ($this->jobs as $i => $curlHandle) {
  30264. if (!isset($this->jobs[$i])) {
  30265. continue;
  30266. }
  30267. $curlHandle = $this->jobs[$i]['curlHandle'];
  30268. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  30269. if ($this->jobs[$i]['progress'] !== $progress) {
  30270. $this->jobs[$i]['progress'] = $progress;
  30271. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  30272. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  30273. $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'));
  30274. }
  30275. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  30276. $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'));
  30277. }
  30278. }
  30279. }
  30280. }
  30281. }
  30282. private function handleRedirect(array $job, Response $response)
  30283. {
  30284. if ($locationHeader = $response->getHeader('location')) {
  30285. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  30286. $targetUrl = $locationHeader;
  30287. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  30288. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  30289. } elseif ('/' === $locationHeader[0]) {
  30290. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  30291. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  30292. } else {
  30293. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  30294. }
  30295. }
  30296. if (!empty($targetUrl)) {
  30297. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  30298. return $targetUrl;
  30299. }
  30300. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  30301. }
  30302. private function isAuthenticatedRetryNeeded(array $job, Response $response)
  30303. {
  30304. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  30305. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  30306. if ($result['retry']) {
  30307. return $result;
  30308. }
  30309. }
  30310. $locationHeader = $response->getHeader('location');
  30311. $needsAuthRetry = false;
  30312. if (
  30313. $job['origin'] === 'bitbucket.org'
  30314. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  30315. && substr($job['url'], -4) === '.zip'
  30316. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  30317. && preg_match('{^text/html\b}i', $response->getHeader('content-type'))
  30318. ) {
  30319. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  30320. }
  30321. if (
  30322. $response->getStatusCode() === 404
  30323. && $this->config && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  30324. && false !== strpos($job['url'], 'archive.zip')
  30325. ) {
  30326. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  30327. }
  30328. if ($needsAuthRetry) {
  30329. if ($job['attributes']['retryAuthFailure']) {
  30330. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  30331. if ($result['retry']) {
  30332. return $result;
  30333. }
  30334. }
  30335. throw $this->failResponse($job, $response, $needsAuthRetry);
  30336. }
  30337. return array('retry' => false, 'storeAuth' => false);
  30338. }
  30339. private function restartJob(array $job, $url, array $attributes = array())
  30340. {
  30341. if ($job['filename']) {
  30342. @unlink($job['filename'].'~');
  30343. }
  30344. $attributes = array_merge($job['attributes'], $attributes);
  30345. $origin = Url::getOrigin($this->config, $url);
  30346. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  30347. }
  30348. private function failResponse(array $job, Response $response, $errorMessage)
  30349. {
  30350. if ($job['filename']) {
  30351. @unlink($job['filename'].'~');
  30352. }
  30353. $details = '';
  30354. if ($response->getHeader('content-type') === 'application/json') {
  30355. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  30356. }
  30357. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  30358. }
  30359. private function rejectJob(array $job, \Exception $e)
  30360. {
  30361. if (is_resource($job['headerHandle'])) {
  30362. fclose($job['headerHandle']);
  30363. }
  30364. if (is_resource($job['bodyHandle'])) {
  30365. fclose($job['bodyHandle']);
  30366. }
  30367. if ($job['filename']) {
  30368. @unlink($job['filename'].'~');
  30369. }
  30370. call_user_func($job['reject'], $e);
  30371. }
  30372. private function checkCurlResult($code)
  30373. {
  30374. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  30375. throw new \RuntimeException(
  30376. isset($this->multiErrors[$code])
  30377. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  30378. : 'Unexpected cURL error: ' . $code
  30379. );
  30380. }
  30381. }
  30382. }
  30383. <?php
  30384. namespace Composer\Util\Http;
  30385. class CurlResponse extends Response
  30386. {
  30387. private $curlInfo;
  30388. public function __construct(array $request, $code, array $headers, $body, array $curlInfo)
  30389. {
  30390. parent::__construct($request, $code, $headers, $body);
  30391. $this->curlInfo = $curlInfo;
  30392. }
  30393. public function getCurlInfo()
  30394. {
  30395. return $this->curlInfo;
  30396. }
  30397. }
  30398. <?php
  30399. namespace Composer\Util\Http;
  30400. class ProxyHelper
  30401. {
  30402. public static function getProxyData()
  30403. {
  30404. $httpProxy = null;
  30405. $httpsProxy = null;
  30406. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  30407. if ($env = self::getProxyEnv(array('http_proxy', 'HTTP_PROXY'), $name)) {
  30408. $httpProxy = self::checkProxy($env, $name);
  30409. }
  30410. }
  30411. if ($env = self::getProxyEnv(array('CGI_HTTP_PROXY'), $name)) {
  30412. $httpProxy = self::checkProxy($env, $name);
  30413. }
  30414. if ($env = self::getProxyEnv(array('https_proxy', 'HTTPS_PROXY'), $name)) {
  30415. $httpsProxy = self::checkProxy($env, $name);
  30416. } else {
  30417. $httpsProxy = $httpProxy;
  30418. }
  30419. $noProxy = self::getProxyEnv(array('no_proxy', 'NO_PROXY'), $name);
  30420. return array($httpProxy, $httpsProxy, $noProxy);
  30421. }
  30422. public static function getContextOptions($proxyUrl)
  30423. {
  30424. $proxy = parse_url($proxyUrl);
  30425. $proxyUrl = self::formatParsedUrl($proxy, false);
  30426. $proxyUrl = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyUrl);
  30427. $options['http']['proxy'] = $proxyUrl;
  30428. if (isset($proxy['user'])) {
  30429. $auth = rawurldecode($proxy['user']);
  30430. if (isset($proxy['pass'])) {
  30431. $auth .= ':' . rawurldecode($proxy['pass']);
  30432. }
  30433. $auth = base64_encode($auth);
  30434. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  30435. }
  30436. return $options;
  30437. }
  30438. public static function setRequestFullUri($requestUrl, array &$options)
  30439. {
  30440. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  30441. $options['http']['request_fulluri'] = true;
  30442. } else {
  30443. unset($options['http']['request_fulluri']);
  30444. }
  30445. }
  30446. private static function getProxyEnv(array $names, &$name)
  30447. {
  30448. foreach ($names as $name) {
  30449. if (!empty($_SERVER[$name])) {
  30450. return $_SERVER[$name];
  30451. }
  30452. }
  30453. }
  30454. private static function checkProxy($proxyUrl, $envName)
  30455. {
  30456. $error = sprintf('malformed %s url', $envName);
  30457. $proxy = parse_url($proxyUrl);
  30458. if (!isset($proxy['host'])) {
  30459. throw new \RuntimeException($error);
  30460. }
  30461. $proxyUrl = self::formatParsedUrl($proxy, true);
  30462. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  30463. throw new \RuntimeException($error);
  30464. }
  30465. return $proxyUrl;
  30466. }
  30467. private static function formatParsedUrl(array $proxy, $includeAuth)
  30468. {
  30469. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  30470. if ($includeAuth && isset($proxy['user'])) {
  30471. $proxyUrl .= $proxy['user'];
  30472. if (isset($proxy['pass'])) {
  30473. $proxyUrl .= ':' . $proxy['pass'];
  30474. }
  30475. $proxyUrl .= '@';
  30476. }
  30477. $proxyUrl .= $proxy['host'];
  30478. if (isset($proxy['port'])) {
  30479. $proxyUrl .= ':' . $proxy['port'];
  30480. } elseif (strpos($proxyUrl, 'http://') === 0) {
  30481. $proxyUrl .= ':80';
  30482. } elseif (strpos($proxyUrl, 'https://') === 0) {
  30483. $proxyUrl .= ':443';
  30484. }
  30485. return $proxyUrl;
  30486. }
  30487. }
  30488. <?php
  30489. namespace Composer\Util\Http;
  30490. use Composer\Downloader\TransportException;
  30491. use Composer\Util\NoProxyPattern;
  30492. use Composer\Util\Url;
  30493. class ProxyManager
  30494. {
  30495. private $error;
  30496. private $fullProxy;
  30497. private $safeProxy;
  30498. private $streams;
  30499. private $hasProxy;
  30500. private $info;
  30501. private $lastProxy;
  30502. private $noProxyHandler;
  30503. private static $instance;
  30504. private function __construct()
  30505. {
  30506. $this->fullProxy = $this->safeProxy = array(
  30507. 'http' => null,
  30508. 'https' => null,
  30509. );
  30510. $this->streams['http'] = $this->streams['https'] = array(
  30511. 'options' => null,
  30512. );
  30513. $this->hasProxy = false;
  30514. $this->initProxyData();
  30515. }
  30516. public static function getInstance()
  30517. {
  30518. if (!self::$instance) {
  30519. self::$instance = new self();
  30520. }
  30521. return self::$instance;
  30522. }
  30523. public static function reset()
  30524. {
  30525. self::$instance = null;
  30526. }
  30527. public function getProxyForRequest($requestUrl)
  30528. {
  30529. if ($this->error) {
  30530. throw new TransportException('Unable to use a proxy: '.$this->error);
  30531. }
  30532. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  30533. $proxyUrl = '';
  30534. $options = array();
  30535. $formattedProxyUrl = '';
  30536. if ($this->hasProxy && in_array($scheme, array('http', 'https'), true) && $this->fullProxy[$scheme]) {
  30537. if ($this->noProxy($requestUrl)) {
  30538. $formattedProxyUrl = 'excluded by no_proxy';
  30539. } else {
  30540. $proxyUrl = $this->fullProxy[$scheme];
  30541. $options = $this->streams[$scheme]['options'];
  30542. ProxyHelper::setRequestFullUri($requestUrl, $options);
  30543. $formattedProxyUrl = $this->safeProxy[$scheme];
  30544. }
  30545. }
  30546. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  30547. }
  30548. public function isProxying()
  30549. {
  30550. return $this->hasProxy;
  30551. }
  30552. public function getFormattedProxy()
  30553. {
  30554. return $this->hasProxy ? $this->info : $this->error;
  30555. }
  30556. private function initProxyData()
  30557. {
  30558. try {
  30559. list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
  30560. } catch (\RuntimeException $e) {
  30561. $this->error = $e->getMessage();
  30562. return;
  30563. }
  30564. $info = array();
  30565. if ($httpProxy) {
  30566. $info[] = $this->setData($httpProxy, 'http');
  30567. }
  30568. if ($httpsProxy) {
  30569. $info[] = $this->setData($httpsProxy, 'https');
  30570. }
  30571. if ($this->hasProxy) {
  30572. $this->info = implode(', ', $info);
  30573. if ($noProxy) {
  30574. $this->noProxyHandler = array(new NoProxyPattern($noProxy), 'test');
  30575. }
  30576. }
  30577. }
  30578. private function setData($url, $scheme)
  30579. {
  30580. $safeProxy = Url::sanitize($url);
  30581. $this->fullProxy[$scheme] = $url;
  30582. $this->safeProxy[$scheme] = $safeProxy;
  30583. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  30584. $this->hasProxy = true;
  30585. return sprintf('%s=%s', $scheme, $safeProxy);
  30586. }
  30587. private function noProxy($requestUrl)
  30588. {
  30589. if ($this->noProxyHandler) {
  30590. if (call_user_func($this->noProxyHandler, $requestUrl)) {
  30591. $this->lastProxy = 'excluded by no_proxy';
  30592. return true;
  30593. }
  30594. }
  30595. return false;
  30596. }
  30597. }
  30598. <?php
  30599. namespace Composer\Util\Http;
  30600. use Composer\Util\Url;
  30601. class RequestProxy
  30602. {
  30603. private $contextOptions;
  30604. private $isSecure;
  30605. private $formattedUrl;
  30606. private $url;
  30607. public function __construct($url, array $contextOptions, $formattedUrl)
  30608. {
  30609. $this->url = $url;
  30610. $this->contextOptions = $contextOptions;
  30611. $this->formattedUrl = $formattedUrl;
  30612. $this->isSecure = 0 === strpos($url, 'https://');
  30613. }
  30614. public function getContextOptions()
  30615. {
  30616. return $this->contextOptions;
  30617. }
  30618. public function getFormattedUrl($format = '')
  30619. {
  30620. $result = '';
  30621. if ($this->formattedUrl) {
  30622. $format = $format ?: '%s';
  30623. $result = sprintf($format, $this->formattedUrl);
  30624. }
  30625. return $result;
  30626. }
  30627. public function getUrl()
  30628. {
  30629. return $this->url;
  30630. }
  30631. public function isSecure()
  30632. {
  30633. return $this->isSecure;
  30634. }
  30635. }
  30636. <?php
  30637. namespace Composer\Util\Http;
  30638. use Composer\Json\JsonFile;
  30639. class Response
  30640. {
  30641. private $request;
  30642. private $code;
  30643. private $headers;
  30644. private $body;
  30645. public function __construct(array $request, $code, array $headers, $body)
  30646. {
  30647. if (!isset($request['url'])) {
  30648. throw new \LogicException('url key missing from request array');
  30649. }
  30650. $this->request = $request;
  30651. $this->code = (int) $code;
  30652. $this->headers = $headers;
  30653. $this->body = $body;
  30654. }
  30655. public function getStatusCode()
  30656. {
  30657. return $this->code;
  30658. }
  30659. public function getStatusMessage()
  30660. {
  30661. $value = null;
  30662. foreach ($this->headers as $header) {
  30663. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  30664. $value = $header;
  30665. }
  30666. }
  30667. return $value;
  30668. }
  30669. public function getHeaders()
  30670. {
  30671. return $this->headers;
  30672. }
  30673. public function getHeader($name)
  30674. {
  30675. return self::findHeaderValue($this->headers, $name);
  30676. }
  30677. public function getBody()
  30678. {
  30679. return $this->body;
  30680. }
  30681. public function decodeJson()
  30682. {
  30683. return JsonFile::parseJson($this->body, $this->request['url']);
  30684. }
  30685. public function collect()
  30686. {
  30687. $this->request = $this->code = $this->headers = $this->body = null;
  30688. }
  30689. public static function findHeaderValue(array $headers, $name)
  30690. {
  30691. $value = null;
  30692. foreach ($headers as $header) {
  30693. if (preg_match('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  30694. $value = $match[1];
  30695. }
  30696. }
  30697. return $value;
  30698. }
  30699. }
  30700. <?php
  30701. namespace Composer\Util;
  30702. use Composer\Config;
  30703. use Composer\IO\IOInterface;
  30704. use Composer\Downloader\TransportException;
  30705. use Composer\Util\Http\Response;
  30706. use Composer\Composer;
  30707. use Composer\Package\Version\VersionParser;
  30708. use Composer\Semver\Constraint\Constraint;
  30709. use Composer\Exception\IrrecoverableDownloadException;
  30710. use React\Promise\Promise;
  30711. class HttpDownloader
  30712. {
  30713. const STATUS_QUEUED = 1;
  30714. const STATUS_STARTED = 2;
  30715. const STATUS_COMPLETED = 3;
  30716. const STATUS_FAILED = 4;
  30717. const STATUS_ABORTED = 5;
  30718. private $io;
  30719. private $config;
  30720. private $jobs = array();
  30721. private $options = array();
  30722. private $runningJobs = 0;
  30723. private $maxJobs = 12;
  30724. private $curl;
  30725. private $rfs;
  30726. private $idGen = 0;
  30727. private $disabled;
  30728. private $allowAsync = false;
  30729. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  30730. {
  30731. $this->io = $io;
  30732. $this->disabled = (bool) getenv('COMPOSER_DISABLE_NETWORK');
  30733. if ($disableTls === false) {
  30734. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  30735. }
  30736. $this->options = array_replace_recursive($this->options, $options);
  30737. $this->config = $config;
  30738. if (self::isCurlEnabled()) {
  30739. $this->curl = new Http\CurlDownloader($io, $config, $options, $disableTls);
  30740. }
  30741. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  30742. if (is_numeric($maxJobs = getenv('COMPOSER_MAX_PARALLEL_HTTP'))) {
  30743. $this->maxJobs = max(1, min(50, (int) $maxJobs));
  30744. }
  30745. }
  30746. public function get($url, $options = array())
  30747. {
  30748. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30749. $this->wait($job['id']);
  30750. $response = $this->getResponse($job['id']);
  30751. if (
  30752. $this->curl
  30753. && PHP_VERSION_ID < 70000
  30754. && $response->getBody() === null
  30755. && $response->getStatusCode() === 200
  30756. && $response->getHeader('content-length') !== '0'
  30757. ) {
  30758. $this->io->writeError('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
  30759. $this->curl = null;
  30760. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30761. $this->wait($job['id']);
  30762. $response = $this->getResponse($job['id']);
  30763. }
  30764. return $response;
  30765. }
  30766. public function add($url, $options = array())
  30767. {
  30768. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false));
  30769. return $promise;
  30770. }
  30771. public function copy($url, $to, $options = array())
  30772. {
  30773. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  30774. $this->wait($job['id']);
  30775. return $this->getResponse($job['id']);
  30776. }
  30777. public function addCopy($url, $to, $options = array())
  30778. {
  30779. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  30780. return $promise;
  30781. }
  30782. public function getOptions()
  30783. {
  30784. return $this->options;
  30785. }
  30786. public function setOptions(array $options)
  30787. {
  30788. $this->options = array_replace_recursive($this->options, $options);
  30789. }
  30790. private function addJob($request, $sync = false)
  30791. {
  30792. $request['options'] = array_replace_recursive($this->options, $request['options']);
  30793. $job = array(
  30794. 'id' => $this->idGen++,
  30795. 'status' => self::STATUS_QUEUED,
  30796. 'request' => $request,
  30797. 'sync' => $sync,
  30798. 'origin' => Url::getOrigin($this->config, $request['url']),
  30799. );
  30800. if (!$sync && !$this->allowAsync) {
  30801. 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');
  30802. }
  30803. if (preg_match('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  30804. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  30805. }
  30806. $rfs = $this->rfs;
  30807. if ($this->canUseCurl($job)) {
  30808. $resolver = function ($resolve, $reject) use (&$job) {
  30809. $job['status'] = HttpDownloader::STATUS_QUEUED;
  30810. $job['resolve'] = $resolve;
  30811. $job['reject'] = $reject;
  30812. };
  30813. } else {
  30814. $resolver = function ($resolve, $reject) use (&$job, $rfs) {
  30815. $url = $job['request']['url'];
  30816. $options = $job['request']['options'];
  30817. $job['status'] = HttpDownloader::STATUS_STARTED;
  30818. if ($job['request']['copyTo']) {
  30819. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  30820. $headers = $rfs->getLastHeaders();
  30821. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  30822. $resolve($response);
  30823. } else {
  30824. $body = $rfs->getContents($job['origin'], $url, false , $options);
  30825. $headers = $rfs->getLastHeaders();
  30826. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  30827. $resolve($response);
  30828. }
  30829. };
  30830. }
  30831. $downloader = $this;
  30832. $curl = $this->curl;
  30833. $canceler = function () use (&$job, $curl) {
  30834. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  30835. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30836. }
  30837. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  30838. return;
  30839. }
  30840. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30841. if (isset($job['curl_id'])) {
  30842. $curl->abortRequest($job['curl_id']);
  30843. }
  30844. throw new IrrecoverableDownloadException('Download of ' . Url::sanitize($job['request']['url']) . ' canceled');
  30845. };
  30846. $promise = new Promise($resolver, $canceler);
  30847. $promise = $promise->then(function ($response) use (&$job, $downloader) {
  30848. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  30849. $job['response'] = $response;
  30850. $downloader->markJobDone();
  30851. return $response;
  30852. }, function ($e) use (&$job, $downloader) {
  30853. $job['status'] = HttpDownloader::STATUS_FAILED;
  30854. $job['exception'] = $e;
  30855. $downloader->markJobDone();
  30856. throw $e;
  30857. });
  30858. $this->jobs[$job['id']] = &$job;
  30859. if ($this->runningJobs < $this->maxJobs) {
  30860. $this->startJob($job['id']);
  30861. }
  30862. return array($job, $promise);
  30863. }
  30864. private function startJob($id)
  30865. {
  30866. $job = &$this->jobs[$id];
  30867. if ($job['status'] !== self::STATUS_QUEUED) {
  30868. return;
  30869. }
  30870. $job['status'] = self::STATUS_STARTED;
  30871. $this->runningJobs++;
  30872. $resolve = $job['resolve'];
  30873. $reject = $job['reject'];
  30874. $url = $job['request']['url'];
  30875. $options = $job['request']['options'];
  30876. $origin = $job['origin'];
  30877. if ($this->disabled) {
  30878. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  30879. $resolve(new Response(array('url' => $url), 304, array(), ''));
  30880. } else {
  30881. $e = new TransportException('Network disabled, request canceled: '.Url::sanitize($url), 499);
  30882. $e->setStatusCode(499);
  30883. $reject($e);
  30884. }
  30885. return;
  30886. }
  30887. try {
  30888. if ($job['request']['copyTo']) {
  30889. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  30890. } else {
  30891. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  30892. }
  30893. } catch (\Exception $exception) {
  30894. $reject($exception);
  30895. }
  30896. }
  30897. public function markJobDone()
  30898. {
  30899. $this->runningJobs--;
  30900. }
  30901. public function wait($index = null)
  30902. {
  30903. do {
  30904. $jobCount = $this->countActiveJobs($index);
  30905. } while ($jobCount);
  30906. }
  30907. public function enableAsync()
  30908. {
  30909. $this->allowAsync = true;
  30910. }
  30911. public function countActiveJobs($index = null)
  30912. {
  30913. if ($this->runningJobs < $this->maxJobs) {
  30914. foreach ($this->jobs as $job) {
  30915. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  30916. $this->startJob($job['id']);
  30917. }
  30918. }
  30919. }
  30920. if ($this->curl) {
  30921. $this->curl->tick();
  30922. }
  30923. if (null !== $index) {
  30924. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  30925. }
  30926. $active = 0;
  30927. foreach ($this->jobs as $job) {
  30928. if ($job['status'] < self::STATUS_COMPLETED) {
  30929. $active++;
  30930. } elseif (!$job['sync']) {
  30931. unset($this->jobs[$job['id']]);
  30932. }
  30933. }
  30934. return $active;
  30935. }
  30936. private function getResponse($index)
  30937. {
  30938. if (!isset($this->jobs[$index])) {
  30939. throw new \LogicException('Invalid request id');
  30940. }
  30941. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  30942. throw $this->jobs[$index]['exception'];
  30943. }
  30944. if (!isset($this->jobs[$index]['response'])) {
  30945. throw new \LogicException('Response not available yet, call wait() first');
  30946. }
  30947. $resp = $this->jobs[$index]['response'];
  30948. unset($this->jobs[$index]);
  30949. return $resp;
  30950. }
  30951. public static function outputWarnings(IOInterface $io, $url, $data)
  30952. {
  30953. foreach (array('warning', 'info') as $type) {
  30954. if (empty($data[$type])) {
  30955. continue;
  30956. }
  30957. if (!empty($data[$type . '-versions'])) {
  30958. $versionParser = new VersionParser();
  30959. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  30960. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  30961. if (!$constraint->matches($composer)) {
  30962. continue;
  30963. }
  30964. }
  30965. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.Url::sanitize($url).': '.$data[$type].'</'.$type.'>');
  30966. }
  30967. }
  30968. public static function getExceptionHints(\Exception $e)
  30969. {
  30970. if (!$e instanceof TransportException) {
  30971. return;
  30972. }
  30973. if (
  30974. false !== strpos($e->getMessage(), 'Resolving timed out')
  30975. || false !== strpos($e->getMessage(), 'Could not resolve host')
  30976. ) {
  30977. Silencer::suppress();
  30978. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
  30979. 'ssl' => array('verify_peer' => false),
  30980. 'http' => array('follow_location' => false, 'ignore_errors' => true),
  30981. )));
  30982. Silencer::restore();
  30983. if (false !== $testConnectivity) {
  30984. return array(
  30985. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  30986. );
  30987. }
  30988. return array(
  30989. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  30990. );
  30991. }
  30992. }
  30993. private function canUseCurl(array $job)
  30994. {
  30995. if (!$this->curl) {
  30996. return false;
  30997. }
  30998. if (!preg_match('{^https?://}i', $job['request']['url'])) {
  30999. return false;
  31000. }
  31001. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  31002. return false;
  31003. }
  31004. return true;
  31005. }
  31006. public static function isCurlEnabled()
  31007. {
  31008. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  31009. }
  31010. }
  31011. <?php
  31012. namespace Composer\Util;
  31013. use Composer\XdebugHandler\XdebugHandler;
  31014. class IniHelper
  31015. {
  31016. public static function getAll()
  31017. {
  31018. return XdebugHandler::getAllIniFiles();
  31019. }
  31020. public static function getMessage()
  31021. {
  31022. $paths = self::getAll();
  31023. if (empty($paths[0])) {
  31024. array_shift($paths);
  31025. }
  31026. $ini = array_shift($paths);
  31027. if (empty($ini)) {
  31028. return 'A php.ini file does not exist. You will have to create one.';
  31029. }
  31030. if (!empty($paths)) {
  31031. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  31032. }
  31033. return 'The php.ini used by your command-line PHP is: '.$ini;
  31034. }
  31035. }
  31036. <?php
  31037. namespace Composer\Util;
  31038. use React\Promise\Promise;
  31039. use Symfony\Component\Console\Helper\ProgressBar;
  31040. class Loop
  31041. {
  31042. private $httpDownloader;
  31043. private $processExecutor;
  31044. private $currentPromises = array();
  31045. private $waitIndex = 0;
  31046. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  31047. {
  31048. $this->httpDownloader = $httpDownloader;
  31049. $this->httpDownloader->enableAsync();
  31050. $this->processExecutor = $processExecutor;
  31051. if ($this->processExecutor) {
  31052. $this->processExecutor->enableAsync();
  31053. }
  31054. }
  31055. public function getHttpDownloader()
  31056. {
  31057. return $this->httpDownloader;
  31058. }
  31059. public function getProcessExecutor()
  31060. {
  31061. return $this->processExecutor;
  31062. }
  31063. public function wait(array $promises, ProgressBar $progress = null)
  31064. {
  31065. $uncaught = null;
  31066. \React\Promise\all($promises)->then(
  31067. function () {
  31068. },
  31069. function ($e) use (&$uncaught) {
  31070. $uncaught = $e;
  31071. }
  31072. );
  31073. $waitIndex = $this->waitIndex++;
  31074. $this->currentPromises[$waitIndex] = $promises;
  31075. if ($progress) {
  31076. $totalJobs = 0;
  31077. if ($this->httpDownloader) {
  31078. $totalJobs += $this->httpDownloader->countActiveJobs();
  31079. }
  31080. if ($this->processExecutor) {
  31081. $totalJobs += $this->processExecutor->countActiveJobs();
  31082. }
  31083. $progress->start($totalJobs);
  31084. }
  31085. $lastUpdate = 0;
  31086. while (true) {
  31087. $activeJobs = 0;
  31088. if ($this->httpDownloader) {
  31089. $activeJobs += $this->httpDownloader->countActiveJobs();
  31090. }
  31091. if ($this->processExecutor) {
  31092. $activeJobs += $this->processExecutor->countActiveJobs();
  31093. }
  31094. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  31095. $lastUpdate = microtime(true);
  31096. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  31097. }
  31098. if (!$activeJobs) {
  31099. break;
  31100. }
  31101. }
  31102. if ($progress) {
  31103. $progress->setProgress($progress->getMaxSteps());
  31104. }
  31105. unset($this->currentPromises[$waitIndex]);
  31106. if ($uncaught) {
  31107. throw $uncaught;
  31108. }
  31109. }
  31110. public function abortJobs()
  31111. {
  31112. foreach ($this->currentPromises as $promiseGroup) {
  31113. foreach ($promiseGroup as $promise) {
  31114. $promise->cancel();
  31115. }
  31116. }
  31117. }
  31118. }
  31119. <?php
  31120. namespace Composer\Util;
  31121. @trigger_error('Composer\Util\MetadataMinifier is deprecated, use Composer\MetadataMinifier\MetadataMinifier from composer/metadata-minifier instead.', E_USER_DEPRECATED);
  31122. class MetadataMinifier extends \Composer\MetadataMinifier\MetadataMinifier
  31123. {
  31124. }
  31125. <?php
  31126. namespace Composer\Util;
  31127. use stdClass;
  31128. class NoProxyPattern
  31129. {
  31130. protected $hostNames = array();
  31131. protected $rules = array();
  31132. protected $noproxy;
  31133. public function __construct($pattern)
  31134. {
  31135. $this->hostNames = preg_split('{[\s,]+}', $pattern, null, PREG_SPLIT_NO_EMPTY);
  31136. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  31137. }
  31138. public function test($url)
  31139. {
  31140. if ($this->noproxy) {
  31141. return true;
  31142. }
  31143. if (!$urlData = $this->getUrlData($url)) {
  31144. return false;
  31145. }
  31146. foreach ($this->hostNames as $index => $hostName) {
  31147. if ($this->match($index, $hostName, $urlData)) {
  31148. return true;
  31149. }
  31150. }
  31151. return false;
  31152. }
  31153. protected function getUrlData($url)
  31154. {
  31155. if (!$host = parse_url($url, PHP_URL_HOST)) {
  31156. return false;
  31157. }
  31158. $port = parse_url($url, PHP_URL_PORT);
  31159. if (empty($port)) {
  31160. switch (parse_url($url, PHP_URL_SCHEME)) {
  31161. case 'http':
  31162. $port = 80;
  31163. break;
  31164. case 'https':
  31165. $port = 443;
  31166. break;
  31167. }
  31168. }
  31169. $hostName = $host . ($port ? ':' . $port : '');
  31170. list($host, $port, $err) = $this->splitHostPort($hostName);
  31171. if ($err || !$this->ipCheckData($host, $ipdata)) {
  31172. return false;
  31173. }
  31174. return $this->makeData($host, $port, $ipdata);
  31175. }
  31176. protected function match($index, $hostName, $url)
  31177. {
  31178. if (!$rule = $this->getRule($index, $hostName)) {
  31179. return false;
  31180. }
  31181. if ($rule->ipdata) {
  31182. if (!$url->ipdata) {
  31183. return false;
  31184. }
  31185. if ($rule->ipdata->netmask) {
  31186. return $this->matchRange($rule->ipdata, $url->ipdata);
  31187. }
  31188. $match = $rule->ipdata->ip === $url->ipdata->ip;
  31189. } else {
  31190. $haystack = substr($url->name, -strlen($rule->name));
  31191. $match = stripos($haystack, $rule->name) === 0;
  31192. }
  31193. if ($match && $rule->port) {
  31194. $match = $rule->port === $url->port;
  31195. }
  31196. return $match;
  31197. }
  31198. protected function matchRange(stdClass $network, stdClass $target)
  31199. {
  31200. $net = unpack('C*', $network->ip);
  31201. $mask = unpack('C*', $network->netmask);
  31202. $ip = unpack('C*', $target->ip);
  31203. for ($i = 1; $i < 17; ++$i) {
  31204. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  31205. return false;
  31206. }
  31207. }
  31208. return true;
  31209. }
  31210. private function getRule($index, $hostName)
  31211. {
  31212. if (array_key_exists($index, $this->rules)) {
  31213. return $this->rules[$index];
  31214. }
  31215. $this->rules[$index] = null;
  31216. list($host, $port, $err) = $this->splitHostPort($hostName);
  31217. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  31218. return null;
  31219. }
  31220. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  31221. return $this->rules[$index];
  31222. }
  31223. private function ipCheckData($host, &$ipdata, $allowPrefix = false)
  31224. {
  31225. $ipdata = null;
  31226. $netmask = null;
  31227. $prefix = null;
  31228. $modified = false;
  31229. if (strpos($host, '/') !== false) {
  31230. list($host, $prefix) = explode('/', $host);
  31231. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  31232. return false;
  31233. }
  31234. $prefix = (int) $prefix;
  31235. $modified = true;
  31236. }
  31237. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  31238. return !$modified;
  31239. }
  31240. list($ip, $size) = $this->ipGetAddr($host);
  31241. if ($prefix !== null) {
  31242. if ($prefix > $size * 8) {
  31243. return false;
  31244. }
  31245. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  31246. }
  31247. $ipdata = $this->makeIpData($ip, $size, $netmask);
  31248. return true;
  31249. }
  31250. private function ipGetAddr($host)
  31251. {
  31252. $ip = inet_pton($host);
  31253. $size = strlen($ip);
  31254. $mapped = $this->ipMapTo6($ip, $size);
  31255. return array($mapped, $size);
  31256. }
  31257. private function ipGetMask($prefix, $size)
  31258. {
  31259. $mask = '';
  31260. if ($ones = floor($prefix / 8)) {
  31261. $mask = str_repeat(chr(255), $ones);
  31262. }
  31263. if ($remainder = $prefix % 8) {
  31264. $mask .= chr(0xff ^ (0xff >> $remainder));
  31265. }
  31266. $mask = str_pad($mask, $size, chr(0));
  31267. return $this->ipMapTo6($mask, $size);
  31268. }
  31269. private function ipGetNetwork($rangeIp, $size, $prefix)
  31270. {
  31271. $netmask = $this->ipGetMask($prefix, $size);
  31272. $mask = unpack('C*', $netmask);
  31273. $ip = unpack('C*', $rangeIp);
  31274. $net = '';
  31275. for ($i = 1; $i < 17; ++$i) {
  31276. $net .= chr($ip[$i] & $mask[$i]);
  31277. }
  31278. return array($net, $netmask);
  31279. }
  31280. private function ipMapTo6($binary, $size)
  31281. {
  31282. if ($size === 4) {
  31283. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  31284. $binary = $prefix . $binary;
  31285. }
  31286. return $binary;
  31287. }
  31288. private function makeData($host, $port, $ipdata)
  31289. {
  31290. return (object) array(
  31291. 'host' => $host,
  31292. 'name' => '.' . ltrim($host, '.'),
  31293. 'port' => $port,
  31294. 'ipdata' => $ipdata,
  31295. );
  31296. }
  31297. private function makeIpData($ip, $size, $netmask)
  31298. {
  31299. return (object) array(
  31300. 'ip' => $ip,
  31301. 'size' => $size,
  31302. 'netmask' => $netmask,
  31303. );
  31304. }
  31305. private function splitHostPort($hostName)
  31306. {
  31307. $error = array('', '', true);
  31308. $port = 0;
  31309. $ip6 = '';
  31310. if ($hostName[0] === '[') {
  31311. $index = strpos($hostName, ']');
  31312. if (false === $index || $index < 3) {
  31313. return $error;
  31314. }
  31315. $ip6 = substr($hostName, 1, $index - 1);
  31316. $hostName = substr($hostName, $index + 1);
  31317. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  31318. return $error;
  31319. }
  31320. }
  31321. if (substr_count($hostName, ':') === 1) {
  31322. $index = strpos($hostName, ':');
  31323. $port = substr($hostName, $index + 1);
  31324. $hostName = substr($hostName, 0, $index);
  31325. if (!$this->validateInt($port, 1, 65535)) {
  31326. return $error;
  31327. }
  31328. $port = (int) $port;
  31329. }
  31330. $host = $ip6 . $hostName;
  31331. return array($host, $port, false);
  31332. }
  31333. private function validateInt($int, $min, $max)
  31334. {
  31335. $options = array(
  31336. 'options' => array(
  31337. 'min_range' => $min,
  31338. 'max_range' => $max,
  31339. ),
  31340. );
  31341. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  31342. }
  31343. }
  31344. <?php
  31345. namespace Composer\Util;
  31346. use Composer\Package\Link;
  31347. use Composer\Package\PackageInterface;
  31348. class PackageSorter
  31349. {
  31350. public static function sortPackages(array $packages)
  31351. {
  31352. $usageList = array();
  31353. foreach ($packages as $package) {
  31354. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  31355. $target = $link->getTarget();
  31356. $usageList[$target][] = $package->getName();
  31357. }
  31358. }
  31359. $computing = array();
  31360. $computed = array();
  31361. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  31362. if (isset($computed[$name])) {
  31363. return $computed[$name];
  31364. }
  31365. if (isset($computing[$name])) {
  31366. return 0;
  31367. }
  31368. $computing[$name] = true;
  31369. $weight = 0;
  31370. if (isset($usageList[$name])) {
  31371. foreach ($usageList[$name] as $user) {
  31372. $weight -= 1 - $computeImportance($user);
  31373. }
  31374. }
  31375. unset($computing[$name]);
  31376. $computed[$name] = $weight;
  31377. return $weight;
  31378. };
  31379. $weightList = array();
  31380. foreach ($packages as $index => $package) {
  31381. $weight = $computeImportance($package->getName());
  31382. $weightList[$index] = $weight;
  31383. }
  31384. $stable_sort = function (&$array) {
  31385. static $transform, $restore;
  31386. $i = 0;
  31387. if (!$transform) {
  31388. $transform = function (&$v, $k) use (&$i) {
  31389. $v = array($v, ++$i, $k, $v);
  31390. };
  31391. $restore = function (&$v) {
  31392. $v = $v[3];
  31393. };
  31394. }
  31395. array_walk($array, $transform);
  31396. asort($array);
  31397. array_walk($array, $restore);
  31398. };
  31399. $stable_sort($weightList);
  31400. $sortedPackages = array();
  31401. foreach (array_keys($weightList) as $index) {
  31402. $sortedPackages[] = $packages[$index];
  31403. }
  31404. return $sortedPackages;
  31405. }
  31406. }
  31407. <?php
  31408. namespace Composer\Util;
  31409. use Composer\IO\IOInterface;
  31410. use Symfony\Component\Process\Process;
  31411. class Perforce
  31412. {
  31413. protected $path;
  31414. protected $p4Depot;
  31415. protected $p4Client;
  31416. protected $p4User;
  31417. protected $p4Password;
  31418. protected $p4Port;
  31419. protected $p4Stream;
  31420. protected $p4ClientSpec;
  31421. protected $p4DepotType;
  31422. protected $p4Branch;
  31423. protected $process;
  31424. protected $uniquePerforceClientName;
  31425. protected $windowsFlag;
  31426. protected $commandResult;
  31427. protected $io;
  31428. protected $filesystem;
  31429. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  31430. {
  31431. $this->windowsFlag = $isWindows;
  31432. $this->p4Port = $port;
  31433. $this->initializePath($path);
  31434. $this->process = $process;
  31435. $this->initialize($repoConfig);
  31436. $this->io = $io;
  31437. }
  31438. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  31439. {
  31440. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  31441. }
  31442. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  31443. {
  31444. $output = null;
  31445. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  31446. }
  31447. public function initialize($repoConfig)
  31448. {
  31449. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  31450. if (!$repoConfig) {
  31451. return;
  31452. }
  31453. if (isset($repoConfig['unique_perforce_client_name'])) {
  31454. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  31455. }
  31456. if (isset($repoConfig['depot'])) {
  31457. $this->p4Depot = $repoConfig['depot'];
  31458. }
  31459. if (isset($repoConfig['branch'])) {
  31460. $this->p4Branch = $repoConfig['branch'];
  31461. }
  31462. if (isset($repoConfig['p4user'])) {
  31463. $this->p4User = $repoConfig['p4user'];
  31464. } else {
  31465. $this->p4User = $this->getP4variable('P4USER');
  31466. }
  31467. if (isset($repoConfig['p4password'])) {
  31468. $this->p4Password = $repoConfig['p4password'];
  31469. }
  31470. }
  31471. public function initializeDepotAndBranch($depot, $branch)
  31472. {
  31473. if (isset($depot)) {
  31474. $this->p4Depot = $depot;
  31475. }
  31476. if (isset($branch)) {
  31477. $this->p4Branch = $branch;
  31478. }
  31479. }
  31480. public function generateUniquePerforceClientName()
  31481. {
  31482. return gethostname() . "_" . time();
  31483. }
  31484. public function cleanupClientSpec()
  31485. {
  31486. $client = $this->getClient();
  31487. $task = 'client -d ' . ProcessExecutor::escape($client);
  31488. $useP4Client = false;
  31489. $command = $this->generateP4Command($task, $useP4Client);
  31490. $this->executeCommand($command);
  31491. $clientSpec = $this->getP4ClientSpec();
  31492. $fileSystem = $this->getFilesystem();
  31493. $fileSystem->remove($clientSpec);
  31494. }
  31495. protected function executeCommand($command)
  31496. {
  31497. $this->commandResult = '';
  31498. return $this->process->execute($command, $this->commandResult);
  31499. }
  31500. public function getClient()
  31501. {
  31502. if (!isset($this->p4Client)) {
  31503. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  31504. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  31505. }
  31506. return $this->p4Client;
  31507. }
  31508. protected function getPath()
  31509. {
  31510. return $this->path;
  31511. }
  31512. public function initializePath($path)
  31513. {
  31514. $this->path = $path;
  31515. $fs = $this->getFilesystem();
  31516. $fs->ensureDirectoryExists($path);
  31517. }
  31518. protected function getPort()
  31519. {
  31520. return $this->p4Port;
  31521. }
  31522. public function setStream($stream)
  31523. {
  31524. $this->p4Stream = $stream;
  31525. $index = strrpos($stream, '/');
  31526. if ($index > 2) {
  31527. $this->p4DepotType = 'stream';
  31528. }
  31529. }
  31530. public function isStream()
  31531. {
  31532. return (strcmp($this->p4DepotType, 'stream') === 0);
  31533. }
  31534. public function getStream()
  31535. {
  31536. if (!isset($this->p4Stream)) {
  31537. if ($this->isStream()) {
  31538. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  31539. } else {
  31540. $this->p4Stream = '//' . $this->p4Depot;
  31541. }
  31542. }
  31543. return $this->p4Stream;
  31544. }
  31545. public function getStreamWithoutLabel($stream)
  31546. {
  31547. $index = strpos($stream, '@');
  31548. if ($index === false) {
  31549. return $stream;
  31550. }
  31551. return substr($stream, 0, $index);
  31552. }
  31553. public function getP4ClientSpec()
  31554. {
  31555. return $this->path . '/' . $this->getClient() . '.p4.spec';
  31556. }
  31557. public function getUser()
  31558. {
  31559. return $this->p4User;
  31560. }
  31561. public function setUser($user)
  31562. {
  31563. $this->p4User = $user;
  31564. }
  31565. public function queryP4User()
  31566. {
  31567. $this->getUser();
  31568. if (strlen($this->p4User) > 0) {
  31569. return;
  31570. }
  31571. $this->p4User = $this->getP4variable('P4USER');
  31572. if (strlen($this->p4User) > 0) {
  31573. return;
  31574. }
  31575. $this->p4User = $this->io->ask('Enter P4 User:');
  31576. if ($this->windowsFlag) {
  31577. $command = 'p4 set P4USER=' . $this->p4User;
  31578. } else {
  31579. $command = 'export P4USER=' . $this->p4User;
  31580. }
  31581. $this->executeCommand($command);
  31582. }
  31583. protected function getP4variable($name)
  31584. {
  31585. if ($this->windowsFlag) {
  31586. $command = 'p4 set';
  31587. $this->executeCommand($command);
  31588. $result = trim($this->commandResult);
  31589. $resArray = explode(PHP_EOL, $result);
  31590. foreach ($resArray as $line) {
  31591. $fields = explode('=', $line);
  31592. if (strcmp($name, $fields[0]) == 0) {
  31593. $index = strpos($fields[1], ' ');
  31594. if ($index === false) {
  31595. $value = $fields[1];
  31596. } else {
  31597. $value = substr($fields[1], 0, $index);
  31598. }
  31599. $value = trim($value);
  31600. return $value;
  31601. }
  31602. }
  31603. return null;
  31604. }
  31605. $command = 'echo $' . $name;
  31606. $this->executeCommand($command);
  31607. $result = trim($this->commandResult);
  31608. return $result;
  31609. }
  31610. public function queryP4Password()
  31611. {
  31612. if (isset($this->p4Password)) {
  31613. return $this->p4Password;
  31614. }
  31615. $password = $this->getP4variable('P4PASSWD');
  31616. if (strlen($password) <= 0) {
  31617. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  31618. }
  31619. $this->p4Password = $password;
  31620. return $password;
  31621. }
  31622. public function generateP4Command($command, $useClient = true)
  31623. {
  31624. $p4Command = 'p4 ';
  31625. $p4Command .= '-u ' . $this->getUser() . ' ';
  31626. if ($useClient) {
  31627. $p4Command .= '-c ' . $this->getClient() . ' ';
  31628. }
  31629. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  31630. return $p4Command;
  31631. }
  31632. public function isLoggedIn()
  31633. {
  31634. $command = $this->generateP4Command('login -s', false);
  31635. $exitCode = $this->executeCommand($command);
  31636. if ($exitCode) {
  31637. $errorOutput = $this->process->getErrorOutput();
  31638. $index = strpos($errorOutput, $this->getUser());
  31639. if ($index === false) {
  31640. $index = strpos($errorOutput, 'p4');
  31641. if ($index === false) {
  31642. return false;
  31643. }
  31644. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  31645. }
  31646. throw new \Exception('Invalid user name: ' . $this->getUser());
  31647. }
  31648. return true;
  31649. }
  31650. public function connectClient()
  31651. {
  31652. $p4CreateClientCommand = $this->generateP4Command(
  31653. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  31654. );
  31655. $this->executeCommand($p4CreateClientCommand);
  31656. }
  31657. public function syncCodeBase($sourceReference)
  31658. {
  31659. $prevDir = getcwd();
  31660. chdir($this->path);
  31661. $p4SyncCommand = $this->generateP4Command('sync -f ');
  31662. if (null !== $sourceReference) {
  31663. $p4SyncCommand .= '@' . $sourceReference;
  31664. }
  31665. $this->executeCommand($p4SyncCommand);
  31666. chdir($prevDir);
  31667. }
  31668. public function writeClientSpecToFile($spec)
  31669. {
  31670. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  31671. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  31672. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  31673. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  31674. fwrite($spec, 'Description:' . PHP_EOL);
  31675. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  31676. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  31677. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  31678. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  31679. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  31680. if ($this->isStream()) {
  31681. fwrite($spec, 'Stream:' . PHP_EOL);
  31682. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  31683. } else {
  31684. fwrite(
  31685. $spec,
  31686. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  31687. );
  31688. }
  31689. }
  31690. public function writeP4ClientSpec()
  31691. {
  31692. $clientSpec = $this->getP4ClientSpec();
  31693. $spec = fopen($clientSpec, 'w');
  31694. try {
  31695. $this->writeClientSpecToFile($spec);
  31696. } catch (\Exception $e) {
  31697. fclose($spec);
  31698. throw $e;
  31699. }
  31700. fclose($spec);
  31701. }
  31702. protected function read($pipe, $name)
  31703. {
  31704. if (feof($pipe)) {
  31705. return;
  31706. }
  31707. $line = fgets($pipe);
  31708. while ($line !== false) {
  31709. $line = fgets($pipe);
  31710. }
  31711. }
  31712. public function windowsLogin($password)
  31713. {
  31714. $command = $this->generateP4Command(' login -a');
  31715. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31716. $process = Process::fromShellCommandline($command, null, null, $password);
  31717. } else {
  31718. $process = new Process($command, null, null, $password);
  31719. }
  31720. return $process->run();
  31721. }
  31722. public function p4Login()
  31723. {
  31724. $this->queryP4User();
  31725. if (!$this->isLoggedIn()) {
  31726. $password = $this->queryP4Password();
  31727. if ($this->windowsFlag) {
  31728. $this->windowsLogin($password);
  31729. } else {
  31730. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  31731. $exitCode = $this->executeCommand($command);
  31732. if ($exitCode) {
  31733. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  31734. }
  31735. }
  31736. }
  31737. }
  31738. public function getComposerInformation($identifier)
  31739. {
  31740. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  31741. if (!$composerFileContent) {
  31742. return;
  31743. }
  31744. return json_decode($composerFileContent, true);
  31745. }
  31746. public function getFileContent($file, $identifier)
  31747. {
  31748. $path = $this->getFilePath($file, $identifier);
  31749. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  31750. $this->executeCommand($command);
  31751. $result = $this->commandResult;
  31752. if (!trim($result)) {
  31753. return null;
  31754. }
  31755. return $result;
  31756. }
  31757. public function getFilePath($file, $identifier)
  31758. {
  31759. $index = strpos($identifier, '@');
  31760. if ($index === false) {
  31761. return $identifier. '/' . $file;
  31762. }
  31763. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  31764. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  31765. $this->executeCommand($command);
  31766. $result = $this->commandResult;
  31767. $index2 = strpos($result, 'no such file(s).');
  31768. if ($index2 === false) {
  31769. $index3 = strpos($result, 'change');
  31770. if ($index3 !== false) {
  31771. $phrase = trim(substr($result, $index3));
  31772. $fields = explode(' ', $phrase);
  31773. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  31774. }
  31775. }
  31776. return null;
  31777. }
  31778. public function getBranches()
  31779. {
  31780. $possibleBranches = array();
  31781. if (!$this->isStream()) {
  31782. $possibleBranches[$this->p4Branch] = $this->getStream();
  31783. } else {
  31784. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  31785. $this->executeCommand($command);
  31786. $result = $this->commandResult;
  31787. $resArray = explode(PHP_EOL, $result);
  31788. foreach ($resArray as $line) {
  31789. $resBits = explode(' ', $line);
  31790. if (count($resBits) > 4) {
  31791. $branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  31792. $possibleBranches[$branch] = $resBits[1];
  31793. }
  31794. }
  31795. }
  31796. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  31797. $this->executeCommand($command);
  31798. $result = $this->commandResult;
  31799. $resArray = explode(PHP_EOL, $result);
  31800. $lastCommit = $resArray[0];
  31801. $lastCommitArr = explode(' ', $lastCommit);
  31802. $lastCommitNum = $lastCommitArr[1];
  31803. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  31804. }
  31805. public function getTags()
  31806. {
  31807. $command = $this->generateP4Command('labels');
  31808. $this->executeCommand($command);
  31809. $result = $this->commandResult;
  31810. $resArray = explode(PHP_EOL, $result);
  31811. $tags = array();
  31812. foreach ($resArray as $line) {
  31813. if (strpos($line, 'Label') !== false) {
  31814. $fields = explode(' ', $line);
  31815. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  31816. }
  31817. }
  31818. return $tags;
  31819. }
  31820. public function checkStream()
  31821. {
  31822. $command = $this->generateP4Command('depots', false);
  31823. $this->executeCommand($command);
  31824. $result = $this->commandResult;
  31825. $resArray = explode(PHP_EOL, $result);
  31826. foreach ($resArray as $line) {
  31827. if (strpos($line, 'Depot') !== false) {
  31828. $fields = explode(' ', $line);
  31829. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  31830. $this->p4DepotType = $fields[3];
  31831. return $this->isStream();
  31832. }
  31833. }
  31834. }
  31835. return false;
  31836. }
  31837. protected function getChangeList($reference)
  31838. {
  31839. $index = strpos($reference, '@');
  31840. if ($index === false) {
  31841. return null;
  31842. }
  31843. $label = substr($reference, $index);
  31844. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  31845. $this->executeCommand($command);
  31846. $changes = $this->commandResult;
  31847. if (strpos($changes, 'Change') !== 0) {
  31848. return null;
  31849. }
  31850. $fields = explode(' ', $changes);
  31851. return $fields[1];
  31852. }
  31853. public function getCommitLogs($fromReference, $toReference)
  31854. {
  31855. $fromChangeList = $this->getChangeList($fromReference);
  31856. if ($fromChangeList === null) {
  31857. return null;
  31858. }
  31859. $toChangeList = $this->getChangeList($toReference);
  31860. if ($toChangeList === null) {
  31861. return null;
  31862. }
  31863. $index = strpos($fromReference, '@');
  31864. $main = substr($fromReference, 0, $index) . '/...';
  31865. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  31866. $this->executeCommand($command);
  31867. return $this->commandResult;
  31868. }
  31869. public function getFilesystem()
  31870. {
  31871. if (empty($this->filesystem)) {
  31872. $this->filesystem = new Filesystem($this->process);
  31873. }
  31874. return $this->filesystem;
  31875. }
  31876. public function setFilesystem(Filesystem $fs)
  31877. {
  31878. $this->filesystem = $fs;
  31879. }
  31880. }
  31881. <?php
  31882. namespace Composer\Util;
  31883. class Platform
  31884. {
  31885. private static $isVirtualBoxGuest = null;
  31886. public static function expandPath($path)
  31887. {
  31888. if (preg_match('#^~[\\/]#', $path)) {
  31889. return self::getUserDirectory() . substr($path, 1);
  31890. }
  31891. return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  31892. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  31893. return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
  31894. }
  31895. return getenv($matches['var']) . $matches['path'];
  31896. }, $path);
  31897. }
  31898. public static function getUserDirectory()
  31899. {
  31900. if (false !== ($home = getenv('HOME'))) {
  31901. return $home;
  31902. }
  31903. if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
  31904. return $home;
  31905. }
  31906. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  31907. $info = posix_getpwuid(posix_getuid());
  31908. return $info['dir'];
  31909. }
  31910. throw new \RuntimeException('Could not determine user directory');
  31911. }
  31912. public static function isWindows()
  31913. {
  31914. return \defined('PHP_WINDOWS_VERSION_BUILD');
  31915. }
  31916. public static function strlen($str)
  31917. {
  31918. static $useMbString = null;
  31919. if (null === $useMbString) {
  31920. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  31921. }
  31922. if ($useMbString) {
  31923. return mb_strlen($str, '8bit');
  31924. }
  31925. return \strlen($str);
  31926. }
  31927. public static function isTty($fd = null)
  31928. {
  31929. if ($fd === null) {
  31930. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  31931. }
  31932. if (in_array(strtoupper(getenv('MSYSTEM') ?: ''), array('MINGW32', 'MINGW64'), true)) {
  31933. return true;
  31934. }
  31935. if (function_exists('stream_isatty')) {
  31936. return stream_isatty($fd);
  31937. }
  31938. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  31939. return true;
  31940. }
  31941. $stat = @fstat($fd);
  31942. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  31943. }
  31944. public static function workaroundFilesystemIssues()
  31945. {
  31946. if (self::isVirtualBoxGuest()) {
  31947. usleep(200000);
  31948. }
  31949. }
  31950. private static function isVirtualBoxGuest()
  31951. {
  31952. if (null === self::$isVirtualBoxGuest) {
  31953. self::$isVirtualBoxGuest = false;
  31954. if (self::isWindows()) {
  31955. return self::$isVirtualBoxGuest;
  31956. }
  31957. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  31958. $processUser = posix_getpwuid(posix_geteuid());
  31959. if ($processUser && $processUser['name'] === 'vagrant') {
  31960. return self::$isVirtualBoxGuest = true;
  31961. }
  31962. }
  31963. if (getenv('COMPOSER_RUNTIME_ENV') === 'virtualbox') {
  31964. return self::$isVirtualBoxGuest = true;
  31965. }
  31966. if (defined('PHP_OS_FAMILY') && PHP_OS_FAMILY === 'Linux') {
  31967. $process = new ProcessExecutor();
  31968. try {
  31969. if (0 === $process->execute('lsmod | grep vboxguest', $ignoredOutput)) {
  31970. return self::$isVirtualBoxGuest = true;
  31971. }
  31972. } catch (\Exception $e) {
  31973. }
  31974. }
  31975. }
  31976. return self::$isVirtualBoxGuest;
  31977. }
  31978. }
  31979. <?php
  31980. namespace Composer\Util;
  31981. use Composer\IO\IOInterface;
  31982. use Symfony\Component\Process\Process;
  31983. use Symfony\Component\Process\ProcessUtils;
  31984. use Symfony\Component\Process\Exception\RuntimeException;
  31985. use React\Promise\Promise;
  31986. class ProcessExecutor
  31987. {
  31988. const STATUS_QUEUED = 1;
  31989. const STATUS_STARTED = 2;
  31990. const STATUS_COMPLETED = 3;
  31991. const STATUS_FAILED = 4;
  31992. const STATUS_ABORTED = 5;
  31993. protected static $timeout = 300;
  31994. protected $captureOutput;
  31995. protected $errorOutput;
  31996. protected $io;
  31997. private $jobs = array();
  31998. private $runningJobs = 0;
  31999. private $maxJobs = 10;
  32000. private $idGen = 0;
  32001. private $allowAsync = false;
  32002. public function __construct(IOInterface $io = null)
  32003. {
  32004. $this->io = $io;
  32005. }
  32006. public function execute($command, &$output = null, $cwd = null)
  32007. {
  32008. if (func_num_args() > 1) {
  32009. return $this->doExecute($command, $cwd, false, $output);
  32010. }
  32011. return $this->doExecute($command, $cwd, false);
  32012. }
  32013. public function executeTty($command, $cwd = null)
  32014. {
  32015. if (Platform::isTty()) {
  32016. return $this->doExecute($command, $cwd, true);
  32017. }
  32018. return $this->doExecute($command, $cwd, false);
  32019. }
  32020. private function doExecute($command, $cwd, $tty, &$output = null)
  32021. {
  32022. if ($this->io && $this->io->isDebug()) {
  32023. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  32024. if (preg_match('{^([a-f0-9]{12,}|gh[a-z]_[a-zA-Z0-9_]+)$}', $m['user'])) {
  32025. return '://***:***@';
  32026. }
  32027. return '://'.$m['user'].':***@';
  32028. }, $command);
  32029. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  32030. $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  32031. }
  32032. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  32033. $cwd = realpath(getcwd());
  32034. }
  32035. if (null !== $cwd && !is_dir($cwd)) {
  32036. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  32037. }
  32038. $this->captureOutput = func_num_args() > 3;
  32039. $this->errorOutput = null;
  32040. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  32041. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  32042. } else {
  32043. $process = new Process($command, $cwd, null, null, static::getTimeout());
  32044. }
  32045. if (!Platform::isWindows() && $tty) {
  32046. try {
  32047. $process->setTty(true);
  32048. } catch (RuntimeException $e) {
  32049. }
  32050. }
  32051. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  32052. $process->run($callback);
  32053. if ($this->captureOutput && !is_callable($output)) {
  32054. $output = $process->getOutput();
  32055. }
  32056. $this->errorOutput = $process->getErrorOutput();
  32057. return $process->getExitCode();
  32058. }
  32059. public function executeAsync($command, $cwd = null)
  32060. {
  32061. if (!$this->allowAsync) {
  32062. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  32063. }
  32064. $job = array(
  32065. 'id' => $this->idGen++,
  32066. 'status' => self::STATUS_QUEUED,
  32067. 'command' => $command,
  32068. 'cwd' => $cwd,
  32069. );
  32070. $resolver = function ($resolve, $reject) use (&$job) {
  32071. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  32072. $job['resolve'] = $resolve;
  32073. $job['reject'] = $reject;
  32074. };
  32075. $self = $this;
  32076. $canceler = function () use (&$job) {
  32077. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  32078. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  32079. }
  32080. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  32081. return;
  32082. }
  32083. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  32084. try {
  32085. if (defined('SIGINT')) {
  32086. $job['process']->signal(SIGINT);
  32087. }
  32088. } catch (\Exception $e) {
  32089. }
  32090. $job['process']->stop(1);
  32091. throw new \RuntimeException('Aborted process');
  32092. };
  32093. $promise = new Promise($resolver, $canceler);
  32094. $promise = $promise->then(function () use (&$job, $self) {
  32095. if ($job['process']->isSuccessful()) {
  32096. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  32097. } else {
  32098. $job['status'] = ProcessExecutor::STATUS_FAILED;
  32099. }
  32100. $self->markJobDone();
  32101. return $job['process'];
  32102. }, function ($e) use (&$job, $self) {
  32103. $job['status'] = ProcessExecutor::STATUS_FAILED;
  32104. $self->markJobDone();
  32105. throw $e;
  32106. });
  32107. $this->jobs[$job['id']] = &$job;
  32108. if ($this->runningJobs < $this->maxJobs) {
  32109. $this->startJob($job['id']);
  32110. }
  32111. return $promise;
  32112. }
  32113. private function startJob($id)
  32114. {
  32115. $job = &$this->jobs[$id];
  32116. if ($job['status'] !== self::STATUS_QUEUED) {
  32117. return;
  32118. }
  32119. $job['status'] = self::STATUS_STARTED;
  32120. $this->runningJobs++;
  32121. $command = $job['command'];
  32122. $cwd = $job['cwd'];
  32123. if ($this->io && $this->io->isDebug()) {
  32124. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  32125. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  32126. return '://***:***@';
  32127. }
  32128. return '://'.$m['user'].':***@';
  32129. }, $command);
  32130. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  32131. $this->io->writeError('Executing async command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  32132. }
  32133. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  32134. $cwd = realpath(getcwd());
  32135. }
  32136. if (null !== $cwd && !is_dir($cwd)) {
  32137. throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
  32138. }
  32139. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  32140. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  32141. } else {
  32142. $process = new Process($command, $cwd, null, null, static::getTimeout());
  32143. }
  32144. $job['process'] = $process;
  32145. $process->start();
  32146. }
  32147. public function wait($index = null)
  32148. {
  32149. while (true) {
  32150. if (!$this->countActiveJobs($index)) {
  32151. return;
  32152. }
  32153. usleep(1000);
  32154. }
  32155. }
  32156. public function enableAsync()
  32157. {
  32158. $this->allowAsync = true;
  32159. }
  32160. public function countActiveJobs($index = null)
  32161. {
  32162. foreach ($this->jobs as $job) {
  32163. if ($job['status'] === self::STATUS_STARTED) {
  32164. if (!$job['process']->isRunning()) {
  32165. call_user_func($job['resolve'], $job['process']);
  32166. }
  32167. }
  32168. if ($this->runningJobs < $this->maxJobs) {
  32169. if ($job['status'] === self::STATUS_QUEUED) {
  32170. $this->startJob($job['id']);
  32171. }
  32172. }
  32173. }
  32174. if (null !== $index) {
  32175. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  32176. }
  32177. $active = 0;
  32178. foreach ($this->jobs as $job) {
  32179. if ($job['status'] < self::STATUS_COMPLETED) {
  32180. $active++;
  32181. } else {
  32182. unset($this->jobs[$job['id']]);
  32183. }
  32184. }
  32185. return $active;
  32186. }
  32187. public function markJobDone()
  32188. {
  32189. $this->runningJobs--;
  32190. }
  32191. public function splitLines($output)
  32192. {
  32193. $output = trim($output);
  32194. return ((string) $output === '') ? array() : preg_split('{\r?\n}', $output);
  32195. }
  32196. public function getErrorOutput()
  32197. {
  32198. return $this->errorOutput;
  32199. }
  32200. public function outputHandler($type, $buffer)
  32201. {
  32202. if ($this->captureOutput) {
  32203. return;
  32204. }
  32205. if (null === $this->io) {
  32206. echo $buffer;
  32207. return;
  32208. }
  32209. if (Process::ERR === $type) {
  32210. $this->io->writeErrorRaw($buffer, false);
  32211. } else {
  32212. $this->io->writeRaw($buffer, false);
  32213. }
  32214. }
  32215. public static function getTimeout()
  32216. {
  32217. return static::$timeout;
  32218. }
  32219. public static function setTimeout($timeout)
  32220. {
  32221. static::$timeout = $timeout;
  32222. }
  32223. public static function escape($argument)
  32224. {
  32225. return self::escapeArgument($argument);
  32226. }
  32227. private static function escapeArgument($argument)
  32228. {
  32229. if ('\\' === DIRECTORY_SEPARATOR) {
  32230. if ((string) $argument === '') {
  32231. return escapeshellarg($argument);
  32232. }
  32233. $escapedArgument = '';
  32234. $quote = false;
  32235. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  32236. if ('"' === $part) {
  32237. $escapedArgument .= '\\"';
  32238. } elseif (self::isSurroundedBy($part, '%')) {
  32239. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  32240. } else {
  32241. if ('\\' === substr($part, -1)) {
  32242. $part .= '\\';
  32243. }
  32244. $quote = true;
  32245. $escapedArgument .= $part;
  32246. }
  32247. }
  32248. if ($quote) {
  32249. $escapedArgument = '"'.$escapedArgument.'"';
  32250. }
  32251. return $escapedArgument;
  32252. }
  32253. return "'".str_replace("'", "'\\''", $argument)."'";
  32254. }
  32255. private static function isSurroundedBy($arg, $char)
  32256. {
  32257. return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
  32258. }
  32259. }
  32260. <?php
  32261. namespace Composer\Util;
  32262. use Composer\Config;
  32263. use Composer\Downloader\MaxFileSizeExceededException;
  32264. use Composer\IO\IOInterface;
  32265. use Composer\Downloader\TransportException;
  32266. use Composer\CaBundle\CaBundle;
  32267. use Composer\Util\Http\Response;
  32268. use Composer\Util\Http\ProxyManager;
  32269. class RemoteFilesystem
  32270. {
  32271. private $io;
  32272. private $config;
  32273. private $scheme;
  32274. private $bytesMax;
  32275. private $originUrl;
  32276. private $fileUrl;
  32277. private $fileName;
  32278. private $retry;
  32279. private $progress;
  32280. private $lastProgress;
  32281. private $options = array();
  32282. private $peerCertificateMap = array();
  32283. private $disableTls = false;
  32284. private $lastHeaders;
  32285. private $storeAuth;
  32286. private $authHelper;
  32287. private $degradedMode = false;
  32288. private $redirects;
  32289. private $maxRedirects = 20;
  32290. private $proxyManager;
  32291. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false, AuthHelper $authHelper = null)
  32292. {
  32293. $this->io = $io;
  32294. if ($disableTls === false) {
  32295. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  32296. } else {
  32297. $this->disableTls = true;
  32298. }
  32299. $this->options = array_replace_recursive($this->options, $options);
  32300. $this->config = $config;
  32301. $this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
  32302. $this->proxyManager = ProxyManager::getInstance();
  32303. }
  32304. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  32305. {
  32306. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  32307. }
  32308. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  32309. {
  32310. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  32311. }
  32312. public function getOptions()
  32313. {
  32314. return $this->options;
  32315. }
  32316. public function setOptions(array $options)
  32317. {
  32318. $this->options = array_replace_recursive($this->options, $options);
  32319. }
  32320. public function isTlsDisabled()
  32321. {
  32322. return $this->disableTls === true;
  32323. }
  32324. public function getLastHeaders()
  32325. {
  32326. return $this->lastHeaders;
  32327. }
  32328. public static function findStatusCode(array $headers)
  32329. {
  32330. $value = null;
  32331. foreach ($headers as $header) {
  32332. if (preg_match('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  32333. $value = (int) $match[1];
  32334. }
  32335. }
  32336. return $value;
  32337. }
  32338. public function findStatusMessage(array $headers)
  32339. {
  32340. $value = null;
  32341. foreach ($headers as $header) {
  32342. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  32343. $value = $header;
  32344. }
  32345. }
  32346. return $value;
  32347. }
  32348. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  32349. {
  32350. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  32351. $this->bytesMax = 0;
  32352. $this->originUrl = $originUrl;
  32353. $this->fileUrl = $fileUrl;
  32354. $this->fileName = $fileName;
  32355. $this->progress = $progress;
  32356. $this->lastProgress = null;
  32357. $retryAuthFailure = true;
  32358. $this->lastHeaders = array();
  32359. $this->redirects = 1;
  32360. $tempAdditionalOptions = $additionalOptions;
  32361. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  32362. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  32363. unset($tempAdditionalOptions['retry-auth-failure']);
  32364. }
  32365. $isRedirect = false;
  32366. if (isset($tempAdditionalOptions['redirects'])) {
  32367. $this->redirects = $tempAdditionalOptions['redirects'];
  32368. $isRedirect = true;
  32369. unset($tempAdditionalOptions['redirects']);
  32370. }
  32371. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  32372. unset($tempAdditionalOptions);
  32373. $origFileUrl = $fileUrl;
  32374. if (isset($options['gitlab-token'])) {
  32375. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  32376. unset($options['gitlab-token']);
  32377. }
  32378. if (isset($options['http'])) {
  32379. $options['http']['ignore_errors'] = true;
  32380. }
  32381. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  32382. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  32383. $degradedPackagist = true;
  32384. }
  32385. $maxFileSize = null;
  32386. if (isset($options['max_file_size'])) {
  32387. $maxFileSize = $options['max_file_size'];
  32388. unset($options['max_file_size']);
  32389. }
  32390. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  32391. $proxy = $this->proxyManager->getProxyForRequest($fileUrl);
  32392. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  32393. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  32394. unset($origFileUrl, $proxy, $usingProxy);
  32395. if ((!preg_match('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
  32396. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  32397. }
  32398. if ($this->progress && !$isRedirect) {
  32399. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  32400. }
  32401. $errorMessage = '';
  32402. $errorCode = 0;
  32403. $result = false;
  32404. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32405. if ($errorMessage) {
  32406. $errorMessage .= "\n";
  32407. }
  32408. $errorMessage .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg);
  32409. return true;
  32410. });
  32411. $http_response_header = array();
  32412. try {
  32413. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  32414. if (!empty($http_response_header[0])) {
  32415. $statusCode = self::findStatusCode($http_response_header);
  32416. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  32417. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  32418. }
  32419. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  32420. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  32421. }
  32422. }
  32423. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  32424. if ($contentLength && Platform::strlen($result) < $contentLength) {
  32425. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  32426. $e->setHeaders($http_response_header);
  32427. $e->setStatusCode(self::findStatusCode($http_response_header));
  32428. try {
  32429. $e->setResponse($this->decodeResult($result, $http_response_header));
  32430. } catch (\Exception $e) {
  32431. $e->setResponse($result);
  32432. }
  32433. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  32434. throw $e;
  32435. }
  32436. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  32437. $params = stream_context_get_params($ctx);
  32438. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  32439. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  32440. if ($expectedPeerFingerprint !== $peerFingerprint) {
  32441. throw new TransportException('Peer fingerprint did not match');
  32442. }
  32443. }
  32444. } catch (\Exception $e) {
  32445. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  32446. $e->setHeaders($http_response_header);
  32447. $e->setStatusCode(self::findStatusCode($http_response_header));
  32448. }
  32449. if ($e instanceof TransportException && $result !== false) {
  32450. $e->setResponse($this->decodeResult($result, $http_response_header));
  32451. }
  32452. $result = false;
  32453. }
  32454. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  32455. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  32456. }
  32457. restore_error_handler();
  32458. if (isset($e) && !$this->retry) {
  32459. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32460. $this->degradedMode = true;
  32461. $this->io->writeError('');
  32462. $this->io->writeError(array(
  32463. '<error>'.$e->getMessage().'</error>',
  32464. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32465. ));
  32466. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32467. }
  32468. throw $e;
  32469. }
  32470. $statusCode = null;
  32471. $contentType = null;
  32472. $locationHeader = null;
  32473. if (!empty($http_response_header[0])) {
  32474. $statusCode = self::findStatusCode($http_response_header);
  32475. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  32476. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  32477. }
  32478. if ($originUrl === 'bitbucket.org'
  32479. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  32480. && substr($fileUrl, -4) === '.zip'
  32481. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  32482. && $contentType && preg_match('{^text/html\b}i', $contentType)
  32483. ) {
  32484. $result = false;
  32485. if ($retryAuthFailure) {
  32486. $this->promptAuthAndRetry(401);
  32487. }
  32488. }
  32489. if ($statusCode === 404
  32490. && $this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  32491. && false !== strpos($fileUrl, 'archive.zip')
  32492. ) {
  32493. $result = false;
  32494. if ($retryAuthFailure) {
  32495. $this->promptAuthAndRetry(401);
  32496. }
  32497. }
  32498. $hasFollowedRedirect = false;
  32499. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  32500. $hasFollowedRedirect = true;
  32501. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  32502. }
  32503. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  32504. if (!$this->retry) {
  32505. if ($this->progress && !$isRedirect) {
  32506. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  32507. }
  32508. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  32509. $e->setHeaders($http_response_header);
  32510. $e->setResponse($this->decodeResult($result, $http_response_header));
  32511. $e->setStatusCode($statusCode);
  32512. throw $e;
  32513. }
  32514. $result = false;
  32515. }
  32516. if ($this->progress && !$this->retry && !$isRedirect) {
  32517. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  32518. }
  32519. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  32520. try {
  32521. $result = $this->decodeResult($result, $http_response_header);
  32522. } catch (\Exception $e) {
  32523. if ($this->degradedMode) {
  32524. throw $e;
  32525. }
  32526. $this->degradedMode = true;
  32527. $this->io->writeError(array(
  32528. '',
  32529. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  32530. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32531. ));
  32532. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32533. }
  32534. }
  32535. if (false !== $result && null !== $fileName && !$isRedirect) {
  32536. if ('' === $result) {
  32537. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  32538. }
  32539. $errorMessage = '';
  32540. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32541. if ($errorMessage) {
  32542. $errorMessage .= "\n";
  32543. }
  32544. $errorMessage .= preg_replace('{^file_put_contents\(.*?\): }', '', $msg);
  32545. return true;
  32546. });
  32547. $result = (bool) file_put_contents($fileName, $result);
  32548. restore_error_handler();
  32549. if (false === $result) {
  32550. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  32551. }
  32552. }
  32553. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  32554. if (CaBundle::isOpensslParseSafe()) {
  32555. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  32556. if ($certDetails) {
  32557. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  32558. $this->retry = true;
  32559. }
  32560. } else {
  32561. $this->io->writeError('');
  32562. $this->io->writeError(sprintf(
  32563. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  32564. PHP_VERSION
  32565. ));
  32566. }
  32567. }
  32568. if ($this->retry) {
  32569. $this->retry = false;
  32570. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32571. if ($this->storeAuth && $this->config) {
  32572. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  32573. $this->storeAuth = false;
  32574. }
  32575. return $result;
  32576. }
  32577. if (false === $result) {
  32578. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  32579. if (!empty($http_response_header[0])) {
  32580. $e->setHeaders($http_response_header);
  32581. }
  32582. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32583. $this->degradedMode = true;
  32584. $this->io->writeError('');
  32585. $this->io->writeError(array(
  32586. '<error>'.$e->getMessage().'</error>',
  32587. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32588. ));
  32589. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32590. }
  32591. throw $e;
  32592. }
  32593. if (!empty($http_response_header[0])) {
  32594. $this->lastHeaders = $http_response_header;
  32595. }
  32596. return $result;
  32597. }
  32598. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null, $maxFileSize = null)
  32599. {
  32600. $result = false;
  32601. try {
  32602. $e = null;
  32603. if ($maxFileSize !== null) {
  32604. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  32605. } else {
  32606. $result = file_get_contents($fileUrl, false, $context);
  32607. }
  32608. } catch (\Throwable $e) {
  32609. } catch (\Exception $e) {
  32610. }
  32611. if ($maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  32612. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  32613. }
  32614. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  32615. if (null !== $e) {
  32616. throw $e;
  32617. }
  32618. return $result;
  32619. }
  32620. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  32621. {
  32622. switch ($notificationCode) {
  32623. case STREAM_NOTIFY_FAILURE:
  32624. if (400 === $messageCode) {
  32625. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  32626. }
  32627. break;
  32628. case STREAM_NOTIFY_FILE_SIZE_IS:
  32629. $this->bytesMax = $bytesMax;
  32630. break;
  32631. case STREAM_NOTIFY_PROGRESS:
  32632. if ($this->bytesMax > 0 && $this->progress) {
  32633. $progression = min(100, round($bytesTransferred / $this->bytesMax * 100));
  32634. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  32635. $this->lastProgress = $progression;
  32636. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  32637. }
  32638. }
  32639. break;
  32640. default:
  32641. break;
  32642. }
  32643. }
  32644. protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
  32645. {
  32646. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  32647. $this->storeAuth = $result['storeAuth'];
  32648. $this->retry = $result['retry'];
  32649. if ($this->retry) {
  32650. throw new TransportException('RETRY');
  32651. }
  32652. }
  32653. protected function getOptionsForUrl($originUrl, $additionalOptions)
  32654. {
  32655. $tlsOptions = array();
  32656. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  32657. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  32658. if (PHP_VERSION_ID < 50304) {
  32659. if ($host === 'github.com' || $host === 'api.github.com') {
  32660. $host = '*.github.com';
  32661. }
  32662. }
  32663. $tlsOptions['ssl']['CN_match'] = $host;
  32664. $tlsOptions['ssl']['SNI_server_name'] = $host;
  32665. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  32666. if (isset($this->peerCertificateMap[$urlAuthority])) {
  32667. $certMap = $this->peerCertificateMap[$urlAuthority];
  32668. $this->io->writeError('', true, IOInterface::DEBUG);
  32669. $this->io->writeError(sprintf(
  32670. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  32671. $certMap['cn'],
  32672. $urlAuthority
  32673. ), true, IOInterface::DEBUG);
  32674. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  32675. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  32676. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  32677. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  32678. }
  32679. }
  32680. $headers = array();
  32681. if (extension_loaded('zlib')) {
  32682. $headers[] = 'Accept-Encoding: gzip';
  32683. }
  32684. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  32685. if (!$this->degradedMode) {
  32686. $options['http']['protocol_version'] = 1.1;
  32687. $headers[] = 'Connection: close';
  32688. }
  32689. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  32690. $options['http']['follow_location'] = 0;
  32691. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  32692. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  32693. }
  32694. foreach ($headers as $header) {
  32695. $options['http']['header'][] = $header;
  32696. }
  32697. return $options;
  32698. }
  32699. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  32700. {
  32701. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  32702. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  32703. $targetUrl = $locationHeader;
  32704. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  32705. $targetUrl = $this->scheme.':'.$locationHeader;
  32706. } elseif ('/' === $locationHeader[0]) {
  32707. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  32708. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32709. } else {
  32710. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32711. }
  32712. }
  32713. if (!empty($targetUrl)) {
  32714. $this->redirects++;
  32715. $this->io->writeError('', true, IOInterface::DEBUG);
  32716. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  32717. $additionalOptions['redirects'] = $this->redirects;
  32718. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  32719. }
  32720. if (!$this->retry) {
  32721. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  32722. $e->setHeaders($http_response_header);
  32723. $e->setResponse($this->decodeResult($result, $http_response_header));
  32724. throw $e;
  32725. }
  32726. return false;
  32727. }
  32728. private function getCertificateCnAndFp($url, $options)
  32729. {
  32730. if (PHP_VERSION_ID >= 50600) {
  32731. throw new \BadMethodCallException(sprintf(
  32732. '%s must not be used on PHP >= 5.6',
  32733. __METHOD__
  32734. ));
  32735. }
  32736. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  32737. 'ssl' => array(
  32738. 'capture_peer_cert' => true,
  32739. 'verify_peer' => false,
  32740. ), ),
  32741. ));
  32742. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  32743. return;
  32744. }
  32745. fclose($handle);
  32746. $handle = null;
  32747. $params = stream_context_get_params($context);
  32748. if (!empty($params['options']['ssl']['peer_certificate'])) {
  32749. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  32750. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  32751. return array(
  32752. 'cn' => $commonName,
  32753. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  32754. );
  32755. }
  32756. }
  32757. }
  32758. private function getUrlAuthority($url)
  32759. {
  32760. $defaultPorts = array(
  32761. 'ftp' => 21,
  32762. 'http' => 80,
  32763. 'https' => 443,
  32764. 'ssh2.sftp' => 22,
  32765. 'ssh2.scp' => 22,
  32766. );
  32767. $scheme = parse_url($url, PHP_URL_SCHEME);
  32768. if (!isset($defaultPorts[$scheme])) {
  32769. throw new \InvalidArgumentException(sprintf(
  32770. 'Could not get default port for unknown scheme: %s',
  32771. $scheme
  32772. ));
  32773. }
  32774. $defaultPort = $defaultPorts[$scheme];
  32775. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  32776. return parse_url($url, PHP_URL_HOST).':'.$port;
  32777. }
  32778. private function decodeResult($result, $http_response_header)
  32779. {
  32780. if ($result && extension_loaded('zlib')) {
  32781. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  32782. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  32783. if ($decode) {
  32784. if (PHP_VERSION_ID >= 50400) {
  32785. $result = zlib_decode($result);
  32786. } else {
  32787. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  32788. }
  32789. if ($result === false) {
  32790. throw new TransportException('Failed to decode zlib stream');
  32791. }
  32792. }
  32793. }
  32794. return $result;
  32795. }
  32796. }
  32797. <?php
  32798. namespace Composer\Util;
  32799. class Silencer
  32800. {
  32801. private static $stack = array();
  32802. public static function suppress($mask = null)
  32803. {
  32804. if (!isset($mask)) {
  32805. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  32806. }
  32807. $old = error_reporting();
  32808. self::$stack[] = $old;
  32809. error_reporting($old & ~$mask);
  32810. return $old;
  32811. }
  32812. public static function restore()
  32813. {
  32814. if (!empty(self::$stack)) {
  32815. error_reporting(array_pop(self::$stack));
  32816. }
  32817. }
  32818. public static function call($callable )
  32819. {
  32820. try {
  32821. self::suppress();
  32822. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  32823. self::restore();
  32824. return $result;
  32825. } catch (\Exception $e) {
  32826. self::restore();
  32827. throw $e;
  32828. }
  32829. }
  32830. }
  32831. <?php
  32832. namespace Composer\Util;
  32833. use Composer\Composer;
  32834. use Composer\CaBundle\CaBundle;
  32835. use Composer\Downloader\TransportException;
  32836. use Composer\Util\Http\ProxyManager;
  32837. use Psr\Log\LoggerInterface;
  32838. final class StreamContextFactory
  32839. {
  32840. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  32841. {
  32842. $options = array('http' => array(
  32843. 'follow_location' => 1,
  32844. 'max_redirects' => 20,
  32845. ));
  32846. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  32847. unset($defaultOptions['http']['header']);
  32848. $options = array_replace_recursive($options, $defaultOptions);
  32849. if (isset($options['http']['header'])) {
  32850. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  32851. }
  32852. return stream_context_create($options, $defaultParams);
  32853. }
  32854. public static function initOptions($url, array $options, $forCurl = false)
  32855. {
  32856. if (!isset($options['http']['header'])) {
  32857. $options['http']['header'] = array();
  32858. }
  32859. if (is_string($options['http']['header'])) {
  32860. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  32861. }
  32862. if (!$forCurl) {
  32863. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  32864. if ($proxyOptions = $proxy->getContextOptions()) {
  32865. $isHttpsRequest = 0 === strpos($url, 'https://');
  32866. if ($proxy->isSecure()) {
  32867. if (!extension_loaded('openssl')) {
  32868. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  32869. }
  32870. if ($isHttpsRequest) {
  32871. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  32872. }
  32873. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  32874. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  32875. }
  32876. if (isset($proxyOptions['http']['header'])) {
  32877. $options['http']['header'][] = $proxyOptions['http']['header'];
  32878. unset($proxyOptions['http']['header']);
  32879. }
  32880. $options = array_replace_recursive($options, $proxyOptions);
  32881. }
  32882. }
  32883. if (defined('HHVM_VERSION')) {
  32884. $phpVersion = 'HHVM ' . HHVM_VERSION;
  32885. } else {
  32886. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  32887. }
  32888. if ($forCurl) {
  32889. $curl = curl_version();
  32890. $httpVersion = 'cURL '.$curl['version'];
  32891. } else {
  32892. $httpVersion = 'streams';
  32893. }
  32894. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  32895. $options['http']['header'][] = sprintf(
  32896. 'User-Agent: Composer/%s (%s; %s; %s; %s%s)',
  32897. Composer::getVersion(),
  32898. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  32899. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  32900. $phpVersion,
  32901. $httpVersion,
  32902. getenv('CI') ? '; CI' : ''
  32903. );
  32904. }
  32905. return $options;
  32906. }
  32907. public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
  32908. {
  32909. $ciphers = implode(':', array(
  32910. 'ECDHE-RSA-AES128-GCM-SHA256',
  32911. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  32912. 'ECDHE-RSA-AES256-GCM-SHA384',
  32913. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  32914. 'DHE-RSA-AES128-GCM-SHA256',
  32915. 'DHE-DSS-AES128-GCM-SHA256',
  32916. 'kEDH+AESGCM',
  32917. 'ECDHE-RSA-AES128-SHA256',
  32918. 'ECDHE-ECDSA-AES128-SHA256',
  32919. 'ECDHE-RSA-AES128-SHA',
  32920. 'ECDHE-ECDSA-AES128-SHA',
  32921. 'ECDHE-RSA-AES256-SHA384',
  32922. 'ECDHE-ECDSA-AES256-SHA384',
  32923. 'ECDHE-RSA-AES256-SHA',
  32924. 'ECDHE-ECDSA-AES256-SHA',
  32925. 'DHE-RSA-AES128-SHA256',
  32926. 'DHE-RSA-AES128-SHA',
  32927. 'DHE-DSS-AES128-SHA256',
  32928. 'DHE-RSA-AES256-SHA256',
  32929. 'DHE-DSS-AES256-SHA',
  32930. 'DHE-RSA-AES256-SHA',
  32931. 'AES128-GCM-SHA256',
  32932. 'AES256-GCM-SHA384',
  32933. 'AES128-SHA256',
  32934. 'AES256-SHA256',
  32935. 'AES128-SHA',
  32936. 'AES256-SHA',
  32937. 'AES',
  32938. 'CAMELLIA',
  32939. 'DES-CBC3-SHA',
  32940. '!aNULL',
  32941. '!eNULL',
  32942. '!EXPORT',
  32943. '!DES',
  32944. '!RC4',
  32945. '!MD5',
  32946. '!PSK',
  32947. '!aECDH',
  32948. '!EDH-DSS-DES-CBC3-SHA',
  32949. '!EDH-RSA-DES-CBC3-SHA',
  32950. '!KRB5-DES-CBC3-SHA',
  32951. ));
  32952. $defaults = array(
  32953. 'ssl' => array(
  32954. 'ciphers' => $ciphers,
  32955. 'verify_peer' => true,
  32956. 'verify_depth' => 7,
  32957. 'SNI_enabled' => true,
  32958. 'capture_peer_cert' => true,
  32959. ),
  32960. );
  32961. if (isset($options['ssl'])) {
  32962. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  32963. }
  32964. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  32965. $result = CaBundle::getSystemCaRootBundlePath($logger);
  32966. if (is_dir($result)) {
  32967. $defaults['ssl']['capath'] = $result;
  32968. } else {
  32969. $defaults['ssl']['cafile'] = $result;
  32970. }
  32971. }
  32972. if (isset($defaults['ssl']['cafile']) && (!is_readable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  32973. throw new TransportException('The configured cafile was not valid or could not be read.');
  32974. }
  32975. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !is_readable($defaults['ssl']['capath']))) {
  32976. throw new TransportException('The configured capath was not valid or could not be read.');
  32977. }
  32978. if (PHP_VERSION_ID >= 50413) {
  32979. $defaults['ssl']['disable_compression'] = true;
  32980. }
  32981. return $defaults;
  32982. }
  32983. private static function fixHttpHeaderField($header)
  32984. {
  32985. if (!is_array($header)) {
  32986. $header = explode("\r\n", $header);
  32987. }
  32988. uasort($header, function ($el) {
  32989. return stripos($el, 'content-type') === 0 ? 1 : -1;
  32990. });
  32991. return $header;
  32992. }
  32993. }
  32994. <?php
  32995. namespace Composer\Util;
  32996. use Composer\Config;
  32997. use Composer\IO\IOInterface;
  32998. class Svn
  32999. {
  33000. const MAX_QTY_AUTH_TRIES = 5;
  33001. protected $credentials;
  33002. protected $hasAuth;
  33003. protected $io;
  33004. protected $url;
  33005. protected $cacheCredentials = true;
  33006. protected $process;
  33007. protected $qtyAuthTries = 0;
  33008. protected $config;
  33009. private static $version;
  33010. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  33011. {
  33012. $this->url = $url;
  33013. $this->io = $io;
  33014. $this->config = $config;
  33015. $this->process = $process ?: new ProcessExecutor($io);
  33016. }
  33017. public static function cleanEnv()
  33018. {
  33019. putenv("DYLD_LIBRARY_PATH");
  33020. unset($_SERVER['DYLD_LIBRARY_PATH']);
  33021. }
  33022. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  33023. {
  33024. $this->config->prohibitUrlByConfig($url, $this->io);
  33025. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  33026. }
  33027. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  33028. {
  33029. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  33030. }
  33031. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  33032. {
  33033. $command = $this->getCommand($svnCommand, $url, $path);
  33034. $output = null;
  33035. $io = $this->io;
  33036. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  33037. if ($type !== 'out') {
  33038. return;
  33039. }
  33040. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  33041. return;
  33042. }
  33043. $output .= $buffer;
  33044. if ($verbose) {
  33045. $io->writeError($buffer, false);
  33046. }
  33047. };
  33048. $status = $this->process->execute($command, $handler, $cwd);
  33049. if (0 === $status) {
  33050. return $output;
  33051. }
  33052. $errorOutput = $this->process->getErrorOutput();
  33053. $fullOutput = implode("\n", array($output, $errorOutput));
  33054. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  33055. && false === stripos($fullOutput, 'authorization failed')
  33056. && false === stripos($fullOutput, 'svn: E170001:')
  33057. && false === stripos($fullOutput, 'svn: E215004:')) {
  33058. throw new \RuntimeException($fullOutput);
  33059. }
  33060. if (!$this->hasAuth()) {
  33061. $this->doAuthDance();
  33062. }
  33063. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  33064. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  33065. }
  33066. throw new \RuntimeException(
  33067. 'wrong credentials provided ('.$fullOutput.')'
  33068. );
  33069. }
  33070. public function setCacheCredentials($cacheCredentials)
  33071. {
  33072. $this->cacheCredentials = $cacheCredentials;
  33073. }
  33074. protected function doAuthDance()
  33075. {
  33076. if (!$this->io->isInteractive()) {
  33077. throw new \RuntimeException(
  33078. 'can not ask for authentication in non interactive mode'
  33079. );
  33080. }
  33081. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  33082. $this->hasAuth = true;
  33083. $this->credentials['username'] = $this->io->ask("Username: ");
  33084. $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
  33085. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  33086. return $this;
  33087. }
  33088. protected function getCommand($cmd, $url, $path = null)
  33089. {
  33090. $cmd = sprintf(
  33091. '%s %s%s -- %s',
  33092. $cmd,
  33093. '--non-interactive ',
  33094. $this->getCredentialString(),
  33095. ProcessExecutor::escape($url)
  33096. );
  33097. if ($path) {
  33098. $cmd .= ' ' . ProcessExecutor::escape($path);
  33099. }
  33100. return $cmd;
  33101. }
  33102. protected function getCredentialString()
  33103. {
  33104. if (!$this->hasAuth()) {
  33105. return '';
  33106. }
  33107. return sprintf(
  33108. ' %s--username %s --password %s ',
  33109. $this->getAuthCache(),
  33110. ProcessExecutor::escape($this->getUsername()),
  33111. ProcessExecutor::escape($this->getPassword())
  33112. );
  33113. }
  33114. protected function getPassword()
  33115. {
  33116. if ($this->credentials === null) {
  33117. throw new \LogicException("No svn auth detected.");
  33118. }
  33119. return isset($this->credentials['password']) ? $this->credentials['password'] : '';
  33120. }
  33121. protected function getUsername()
  33122. {
  33123. if ($this->credentials === null) {
  33124. throw new \LogicException("No svn auth detected.");
  33125. }
  33126. return $this->credentials['username'];
  33127. }
  33128. protected function hasAuth()
  33129. {
  33130. if (null !== $this->hasAuth) {
  33131. return $this->hasAuth;
  33132. }
  33133. if (false === $this->createAuthFromConfig()) {
  33134. $this->createAuthFromUrl();
  33135. }
  33136. return (bool) $this->hasAuth;
  33137. }
  33138. protected function getAuthCache()
  33139. {
  33140. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  33141. }
  33142. private function createAuthFromConfig()
  33143. {
  33144. if (!$this->config->has('http-basic')) {
  33145. return $this->hasAuth = false;
  33146. }
  33147. $authConfig = $this->config->get('http-basic');
  33148. $host = parse_url($this->url, PHP_URL_HOST);
  33149. if (isset($authConfig[$host])) {
  33150. $this->credentials['username'] = $authConfig[$host]['username'];
  33151. $this->credentials['password'] = $authConfig[$host]['password'];
  33152. return $this->hasAuth = true;
  33153. }
  33154. return $this->hasAuth = false;
  33155. }
  33156. private function createAuthFromUrl()
  33157. {
  33158. $uri = parse_url($this->url);
  33159. if (empty($uri['user'])) {
  33160. return $this->hasAuth = false;
  33161. }
  33162. $this->credentials['username'] = $uri['user'];
  33163. if (!empty($uri['pass'])) {
  33164. $this->credentials['password'] = $uri['pass'];
  33165. }
  33166. return $this->hasAuth = true;
  33167. }
  33168. public function binaryVersion()
  33169. {
  33170. if (!self::$version) {
  33171. if (0 === $this->process->execute('svn --version', $output)) {
  33172. if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
  33173. self::$version = $match[1];
  33174. }
  33175. }
  33176. }
  33177. return self::$version;
  33178. }
  33179. }
  33180. <?php
  33181. namespace Composer\Util;
  33182. use Composer\Downloader\DownloaderInterface;
  33183. use Composer\Package\PackageInterface;
  33184. use React\Promise\PromiseInterface;
  33185. class SyncHelper
  33186. {
  33187. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, $path, PackageInterface $package, PackageInterface $prevPackage = null)
  33188. {
  33189. $type = $prevPackage ? 'update' : 'install';
  33190. try {
  33191. self::await($loop, $downloader->download($package, $path, $prevPackage));
  33192. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  33193. if ($type === 'update') {
  33194. self::await($loop, $downloader->update($package, $path, $prevPackage));
  33195. } else {
  33196. self::await($loop, $downloader->install($package, $path, $prevPackage));
  33197. }
  33198. } catch (\Exception $e) {
  33199. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  33200. throw $e;
  33201. }
  33202. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  33203. }
  33204. public static function await(Loop $loop, PromiseInterface $promise = null)
  33205. {
  33206. if ($promise) {
  33207. $loop->wait(array($promise));
  33208. }
  33209. }
  33210. }
  33211. <?php
  33212. namespace Composer\Util;
  33213. class Tar
  33214. {
  33215. public static function getComposerJson($pathToArchive)
  33216. {
  33217. $phar = new \PharData($pathToArchive);
  33218. if (!$phar->valid()) {
  33219. return null;
  33220. }
  33221. return self::extractComposerJsonFromFolder($phar);
  33222. }
  33223. private static function extractComposerJsonFromFolder(\PharData $phar)
  33224. {
  33225. if (isset($phar['composer.json'])) {
  33226. return $phar['composer.json']->getContent();
  33227. }
  33228. $topLevelPaths = array();
  33229. foreach ($phar as $folderFile) {
  33230. $name = $folderFile->getBasename();
  33231. if ($folderFile->isDir()) {
  33232. $topLevelPaths[$name] = true;
  33233. if (\count($topLevelPaths) > 1) {
  33234. 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)));
  33235. }
  33236. }
  33237. }
  33238. $composerJsonPath = key($topLevelPaths).'/composer.json';
  33239. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  33240. return $phar[$composerJsonPath]->getContent();
  33241. }
  33242. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  33243. }
  33244. }
  33245. <?php
  33246. namespace Composer\Util;
  33247. use Composer\CaBundle\CaBundle;
  33248. final class TlsHelper
  33249. {
  33250. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  33251. {
  33252. $names = self::getCertificateNames($certificate);
  33253. if (empty($names)) {
  33254. return false;
  33255. }
  33256. $combinedNames = array_merge($names['san'], array($names['cn']));
  33257. $hostname = strtolower($hostname);
  33258. foreach ($combinedNames as $certName) {
  33259. $matcher = self::certNameMatcher($certName);
  33260. if ($matcher && $matcher($hostname)) {
  33261. $cn = $names['cn'];
  33262. return true;
  33263. }
  33264. }
  33265. return false;
  33266. }
  33267. public static function getCertificateNames($certificate)
  33268. {
  33269. if (is_array($certificate)) {
  33270. $info = $certificate;
  33271. } elseif (CaBundle::isOpensslParseSafe()) {
  33272. $info = openssl_x509_parse($certificate, false);
  33273. }
  33274. if (!isset($info['subject']['commonName'])) {
  33275. return null;
  33276. }
  33277. $commonName = strtolower($info['subject']['commonName']);
  33278. $subjectAltNames = array();
  33279. if (isset($info['extensions']['subjectAltName'])) {
  33280. $subjectAltNames = preg_split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  33281. $subjectAltNames = array_filter(array_map(function ($name) {
  33282. if (0 === strpos($name, 'DNS:')) {
  33283. return strtolower(ltrim(substr($name, 4)));
  33284. }
  33285. return null;
  33286. }, $subjectAltNames));
  33287. $subjectAltNames = array_values($subjectAltNames);
  33288. }
  33289. return array(
  33290. 'cn' => $commonName,
  33291. 'san' => $subjectAltNames,
  33292. );
  33293. }
  33294. public static function getCertificateFingerprint($certificate)
  33295. {
  33296. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  33297. $pubkeypem = $pubkeydetails['key'];
  33298. $start = '-----BEGIN PUBLIC KEY-----';
  33299. $end = '-----END PUBLIC KEY-----';
  33300. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  33301. $der = base64_decode($pemtrim);
  33302. return sha1($der);
  33303. }
  33304. public static function isOpensslParseSafe()
  33305. {
  33306. return CaBundle::isOpensslParseSafe();
  33307. }
  33308. private static function certNameMatcher($certName)
  33309. {
  33310. $wildcards = substr_count($certName, '*');
  33311. if (0 === $wildcards) {
  33312. return function ($hostname) use ($certName) {
  33313. return $hostname === $certName;
  33314. };
  33315. }
  33316. if (1 === $wildcards) {
  33317. $components = explode('.', $certName);
  33318. if (3 > count($components)) {
  33319. return;
  33320. }
  33321. $firstComponent = $components[0];
  33322. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  33323. return;
  33324. }
  33325. $wildcardRegex = preg_quote($certName);
  33326. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  33327. $wildcardRegex = "{^{$wildcardRegex}$}";
  33328. return function ($hostname) use ($wildcardRegex) {
  33329. return 1 === preg_match($wildcardRegex, $hostname);
  33330. };
  33331. }
  33332. }
  33333. }
  33334. <?php
  33335. namespace Composer\Util;
  33336. use Composer\Config;
  33337. class Url
  33338. {
  33339. public static function updateDistReference(Config $config, $url, $ref)
  33340. {
  33341. $host = parse_url($url, PHP_URL_HOST);
  33342. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  33343. if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  33344. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33345. } elseif (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  33346. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33347. } elseif (preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  33348. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33349. }
  33350. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  33351. if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  33352. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  33353. }
  33354. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  33355. if (preg_match('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  33356. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  33357. }
  33358. } elseif (in_array($host, $config->get('github-domains'), true)) {
  33359. $url = preg_replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  33360. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  33361. $url = preg_replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  33362. }
  33363. return $url;
  33364. }
  33365. public static function getOrigin(Config $config, $url)
  33366. {
  33367. if (0 === strpos($url, 'file://')) {
  33368. return $url;
  33369. }
  33370. $origin = (string) parse_url($url, PHP_URL_HOST);
  33371. if ($port = parse_url($url, PHP_URL_PORT)) {
  33372. $origin .= ':'.$port;
  33373. }
  33374. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  33375. return 'github.com';
  33376. }
  33377. if ($origin === 'repo.packagist.org') {
  33378. return 'packagist.org';
  33379. }
  33380. if ($origin === '') {
  33381. $origin = $url;
  33382. }
  33383. if (
  33384. is_array($config->get('gitlab-domains'))
  33385. && false === strpos($origin, '/')
  33386. && !in_array($origin, $config->get('gitlab-domains'))
  33387. ) {
  33388. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  33389. if (0 === strpos($gitlabDomain, $origin)) {
  33390. return $gitlabDomain;
  33391. }
  33392. }
  33393. }
  33394. return $origin;
  33395. }
  33396. public static function sanitize($url)
  33397. {
  33398. $url = preg_replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  33399. $url = preg_replace_callback('{(?P<prefix>://|^)(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  33400. if (preg_match('{^([a-f0-9]{12,}|g[a-z]\d_[a-zA-Z0-9_]+)$}', $m['user'])) {
  33401. return $m['prefix'].'***:***@';
  33402. }
  33403. return $m['prefix'].$m['user'].':***@';
  33404. }, $url);
  33405. return $url;
  33406. }
  33407. }
  33408. <?php
  33409. namespace Composer\Util;
  33410. class Zip
  33411. {
  33412. public static function getComposerJson($pathToZip)
  33413. {
  33414. if (!extension_loaded('zip')) {
  33415. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  33416. }
  33417. $zip = new \ZipArchive();
  33418. if ($zip->open($pathToZip) !== true) {
  33419. return null;
  33420. }
  33421. if (0 == $zip->numFiles) {
  33422. $zip->close();
  33423. return null;
  33424. }
  33425. $foundFileIndex = self::locateFile($zip, 'composer.json');
  33426. if (false === $foundFileIndex) {
  33427. $zip->close();
  33428. return null;
  33429. }
  33430. $content = null;
  33431. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  33432. $stream = $zip->getStream($configurationFileName);
  33433. if (false !== $stream) {
  33434. $content = stream_get_contents($stream);
  33435. }
  33436. $zip->close();
  33437. return $content;
  33438. }
  33439. private static function locateFile(\ZipArchive $zip, $filename)
  33440. {
  33441. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  33442. return $index;
  33443. }
  33444. $topLevelPaths = array();
  33445. for ($i = 0; $i < $zip->numFiles; $i++) {
  33446. $name = $zip->getNameIndex($i);
  33447. $dirname = dirname($name);
  33448. if (strpos($name, '__MACOSX') !== false) {
  33449. continue;
  33450. }
  33451. if ($dirname === '.') {
  33452. $topLevelPaths[$name] = true;
  33453. if (\count($topLevelPaths) > 1) {
  33454. 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)));
  33455. }
  33456. continue;
  33457. }
  33458. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  33459. $topLevelPaths[$dirname.'/'] = true;
  33460. if (\count($topLevelPaths) > 1) {
  33461. 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)));
  33462. }
  33463. }
  33464. }
  33465. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  33466. return $index;
  33467. }
  33468. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  33469. }
  33470. }
  33471. <?php
  33472. function includeIfExists($file)
  33473. {
  33474. return file_exists($file) ? include $file : false;
  33475. }
  33476. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  33477. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  33478. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  33479. exit(1);
  33480. }
  33481. return $loader;
  33482. <?php
  33483. /*
  33484. * This file is part of Composer.
  33485. *
  33486. * (c) Nils Adermann <naderman@naderman.de>
  33487. * Jordi Boggiano <j.boggiano@seld.be>
  33488. *
  33489. * For the full copyright and license information, please view the LICENSE
  33490. * file that was distributed with this source code.
  33491. */
  33492. namespace Composer\Autoload;
  33493. /**
  33494. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  33495. *
  33496. * $loader = new \Composer\Autoload\ClassLoader();
  33497. *
  33498. * // register classes with namespaces
  33499. * $loader->add('Symfony\Component', __DIR__.'/component');
  33500. * $loader->add('Symfony', __DIR__.'/framework');
  33501. *
  33502. * // activate the autoloader
  33503. * $loader->register();
  33504. *
  33505. * // to enable searching the include path (eg. for PEAR packages)
  33506. * $loader->setUseIncludePath(true);
  33507. *
  33508. * In this example, if you try to use a class in the Symfony\Component
  33509. * namespace or one of its children (Symfony\Component\Console for instance),
  33510. * the autoloader will first look for the class under the component/
  33511. * directory, and it will then fallback to the framework/ directory if not
  33512. * found before giving up.
  33513. *
  33514. * This class is loosely based on the Symfony UniversalClassLoader.
  33515. *
  33516. * @author Fabien Potencier <fabien@symfony.com>
  33517. * @author Jordi Boggiano <j.boggiano@seld.be>
  33518. * @see https://www.php-fig.org/psr/psr-0/
  33519. * @see https://www.php-fig.org/psr/psr-4/
  33520. */
  33521. class ClassLoader
  33522. {
  33523. private $vendorDir;
  33524. // PSR-4
  33525. private $prefixLengthsPsr4 = array();
  33526. private $prefixDirsPsr4 = array();
  33527. private $fallbackDirsPsr4 = array();
  33528. // PSR-0
  33529. private $prefixesPsr0 = array();
  33530. private $fallbackDirsPsr0 = array();
  33531. private $useIncludePath = false;
  33532. private $classMap = array();
  33533. private $classMapAuthoritative = false;
  33534. private $missingClasses = array();
  33535. private $apcuPrefix;
  33536. private static $registeredLoaders = array();
  33537. public function __construct($vendorDir = null)
  33538. {
  33539. $this->vendorDir = $vendorDir;
  33540. }
  33541. public function getPrefixes()
  33542. {
  33543. if (!empty($this->prefixesPsr0)) {
  33544. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  33545. }
  33546. return array();
  33547. }
  33548. public function getPrefixesPsr4()
  33549. {
  33550. return $this->prefixDirsPsr4;
  33551. }
  33552. public function getFallbackDirs()
  33553. {
  33554. return $this->fallbackDirsPsr0;
  33555. }
  33556. public function getFallbackDirsPsr4()
  33557. {
  33558. return $this->fallbackDirsPsr4;
  33559. }
  33560. public function getClassMap()
  33561. {
  33562. return $this->classMap;
  33563. }
  33564. /**
  33565. * @param array $classMap Class to filename map
  33566. */
  33567. public function addClassMap(array $classMap)
  33568. {
  33569. if ($this->classMap) {
  33570. $this->classMap = array_merge($this->classMap, $classMap);
  33571. } else {
  33572. $this->classMap = $classMap;
  33573. }
  33574. }
  33575. /**
  33576. * Registers a set of PSR-0 directories for a given prefix, either
  33577. * appending or prepending to the ones previously set for this prefix.
  33578. *
  33579. * @param string $prefix The prefix
  33580. * @param array|string $paths The PSR-0 root directories
  33581. * @param bool $prepend Whether to prepend the directories
  33582. */
  33583. public function add($prefix, $paths, $prepend = false)
  33584. {
  33585. if (!$prefix) {
  33586. if ($prepend) {
  33587. $this->fallbackDirsPsr0 = array_merge(
  33588. (array) $paths,
  33589. $this->fallbackDirsPsr0
  33590. );
  33591. } else {
  33592. $this->fallbackDirsPsr0 = array_merge(
  33593. $this->fallbackDirsPsr0,
  33594. (array) $paths
  33595. );
  33596. }
  33597. return;
  33598. }
  33599. $first = $prefix[0];
  33600. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  33601. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  33602. return;
  33603. }
  33604. if ($prepend) {
  33605. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33606. (array) $paths,
  33607. $this->prefixesPsr0[$first][$prefix]
  33608. );
  33609. } else {
  33610. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33611. $this->prefixesPsr0[$first][$prefix],
  33612. (array) $paths
  33613. );
  33614. }
  33615. }
  33616. /**
  33617. * Registers a set of PSR-4 directories for a given namespace, either
  33618. * appending or prepending to the ones previously set for this namespace.
  33619. *
  33620. * @param string $prefix The prefix/namespace, with trailing '\\'
  33621. * @param array|string $paths The PSR-4 base directories
  33622. * @param bool $prepend Whether to prepend the directories
  33623. *
  33624. * @throws \InvalidArgumentException
  33625. */
  33626. public function addPsr4($prefix, $paths, $prepend = false)
  33627. {
  33628. if (!$prefix) {
  33629. // Register directories for the root namespace.
  33630. if ($prepend) {
  33631. $this->fallbackDirsPsr4 = array_merge(
  33632. (array) $paths,
  33633. $this->fallbackDirsPsr4
  33634. );
  33635. } else {
  33636. $this->fallbackDirsPsr4 = array_merge(
  33637. $this->fallbackDirsPsr4,
  33638. (array) $paths
  33639. );
  33640. }
  33641. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  33642. // Register directories for a new namespace.
  33643. $length = strlen($prefix);
  33644. if ('\\' !== $prefix[$length - 1]) {
  33645. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33646. }
  33647. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33648. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33649. } elseif ($prepend) {
  33650. // Prepend directories for an already registered namespace.
  33651. $this->prefixDirsPsr4[$prefix] = array_merge(
  33652. (array) $paths,
  33653. $this->prefixDirsPsr4[$prefix]
  33654. );
  33655. } else {
  33656. // Append directories for an already registered namespace.
  33657. $this->prefixDirsPsr4[$prefix] = array_merge(
  33658. $this->prefixDirsPsr4[$prefix],
  33659. (array) $paths
  33660. );
  33661. }
  33662. }
  33663. /**
  33664. * Registers a set of PSR-0 directories for a given prefix,
  33665. * replacing any others previously set for this prefix.
  33666. *
  33667. * @param string $prefix The prefix
  33668. * @param array|string $paths The PSR-0 base directories
  33669. */
  33670. public function set($prefix, $paths)
  33671. {
  33672. if (!$prefix) {
  33673. $this->fallbackDirsPsr0 = (array) $paths;
  33674. } else {
  33675. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  33676. }
  33677. }
  33678. /**
  33679. * Registers a set of PSR-4 directories for a given namespace,
  33680. * replacing any others previously set for this namespace.
  33681. *
  33682. * @param string $prefix The prefix/namespace, with trailing '\\'
  33683. * @param array|string $paths The PSR-4 base directories
  33684. *
  33685. * @throws \InvalidArgumentException
  33686. */
  33687. public function setPsr4($prefix, $paths)
  33688. {
  33689. if (!$prefix) {
  33690. $this->fallbackDirsPsr4 = (array) $paths;
  33691. } else {
  33692. $length = strlen($prefix);
  33693. if ('\\' !== $prefix[$length - 1]) {
  33694. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33695. }
  33696. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33697. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33698. }
  33699. }
  33700. /**
  33701. * Turns on searching the include path for class files.
  33702. *
  33703. * @param bool $useIncludePath
  33704. */
  33705. public function setUseIncludePath($useIncludePath)
  33706. {
  33707. $this->useIncludePath = $useIncludePath;
  33708. }
  33709. /**
  33710. * Can be used to check if the autoloader uses the include path to check
  33711. * for classes.
  33712. *
  33713. * @return bool
  33714. */
  33715. public function getUseIncludePath()
  33716. {
  33717. return $this->useIncludePath;
  33718. }
  33719. /**
  33720. * Turns off searching the prefix and fallback directories for classes
  33721. * that have not been registered with the class map.
  33722. *
  33723. * @param bool $classMapAuthoritative
  33724. */
  33725. public function setClassMapAuthoritative($classMapAuthoritative)
  33726. {
  33727. $this->classMapAuthoritative = $classMapAuthoritative;
  33728. }
  33729. /**
  33730. * Should class lookup fail if not found in the current class map?
  33731. *
  33732. * @return bool
  33733. */
  33734. public function isClassMapAuthoritative()
  33735. {
  33736. return $this->classMapAuthoritative;
  33737. }
  33738. /**
  33739. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  33740. *
  33741. * @param string|null $apcuPrefix
  33742. */
  33743. public function setApcuPrefix($apcuPrefix)
  33744. {
  33745. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  33746. }
  33747. /**
  33748. * The APCu prefix in use, or null if APCu caching is not enabled.
  33749. *
  33750. * @return string|null
  33751. */
  33752. public function getApcuPrefix()
  33753. {
  33754. return $this->apcuPrefix;
  33755. }
  33756. /**
  33757. * Registers this instance as an autoloader.
  33758. *
  33759. * @param bool $prepend Whether to prepend the autoloader or not
  33760. */
  33761. public function register($prepend = false)
  33762. {
  33763. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  33764. if (null === $this->vendorDir) {
  33765. return;
  33766. }
  33767. if ($prepend) {
  33768. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  33769. } else {
  33770. unset(self::$registeredLoaders[$this->vendorDir]);
  33771. self::$registeredLoaders[$this->vendorDir] = $this;
  33772. }
  33773. }
  33774. /**
  33775. * Unregisters this instance as an autoloader.
  33776. */
  33777. public function unregister()
  33778. {
  33779. spl_autoload_unregister(array($this, 'loadClass'));
  33780. if (null !== $this->vendorDir) {
  33781. unset(self::$registeredLoaders[$this->vendorDir]);
  33782. }
  33783. }
  33784. /**
  33785. * Loads the given class or interface.
  33786. *
  33787. * @param string $class The name of the class
  33788. * @return bool|null True if loaded, null otherwise
  33789. */
  33790. public function loadClass($class)
  33791. {
  33792. if ($file = $this->findFile($class)) {
  33793. includeFile($file);
  33794. return true;
  33795. }
  33796. }
  33797. /**
  33798. * Finds the path to the file where the class is defined.
  33799. *
  33800. * @param string $class The name of the class
  33801. *
  33802. * @return string|false The path if found, false otherwise
  33803. */
  33804. public function findFile($class)
  33805. {
  33806. // class map lookup
  33807. if (isset($this->classMap[$class])) {
  33808. return $this->classMap[$class];
  33809. }
  33810. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  33811. return false;
  33812. }
  33813. if (null !== $this->apcuPrefix) {
  33814. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  33815. if ($hit) {
  33816. return $file;
  33817. }
  33818. }
  33819. $file = $this->findFileWithExtension($class, '.php');
  33820. // Search for Hack files if we are running on HHVM
  33821. if (false === $file && defined('HHVM_VERSION')) {
  33822. $file = $this->findFileWithExtension($class, '.hh');
  33823. }
  33824. if (null !== $this->apcuPrefix) {
  33825. apcu_add($this->apcuPrefix.$class, $file);
  33826. }
  33827. if (false === $file) {
  33828. // Remember that this class does not exist.
  33829. $this->missingClasses[$class] = true;
  33830. }
  33831. return $file;
  33832. }
  33833. /**
  33834. * Returns the currently registered loaders indexed by their corresponding vendor directories.
  33835. *
  33836. * @return self[]
  33837. */
  33838. public static function getRegisteredLoaders()
  33839. {
  33840. return self::$registeredLoaders;
  33841. }
  33842. private function findFileWithExtension($class, $ext)
  33843. {
  33844. // PSR-4 lookup
  33845. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  33846. $first = $class[0];
  33847. if (isset($this->prefixLengthsPsr4[$first])) {
  33848. $subPath = $class;
  33849. while (false !== $lastPos = strrpos($subPath, '\\')) {
  33850. $subPath = substr($subPath, 0, $lastPos);
  33851. $search = $subPath . '\\';
  33852. if (isset($this->prefixDirsPsr4[$search])) {
  33853. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  33854. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  33855. if (file_exists($file = $dir . $pathEnd)) {
  33856. return $file;
  33857. }
  33858. }
  33859. }
  33860. }
  33861. }
  33862. // PSR-4 fallback dirs
  33863. foreach ($this->fallbackDirsPsr4 as $dir) {
  33864. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  33865. return $file;
  33866. }
  33867. }
  33868. // PSR-0 lookup
  33869. if (false !== $pos = strrpos($class, '\\')) {
  33870. // namespaced class name
  33871. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  33872. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  33873. } else {
  33874. // PEAR-like class name
  33875. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  33876. }
  33877. if (isset($this->prefixesPsr0[$first])) {
  33878. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  33879. if (0 === strpos($class, $prefix)) {
  33880. foreach ($dirs as $dir) {
  33881. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33882. return $file;
  33883. }
  33884. }
  33885. }
  33886. }
  33887. }
  33888. // PSR-0 fallback dirs
  33889. foreach ($this->fallbackDirsPsr0 as $dir) {
  33890. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33891. return $file;
  33892. }
  33893. }
  33894. // PSR-0 include paths.
  33895. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  33896. return $file;
  33897. }
  33898. return false;
  33899. }
  33900. }
  33901. /**
  33902. * Scope isolated include.
  33903. *
  33904. * Prevents access to $this/self from included files.
  33905. */
  33906. function includeFile($file)
  33907. {
  33908. include $file;
  33909. }
  33910. {
  33911. "$schema": "https://json-schema.org/draft-04/schema#",
  33912. "description": "A representation of packages metadata.",
  33913. "type": "object",
  33914. "oneOf": [
  33915. { "required": [ "packages" ] },
  33916. { "required": [ "providers" ] },
  33917. { "required": [ "provider-includes", "providers-url" ] }
  33918. ],
  33919. "properties": {
  33920. "packages": {
  33921. "type": ["object", "array"],
  33922. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33923. "additionalProperties": { "$ref": "#/definitions/versions" }
  33924. },
  33925. "providers-url": {
  33926. "type": "string",
  33927. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  33928. },
  33929. "provider-includes": {
  33930. "type": "object",
  33931. "description": "A hashmap of provider listings.",
  33932. "additionalProperties": { "$ref": "#/definitions/provider" }
  33933. },
  33934. "providers": {
  33935. "type": "object",
  33936. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33937. "additionalProperties": { "$ref": "#/definitions/provider" }
  33938. },
  33939. "notify-batch": {
  33940. "type": "string",
  33941. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  33942. },
  33943. "search": {
  33944. "type": "string",
  33945. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  33946. },
  33947. "warning": {
  33948. "type": "string",
  33949. "description": "A message that will be output by Composer as a warning when this source is consulted."
  33950. }
  33951. },
  33952. "definitions": {
  33953. "versions": {
  33954. "type": "object",
  33955. "description": "A hashmap of versions and their metadata.",
  33956. "additionalProperties": { "$ref": "#/definitions/version" }
  33957. },
  33958. "version": {
  33959. "type": "object",
  33960. "oneOf": [
  33961. { "$ref": "#/definitions/package" },
  33962. { "$ref": "#/definitions/metapackage" }
  33963. ]
  33964. },
  33965. "package-base": {
  33966. "properties": {
  33967. "name": { "type": "string" },
  33968. "type": { "type": "string" },
  33969. "version": { "type": "string" },
  33970. "version_normalized": {
  33971. "type": "string",
  33972. "description": "Normalized version, optional but can save computational time on client side."
  33973. },
  33974. "autoload": { "type": "object" },
  33975. "require": { "type": "object" },
  33976. "replace": { "type": "object" },
  33977. "conflict": { "type": "object" },
  33978. "provide": { "type": "object" },
  33979. "time": { "type": "string" }
  33980. },
  33981. "additionalProperties": true
  33982. },
  33983. "package": {
  33984. "allOf": [
  33985. { "$ref": "#/definitions/package-base" },
  33986. {
  33987. "properties": {
  33988. "dist": { "type": "object" },
  33989. "source": { "type": "object" }
  33990. }
  33991. },
  33992. { "oneOf": [
  33993. { "required": [ "name", "version", "source" ] },
  33994. { "required": [ "name", "version", "dist" ] }
  33995. ] }
  33996. ]
  33997. },
  33998. "metapackage": {
  33999. "allOf": [
  34000. { "$ref": "#/definitions/package-base" },
  34001. {
  34002. "properties": {
  34003. "type": { "type": "string", "enum": [ "metapackage" ] }
  34004. },
  34005. "required": [ "name", "version", "type" ]
  34006. }
  34007. ]
  34008. },
  34009. "provider": {
  34010. "type": "object",
  34011. "properties": {
  34012. "sha256": {
  34013. "type": "string",
  34014. "description": "Hash value that can be used to validate the resource."
  34015. }
  34016. }
  34017. }
  34018. }
  34019. }
  34020. {
  34021. "$schema": "https://json-schema.org/draft-04/schema#",
  34022. "name": "Package",
  34023. "type": "object",
  34024. "additionalProperties": false,
  34025. "required": [ "name", "description" ],
  34026. "properties": {
  34027. "name": {
  34028. "type": "string",
  34029. "description": "Package name, including 'vendor-name/' prefix.",
  34030. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  34031. },
  34032. "type": {
  34033. "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.",
  34034. "type": "string",
  34035. "pattern": "^[a-z0-9-]+$"
  34036. },
  34037. "target-dir": {
  34038. "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.",
  34039. "type": "string"
  34040. },
  34041. "description": {
  34042. "type": "string",
  34043. "description": "Short package description."
  34044. },
  34045. "keywords": {
  34046. "type": "array",
  34047. "items": {
  34048. "type": "string",
  34049. "description": "A tag/keyword that this package relates to."
  34050. }
  34051. },
  34052. "homepage": {
  34053. "type": "string",
  34054. "description": "Homepage URL for the project.",
  34055. "format": "uri"
  34056. },
  34057. "readme": {
  34058. "type": "string",
  34059. "description": "Relative path to the readme document."
  34060. },
  34061. "version": {
  34062. "type": "string",
  34063. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  34064. "pattern": "^v?\\d+(((\\.\\d+)?\\.\\d+)?\\.\\d+)?|^dev-"
  34065. },
  34066. "time": {
  34067. "type": "string",
  34068. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  34069. },
  34070. "license": {
  34071. "type": ["string", "array"],
  34072. "description": "License name. Or an array of license names."
  34073. },
  34074. "authors": {
  34075. "$ref": "#/definitions/authors"
  34076. },
  34077. "require": {
  34078. "type": "object",
  34079. "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
  34080. "additionalProperties": {
  34081. "type": "string"
  34082. }
  34083. },
  34084. "replace": {
  34085. "type": "object",
  34086. "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
  34087. "additionalProperties": {
  34088. "type": "string"
  34089. }
  34090. },
  34091. "conflict": {
  34092. "type": "object",
  34093. "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
  34094. "additionalProperties": {
  34095. "type": "string"
  34096. }
  34097. },
  34098. "provide": {
  34099. "type": "object",
  34100. "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  34101. "additionalProperties": {
  34102. "type": "string"
  34103. }
  34104. },
  34105. "require-dev": {
  34106. "type": "object",
  34107. "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  34108. "additionalProperties": {
  34109. "type": "string"
  34110. }
  34111. },
  34112. "suggest": {
  34113. "type": "object",
  34114. "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).",
  34115. "additionalProperties": {
  34116. "type": "string"
  34117. }
  34118. },
  34119. "config": {
  34120. "type": "object",
  34121. "description": "Composer options.",
  34122. "properties": {
  34123. "process-timeout": {
  34124. "type": "integer",
  34125. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  34126. },
  34127. "use-include-path": {
  34128. "type": "boolean",
  34129. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  34130. },
  34131. "preferred-install": {
  34132. "type": ["string", "object"],
  34133. "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\"}."
  34134. },
  34135. "notify-on-install": {
  34136. "type": "boolean",
  34137. "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."
  34138. },
  34139. "github-protocols": {
  34140. "type": "array",
  34141. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  34142. "items": {
  34143. "type": "string"
  34144. }
  34145. },
  34146. "github-oauth": {
  34147. "type": "object",
  34148. "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  34149. "additionalProperties": {
  34150. "type": "string"
  34151. }
  34152. },
  34153. "gitlab-oauth": {
  34154. "type": "object",
  34155. "description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  34156. "additionalProperties": {
  34157. "type": "string"
  34158. }
  34159. },
  34160. "gitlab-token": {
  34161. "type": "object",
  34162. "description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  34163. "additionalProperties": {
  34164. "type": "string"
  34165. }
  34166. },
  34167. "bearer": {
  34168. "type": "object",
  34169. "description": "A hash of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  34170. "additionalProperties": {
  34171. "type": "string"
  34172. }
  34173. },
  34174. "disable-tls": {
  34175. "type": "boolean",
  34176. "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."
  34177. },
  34178. "secure-http": {
  34179. "type": "boolean",
  34180. "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."
  34181. },
  34182. "cafile": {
  34183. "type": "string",
  34184. "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."
  34185. },
  34186. "capath": {
  34187. "type": "string",
  34188. "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."
  34189. },
  34190. "http-basic": {
  34191. "type": "object",
  34192. "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  34193. "additionalProperties": {
  34194. "type": "object",
  34195. "required": ["username", "password"],
  34196. "properties": {
  34197. "username": {
  34198. "type": "string",
  34199. "description": "The username used for HTTP Basic authentication"
  34200. },
  34201. "password": {
  34202. "type": "string",
  34203. "description": "The password used for HTTP Basic authentication"
  34204. }
  34205. }
  34206. }
  34207. },
  34208. "store-auths": {
  34209. "type": ["string", "boolean"],
  34210. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  34211. },
  34212. "platform": {
  34213. "type": "object",
  34214. "description": "This is a hash of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  34215. "additionalProperties": {
  34216. "type": "string"
  34217. }
  34218. },
  34219. "vendor-dir": {
  34220. "type": "string",
  34221. "description": "The location where all packages are installed, defaults to \"vendor\"."
  34222. },
  34223. "bin-dir": {
  34224. "type": "string",
  34225. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  34226. },
  34227. "data-dir": {
  34228. "type": "string",
  34229. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  34230. },
  34231. "cache-dir": {
  34232. "type": "string",
  34233. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  34234. },
  34235. "cache-files-dir": {
  34236. "type": "string",
  34237. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  34238. },
  34239. "cache-repo-dir": {
  34240. "type": "string",
  34241. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  34242. },
  34243. "cache-vcs-dir": {
  34244. "type": "string",
  34245. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  34246. },
  34247. "cache-ttl": {
  34248. "type": "integer",
  34249. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  34250. },
  34251. "cache-files-ttl": {
  34252. "type": "integer",
  34253. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  34254. },
  34255. "cache-files-maxsize": {
  34256. "type": ["string", "integer"],
  34257. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  34258. },
  34259. "cache-read-only": {
  34260. "type": ["boolean"],
  34261. "description": "Whether to use the Composer cache in read-only mode."
  34262. },
  34263. "bin-compat": {
  34264. "enum": ["auto", "full"],
  34265. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)."
  34266. },
  34267. "discard-changes": {
  34268. "type": ["string", "boolean"],
  34269. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  34270. },
  34271. "autoloader-suffix": {
  34272. "type": "string",
  34273. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  34274. },
  34275. "optimize-autoloader": {
  34276. "type": "boolean",
  34277. "description": "Always optimize when dumping the autoloader."
  34278. },
  34279. "prepend-autoloader": {
  34280. "type": "boolean",
  34281. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  34282. },
  34283. "classmap-authoritative": {
  34284. "type": "boolean",
  34285. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  34286. },
  34287. "apcu-autoloader": {
  34288. "type": "boolean",
  34289. "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."
  34290. },
  34291. "github-domains": {
  34292. "type": "array",
  34293. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  34294. "items": {
  34295. "type": "string"
  34296. }
  34297. },
  34298. "github-expose-hostname": {
  34299. "type": "boolean",
  34300. "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."
  34301. },
  34302. "gitlab-domains": {
  34303. "type": "array",
  34304. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  34305. "items": {
  34306. "type": "string"
  34307. }
  34308. },
  34309. "use-github-api": {
  34310. "type": "boolean",
  34311. "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."
  34312. },
  34313. "archive-format": {
  34314. "type": "string",
  34315. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  34316. },
  34317. "archive-dir": {
  34318. "type": "string",
  34319. "description": "The default archive path when not provided on cli, defaults to \".\"."
  34320. },
  34321. "htaccess-protect": {
  34322. "type": "boolean",
  34323. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  34324. },
  34325. "sort-packages": {
  34326. "type": "boolean",
  34327. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  34328. },
  34329. "lock": {
  34330. "type": "boolean",
  34331. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  34332. },
  34333. "platform-check": {
  34334. "type": ["boolean", "string"],
  34335. "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."
  34336. }
  34337. }
  34338. },
  34339. "extra": {
  34340. "type": ["object", "array"],
  34341. "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.",
  34342. "additionalProperties": true
  34343. },
  34344. "autoload": {
  34345. "$ref": "#/definitions/autoload"
  34346. },
  34347. "autoload-dev": {
  34348. "type": "object",
  34349. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  34350. "properties": {
  34351. "psr-0": {
  34352. "type": "object",
  34353. "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.",
  34354. "additionalProperties": {
  34355. "type": ["string", "array"],
  34356. "items": {
  34357. "type": "string"
  34358. }
  34359. }
  34360. },
  34361. "psr-4": {
  34362. "type": "object",
  34363. "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.",
  34364. "additionalProperties": {
  34365. "type": ["string", "array"],
  34366. "items": {
  34367. "type": "string"
  34368. }
  34369. }
  34370. },
  34371. "classmap": {
  34372. "type": "array",
  34373. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34374. },
  34375. "files": {
  34376. "type": "array",
  34377. "description": "This is an array of files that are always required on every request."
  34378. }
  34379. }
  34380. },
  34381. "archive": {
  34382. "type": ["object"],
  34383. "description": "Options for creating package archives for distribution.",
  34384. "properties": {
  34385. "name": {
  34386. "type": "string",
  34387. "description": "A base name for archive."
  34388. },
  34389. "exclude": {
  34390. "type": "array",
  34391. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  34392. }
  34393. }
  34394. },
  34395. "repositories": {
  34396. "type": ["object", "array"],
  34397. "description": "A set of additional repositories where packages can be found.",
  34398. "additionalProperties": {
  34399. "anyOf": [
  34400. { "$ref": "#/definitions/repository" },
  34401. { "type": "boolean", "enum": [false] }
  34402. ]
  34403. },
  34404. "items": {
  34405. "anyOf": [
  34406. { "$ref": "#/definitions/repository" },
  34407. {
  34408. "type": "object",
  34409. "additionalProperties": { "type": "boolean", "enum": [false] },
  34410. "minProperties": 1,
  34411. "maxProperties": 1
  34412. }
  34413. ]
  34414. }
  34415. },
  34416. "minimum-stability": {
  34417. "type": ["string"],
  34418. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  34419. "pattern": "^dev|alpha|beta|rc|RC|stable$"
  34420. },
  34421. "prefer-stable": {
  34422. "type": ["boolean"],
  34423. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  34424. },
  34425. "bin": {
  34426. "type": ["string", "array"],
  34427. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34428. "items": {
  34429. "type": "string"
  34430. }
  34431. },
  34432. "include-path": {
  34433. "type": ["array"],
  34434. "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.",
  34435. "items": {
  34436. "type": "string"
  34437. }
  34438. },
  34439. "scripts": {
  34440. "type": ["object"],
  34441. "description": "Script listeners that will be executed before/after some events.",
  34442. "properties": {
  34443. "pre-install-cmd": {
  34444. "type": ["array", "string"],
  34445. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  34446. },
  34447. "post-install-cmd": {
  34448. "type": ["array", "string"],
  34449. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  34450. },
  34451. "pre-update-cmd": {
  34452. "type": ["array", "string"],
  34453. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  34454. },
  34455. "post-update-cmd": {
  34456. "type": ["array", "string"],
  34457. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  34458. },
  34459. "pre-status-cmd": {
  34460. "type": ["array", "string"],
  34461. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  34462. },
  34463. "post-status-cmd": {
  34464. "type": ["array", "string"],
  34465. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  34466. },
  34467. "pre-package-install": {
  34468. "type": ["array", "string"],
  34469. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  34470. },
  34471. "post-package-install": {
  34472. "type": ["array", "string"],
  34473. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  34474. },
  34475. "pre-package-update": {
  34476. "type": ["array", "string"],
  34477. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  34478. },
  34479. "post-package-update": {
  34480. "type": ["array", "string"],
  34481. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  34482. },
  34483. "pre-package-uninstall": {
  34484. "type": ["array", "string"],
  34485. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34486. },
  34487. "post-package-uninstall": {
  34488. "type": ["array", "string"],
  34489. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34490. },
  34491. "pre-autoload-dump": {
  34492. "type": ["array", "string"],
  34493. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34494. },
  34495. "post-autoload-dump": {
  34496. "type": ["array", "string"],
  34497. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34498. },
  34499. "post-root-package-install": {
  34500. "type": ["array", "string"],
  34501. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  34502. },
  34503. "post-create-project-cmd": {
  34504. "type": ["array", "string"],
  34505. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  34506. }
  34507. }
  34508. },
  34509. "scripts-descriptions": {
  34510. "type": ["object"],
  34511. "description": "Descriptions for custom commands, shown in console help.",
  34512. "additionalProperties": {
  34513. "type": "string"
  34514. }
  34515. },
  34516. "support": {
  34517. "type": "object",
  34518. "properties": {
  34519. "email": {
  34520. "type": "string",
  34521. "description": "Email address for support.",
  34522. "format": "email"
  34523. },
  34524. "issues": {
  34525. "type": "string",
  34526. "description": "URL to the issue tracker.",
  34527. "format": "uri"
  34528. },
  34529. "forum": {
  34530. "type": "string",
  34531. "description": "URL to the forum.",
  34532. "format": "uri"
  34533. },
  34534. "wiki": {
  34535. "type": "string",
  34536. "description": "URL to the wiki.",
  34537. "format": "uri"
  34538. },
  34539. "irc": {
  34540. "type": "string",
  34541. "description": "IRC channel for support, as irc://server/channel.",
  34542. "format": "uri"
  34543. },
  34544. "chat": {
  34545. "type": "string",
  34546. "description": "URL to the support chat.",
  34547. "format": "uri"
  34548. },
  34549. "source": {
  34550. "type": "string",
  34551. "description": "URL to browse or download the sources.",
  34552. "format": "uri"
  34553. },
  34554. "docs": {
  34555. "type": "string",
  34556. "description": "URL to the documentation.",
  34557. "format": "uri"
  34558. },
  34559. "rss": {
  34560. "type": "string",
  34561. "description": "URL to the RSS feed.",
  34562. "format": "uri"
  34563. }
  34564. }
  34565. },
  34566. "funding": {
  34567. "type": "array",
  34568. "description": "A list of options to fund the development and maintenance of the package.",
  34569. "items": {
  34570. "type": "object",
  34571. "properties": {
  34572. "type": {
  34573. "type": "string",
  34574. "description": "Type of funding or platform through which funding is possible."
  34575. },
  34576. "url": {
  34577. "type": "string",
  34578. "description": "URL to a website with details on funding and a way to fund the package.",
  34579. "format": "uri"
  34580. }
  34581. }
  34582. }
  34583. },
  34584. "non-feature-branches": {
  34585. "type": ["array"],
  34586. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  34587. "items": {
  34588. "type": "string"
  34589. }
  34590. },
  34591. "default-branch": {
  34592. "type": ["boolean"],
  34593. "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."
  34594. },
  34595. "abandoned": {
  34596. "type": ["boolean", "string"],
  34597. "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."
  34598. },
  34599. "_comment": {
  34600. "type": ["array", "string"],
  34601. "description": "A key to store comments in"
  34602. }
  34603. },
  34604. "definitions": {
  34605. "authors": {
  34606. "type": "array",
  34607. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  34608. "items": {
  34609. "type": "object",
  34610. "additionalProperties": false,
  34611. "required": [ "name"],
  34612. "properties": {
  34613. "name": {
  34614. "type": "string",
  34615. "description": "Full name of the author."
  34616. },
  34617. "email": {
  34618. "type": "string",
  34619. "description": "Email address of the author.",
  34620. "format": "email"
  34621. },
  34622. "homepage": {
  34623. "type": "string",
  34624. "description": "Homepage URL for the author.",
  34625. "format": "uri"
  34626. },
  34627. "role": {
  34628. "type": "string",
  34629. "description": "Author's role in the project."
  34630. }
  34631. }
  34632. }
  34633. },
  34634. "autoload": {
  34635. "type": "object",
  34636. "description": "Description of how the package can be autoloaded.",
  34637. "properties": {
  34638. "psr-0": {
  34639. "type": "object",
  34640. "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.",
  34641. "additionalProperties": {
  34642. "type": ["string", "array"],
  34643. "items": {
  34644. "type": "string"
  34645. }
  34646. }
  34647. },
  34648. "psr-4": {
  34649. "type": "object",
  34650. "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.",
  34651. "additionalProperties": {
  34652. "type": ["string", "array"],
  34653. "items": {
  34654. "type": "string"
  34655. }
  34656. }
  34657. },
  34658. "classmap": {
  34659. "type": "array",
  34660. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34661. },
  34662. "files": {
  34663. "type": "array",
  34664. "description": "This is an array of files that are always required on every request."
  34665. },
  34666. "exclude-from-classmap": {
  34667. "type": "array",
  34668. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  34669. }
  34670. }
  34671. },
  34672. "repository": {
  34673. "type": "object",
  34674. "anyOf": [
  34675. { "$ref": "#/definitions/composer-repository" },
  34676. { "$ref": "#/definitions/vcs-repository" },
  34677. { "$ref": "#/definitions/path-repository" },
  34678. { "$ref": "#/definitions/artifact-repository" },
  34679. { "$ref": "#/definitions/pear-repository" },
  34680. { "$ref": "#/definitions/package-repository" }
  34681. ]
  34682. },
  34683. "composer-repository": {
  34684. "type": "object",
  34685. "required": ["type", "url"],
  34686. "properties": {
  34687. "type": { "type": "string", "enum": ["composer"] },
  34688. "url": { "type": "string" },
  34689. "canonical": { "type": "boolean" },
  34690. "only": {
  34691. "type": "array",
  34692. "items": {
  34693. "type": "string"
  34694. }
  34695. },
  34696. "exclude": {
  34697. "type": "array",
  34698. "items": {
  34699. "type": "string"
  34700. }
  34701. },
  34702. "options": {
  34703. "type": "object",
  34704. "additionalProperties": true
  34705. },
  34706. "allow_ssl_downgrade": { "type": "boolean" },
  34707. "force-lazy-providers": { "type": "boolean" }
  34708. }
  34709. },
  34710. "vcs-repository": {
  34711. "type": "object",
  34712. "required": ["type", "url"],
  34713. "properties": {
  34714. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] },
  34715. "url": { "type": "string" },
  34716. "canonical": { "type": "boolean" },
  34717. "only": {
  34718. "type": "array",
  34719. "items": {
  34720. "type": "string"
  34721. }
  34722. },
  34723. "exclude": {
  34724. "type": "array",
  34725. "items": {
  34726. "type": "string"
  34727. }
  34728. },
  34729. "no-api": { "type": "boolean" },
  34730. "secure-http": { "type": "boolean" },
  34731. "svn-cache-credentials": { "type": "boolean" },
  34732. "trunk-path": { "type": ["string", "boolean"] },
  34733. "branches-path": { "type": ["string", "boolean"] },
  34734. "tags-path": { "type": ["string", "boolean"] },
  34735. "package-path": { "type": "string" },
  34736. "depot": { "type": "string" },
  34737. "branch": { "type": "string" },
  34738. "unique_perforce_client_name": { "type": "string" },
  34739. "p4user": { "type": "string" },
  34740. "p4password": { "type": "string" }
  34741. }
  34742. },
  34743. "path-repository": {
  34744. "type": "object",
  34745. "required": ["type", "url"],
  34746. "properties": {
  34747. "type": { "type": "string", "enum": ["path"] },
  34748. "url": { "type": "string" },
  34749. "canonical": { "type": "boolean" },
  34750. "only": {
  34751. "type": "array",
  34752. "items": {
  34753. "type": "string"
  34754. }
  34755. },
  34756. "exclude": {
  34757. "type": "array",
  34758. "items": {
  34759. "type": "string"
  34760. }
  34761. },
  34762. "options": {
  34763. "type": "object",
  34764. "properties": {
  34765. "symlink": { "type": ["boolean", "null"] }
  34766. },
  34767. "additionalProperties": true
  34768. }
  34769. }
  34770. },
  34771. "artifact-repository": {
  34772. "type": "object",
  34773. "required": ["type", "url"],
  34774. "properties": {
  34775. "type": { "type": "string", "enum": ["artifact"] },
  34776. "url": { "type": "string" },
  34777. "canonical": { "type": "boolean" },
  34778. "only": {
  34779. "type": "array",
  34780. "items": {
  34781. "type": "string"
  34782. }
  34783. },
  34784. "exclude": {
  34785. "type": "array",
  34786. "items": {
  34787. "type": "string"
  34788. }
  34789. }
  34790. }
  34791. },
  34792. "pear-repository": {
  34793. "type": "object",
  34794. "required": ["type", "url"],
  34795. "properties": {
  34796. "type": { "type": "string", "enum": ["pear"] },
  34797. "url": { "type": "string" },
  34798. "canonical": { "type": "boolean" },
  34799. "only": {
  34800. "type": "array",
  34801. "items": {
  34802. "type": "string"
  34803. }
  34804. },
  34805. "exclude": {
  34806. "type": "array",
  34807. "items": {
  34808. "type": "string"
  34809. }
  34810. },
  34811. "vendor-alias": { "type": "string" }
  34812. }
  34813. },
  34814. "package-repository": {
  34815. "type": "object",
  34816. "required": ["type", "package"],
  34817. "properties": {
  34818. "type": { "type": "string", "enum": ["package"] },
  34819. "canonical": { "type": "boolean" },
  34820. "only": {
  34821. "type": "array",
  34822. "items": {
  34823. "type": "string"
  34824. }
  34825. },
  34826. "exclude": {
  34827. "type": "array",
  34828. "items": {
  34829. "type": "string"
  34830. }
  34831. },
  34832. "package": {
  34833. "oneOf": [
  34834. { "$ref": "#/definitions/inline-package" },
  34835. {
  34836. "type": "array",
  34837. "items": { "$ref": "#/definitions/inline-package" }
  34838. }
  34839. ]
  34840. }
  34841. }
  34842. },
  34843. "inline-package": {
  34844. "type": "object",
  34845. "required": ["name", "version"],
  34846. "properties": {
  34847. "name": {
  34848. "type": "string",
  34849. "description": "Package name, including 'vendor-name/' prefix."
  34850. },
  34851. "type": {
  34852. "type": "string"
  34853. },
  34854. "target-dir": {
  34855. "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.",
  34856. "type": "string"
  34857. },
  34858. "description": {
  34859. "type": "string"
  34860. },
  34861. "keywords": {
  34862. "type": "array",
  34863. "items": {
  34864. "type": "string"
  34865. }
  34866. },
  34867. "homepage": {
  34868. "type": "string",
  34869. "format": "uri"
  34870. },
  34871. "version": {
  34872. "type": "string"
  34873. },
  34874. "time": {
  34875. "type": "string"
  34876. },
  34877. "license": {
  34878. "type": [
  34879. "string",
  34880. "array"
  34881. ]
  34882. },
  34883. "authors": {
  34884. "$ref": "#/definitions/authors"
  34885. },
  34886. "require": {
  34887. "type": "object",
  34888. "additionalProperties": {
  34889. "type": "string"
  34890. }
  34891. },
  34892. "replace": {
  34893. "type": "object",
  34894. "additionalProperties": {
  34895. "type": "string"
  34896. }
  34897. },
  34898. "conflict": {
  34899. "type": "object",
  34900. "additionalProperties": {
  34901. "type": "string"
  34902. }
  34903. },
  34904. "provide": {
  34905. "type": "object",
  34906. "additionalProperties": {
  34907. "type": "string"
  34908. }
  34909. },
  34910. "require-dev": {
  34911. "type": "object",
  34912. "additionalProperties": {
  34913. "type": "string"
  34914. }
  34915. },
  34916. "suggest": {
  34917. "type": "object",
  34918. "additionalProperties": {
  34919. "type": "string"
  34920. }
  34921. },
  34922. "extra": {
  34923. "type": ["object", "array"],
  34924. "additionalProperties": true
  34925. },
  34926. "autoload": {
  34927. "$ref": "#/definitions/autoload"
  34928. },
  34929. "archive": {
  34930. "type": ["object"],
  34931. "properties": {
  34932. "exclude": {
  34933. "type": "array"
  34934. }
  34935. }
  34936. },
  34937. "bin": {
  34938. "type": ["string", "array"],
  34939. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34940. "items": {
  34941. "type": "string"
  34942. }
  34943. },
  34944. "include-path": {
  34945. "type": ["array"],
  34946. "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.",
  34947. "items": {
  34948. "type": "string"
  34949. }
  34950. },
  34951. "source": {
  34952. "type": "object",
  34953. "required": ["type", "url", "reference"],
  34954. "properties": {
  34955. "type": {
  34956. "type": "string"
  34957. },
  34958. "url": {
  34959. "type": "string"
  34960. },
  34961. "reference": {
  34962. "type": "string"
  34963. },
  34964. "mirrors": {
  34965. "type": "array"
  34966. }
  34967. }
  34968. },
  34969. "dist": {
  34970. "type": "object",
  34971. "required": ["type", "url"],
  34972. "properties": {
  34973. "type": {
  34974. "type": "string"
  34975. },
  34976. "url": {
  34977. "type": "string"
  34978. },
  34979. "reference": {
  34980. "type": "string"
  34981. },
  34982. "shasum": {
  34983. "type": "string"
  34984. },
  34985. "mirrors": {
  34986. "type": "array"
  34987. }
  34988. }
  34989. }
  34990. },
  34991. "additionalProperties": true
  34992. }
  34993. }
  34994. }
  34995. <?php
  34996. require_once __DIR__ . '/composer/autoload_real.php';
  34997. return ComposerAutoloaderInitComposerPhar1619521868::getLoader();
  34998. <?php
  34999. namespace Composer\Autoload;
  35000. class ClassLoader
  35001. {
  35002. private $vendorDir;
  35003. private $prefixLengthsPsr4 = array();
  35004. private $prefixDirsPsr4 = array();
  35005. private $fallbackDirsPsr4 = array();
  35006. private $prefixesPsr0 = array();
  35007. private $fallbackDirsPsr0 = array();
  35008. private $useIncludePath = false;
  35009. private $classMap = array();
  35010. private $classMapAuthoritative = false;
  35011. private $missingClasses = array();
  35012. private $apcuPrefix;
  35013. private static $registeredLoaders = array();
  35014. public function __construct($vendorDir = null)
  35015. {
  35016. $this->vendorDir = $vendorDir;
  35017. }
  35018. public function getPrefixes()
  35019. {
  35020. if (!empty($this->prefixesPsr0)) {
  35021. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  35022. }
  35023. return array();
  35024. }
  35025. public function getPrefixesPsr4()
  35026. {
  35027. return $this->prefixDirsPsr4;
  35028. }
  35029. public function getFallbackDirs()
  35030. {
  35031. return $this->fallbackDirsPsr0;
  35032. }
  35033. public function getFallbackDirsPsr4()
  35034. {
  35035. return $this->fallbackDirsPsr4;
  35036. }
  35037. public function getClassMap()
  35038. {
  35039. return $this->classMap;
  35040. }
  35041. public function addClassMap(array $classMap)
  35042. {
  35043. if ($this->classMap) {
  35044. $this->classMap = array_merge($this->classMap, $classMap);
  35045. } else {
  35046. $this->classMap = $classMap;
  35047. }
  35048. }
  35049. public function add($prefix, $paths, $prepend = false)
  35050. {
  35051. if (!$prefix) {
  35052. if ($prepend) {
  35053. $this->fallbackDirsPsr0 = array_merge(
  35054. (array) $paths,
  35055. $this->fallbackDirsPsr0
  35056. );
  35057. } else {
  35058. $this->fallbackDirsPsr0 = array_merge(
  35059. $this->fallbackDirsPsr0,
  35060. (array) $paths
  35061. );
  35062. }
  35063. return;
  35064. }
  35065. $first = $prefix[0];
  35066. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  35067. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  35068. return;
  35069. }
  35070. if ($prepend) {
  35071. $this->prefixesPsr0[$first][$prefix] = array_merge(
  35072. (array) $paths,
  35073. $this->prefixesPsr0[$first][$prefix]
  35074. );
  35075. } else {
  35076. $this->prefixesPsr0[$first][$prefix] = array_merge(
  35077. $this->prefixesPsr0[$first][$prefix],
  35078. (array) $paths
  35079. );
  35080. }
  35081. }
  35082. public function addPsr4($prefix, $paths, $prepend = false)
  35083. {
  35084. if (!$prefix) {
  35085. if ($prepend) {
  35086. $this->fallbackDirsPsr4 = array_merge(
  35087. (array) $paths,
  35088. $this->fallbackDirsPsr4
  35089. );
  35090. } else {
  35091. $this->fallbackDirsPsr4 = array_merge(
  35092. $this->fallbackDirsPsr4,
  35093. (array) $paths
  35094. );
  35095. }
  35096. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  35097. $length = strlen($prefix);
  35098. if ('\\' !== $prefix[$length - 1]) {
  35099. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  35100. }
  35101. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  35102. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  35103. } elseif ($prepend) {
  35104. $this->prefixDirsPsr4[$prefix] = array_merge(
  35105. (array) $paths,
  35106. $this->prefixDirsPsr4[$prefix]
  35107. );
  35108. } else {
  35109. $this->prefixDirsPsr4[$prefix] = array_merge(
  35110. $this->prefixDirsPsr4[$prefix],
  35111. (array) $paths
  35112. );
  35113. }
  35114. }
  35115. public function set($prefix, $paths)
  35116. {
  35117. if (!$prefix) {
  35118. $this->fallbackDirsPsr0 = (array) $paths;
  35119. } else {
  35120. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  35121. }
  35122. }
  35123. public function setPsr4($prefix, $paths)
  35124. {
  35125. if (!$prefix) {
  35126. $this->fallbackDirsPsr4 = (array) $paths;
  35127. } else {
  35128. $length = strlen($prefix);
  35129. if ('\\' !== $prefix[$length - 1]) {
  35130. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  35131. }
  35132. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  35133. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  35134. }
  35135. }
  35136. public function setUseIncludePath($useIncludePath)
  35137. {
  35138. $this->useIncludePath = $useIncludePath;
  35139. }
  35140. public function getUseIncludePath()
  35141. {
  35142. return $this->useIncludePath;
  35143. }
  35144. public function setClassMapAuthoritative($classMapAuthoritative)
  35145. {
  35146. $this->classMapAuthoritative = $classMapAuthoritative;
  35147. }
  35148. public function isClassMapAuthoritative()
  35149. {
  35150. return $this->classMapAuthoritative;
  35151. }
  35152. public function setApcuPrefix($apcuPrefix)
  35153. {
  35154. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  35155. }
  35156. public function getApcuPrefix()
  35157. {
  35158. return $this->apcuPrefix;
  35159. }
  35160. public function register($prepend = false)
  35161. {
  35162. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  35163. if (null === $this->vendorDir) {
  35164. return;
  35165. }
  35166. if ($prepend) {
  35167. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  35168. } else {
  35169. unset(self::$registeredLoaders[$this->vendorDir]);
  35170. self::$registeredLoaders[$this->vendorDir] = $this;
  35171. }
  35172. }
  35173. public function unregister()
  35174. {
  35175. spl_autoload_unregister(array($this, 'loadClass'));
  35176. if (null !== $this->vendorDir) {
  35177. unset(self::$registeredLoaders[$this->vendorDir]);
  35178. }
  35179. }
  35180. public function loadClass($class)
  35181. {
  35182. if ($file = $this->findFile($class)) {
  35183. includeFile($file);
  35184. return true;
  35185. }
  35186. }
  35187. public function findFile($class)
  35188. {
  35189. if (isset($this->classMap[$class])) {
  35190. return $this->classMap[$class];
  35191. }
  35192. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  35193. return false;
  35194. }
  35195. if (null !== $this->apcuPrefix) {
  35196. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  35197. if ($hit) {
  35198. return $file;
  35199. }
  35200. }
  35201. $file = $this->findFileWithExtension($class, '.php');
  35202. if (false === $file && defined('HHVM_VERSION')) {
  35203. $file = $this->findFileWithExtension($class, '.hh');
  35204. }
  35205. if (null !== $this->apcuPrefix) {
  35206. apcu_add($this->apcuPrefix.$class, $file);
  35207. }
  35208. if (false === $file) {
  35209. $this->missingClasses[$class] = true;
  35210. }
  35211. return $file;
  35212. }
  35213. public static function getRegisteredLoaders()
  35214. {
  35215. return self::$registeredLoaders;
  35216. }
  35217. private function findFileWithExtension($class, $ext)
  35218. {
  35219. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  35220. $first = $class[0];
  35221. if (isset($this->prefixLengthsPsr4[$first])) {
  35222. $subPath = $class;
  35223. while (false !== $lastPos = strrpos($subPath, '\\')) {
  35224. $subPath = substr($subPath, 0, $lastPos);
  35225. $search = $subPath . '\\';
  35226. if (isset($this->prefixDirsPsr4[$search])) {
  35227. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  35228. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  35229. if (file_exists($file = $dir . $pathEnd)) {
  35230. return $file;
  35231. }
  35232. }
  35233. }
  35234. }
  35235. }
  35236. foreach ($this->fallbackDirsPsr4 as $dir) {
  35237. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  35238. return $file;
  35239. }
  35240. }
  35241. if (false !== $pos = strrpos($class, '\\')) {
  35242. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  35243. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  35244. } else {
  35245. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  35246. }
  35247. if (isset($this->prefixesPsr0[$first])) {
  35248. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  35249. if (0 === strpos($class, $prefix)) {
  35250. foreach ($dirs as $dir) {
  35251. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35252. return $file;
  35253. }
  35254. }
  35255. }
  35256. }
  35257. }
  35258. foreach ($this->fallbackDirsPsr0 as $dir) {
  35259. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35260. return $file;
  35261. }
  35262. }
  35263. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  35264. return $file;
  35265. }
  35266. return false;
  35267. }
  35268. }
  35269. function includeFile($file)
  35270. {
  35271. include $file;
  35272. }
  35273. <?php
  35274. namespace Composer;
  35275. use Composer\Autoload\ClassLoader;
  35276. use Composer\Semver\VersionParser;
  35277. class InstalledVersions
  35278. {
  35279. private static $installed = array (
  35280. 'root' =>
  35281. array (
  35282. 'pretty_version' => '2.0.13',
  35283. 'version' => '2.0.13.0',
  35284. 'aliases' =>
  35285. array (
  35286. ),
  35287. 'reference' => '986e8b86b7b570632ad0a905c3726c33dd4c0efb',
  35288. 'name' => 'composer/composer',
  35289. ),
  35290. 'versions' =>
  35291. array (
  35292. 'composer/ca-bundle' =>
  35293. array (
  35294. 'pretty_version' => '1.2.9',
  35295. 'version' => '1.2.9.0',
  35296. 'aliases' =>
  35297. array (
  35298. ),
  35299. 'reference' => '78a0e288fdcebf92aa2318a8d3656168da6ac1a5',
  35300. ),
  35301. 'composer/composer' =>
  35302. array (
  35303. 'pretty_version' => '2.0.13',
  35304. 'version' => '2.0.13.0',
  35305. 'aliases' =>
  35306. array (
  35307. ),
  35308. 'reference' => '986e8b86b7b570632ad0a905c3726c33dd4c0efb',
  35309. ),
  35310. 'composer/metadata-minifier' =>
  35311. array (
  35312. 'pretty_version' => '1.0.0',
  35313. 'version' => '1.0.0.0',
  35314. 'aliases' =>
  35315. array (
  35316. ),
  35317. 'reference' => 'c549d23829536f0d0e984aaabbf02af91f443207',
  35318. ),
  35319. 'composer/semver' =>
  35320. array (
  35321. 'pretty_version' => '3.2.4',
  35322. 'version' => '3.2.4.0',
  35323. 'aliases' =>
  35324. array (
  35325. ),
  35326. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  35327. ),
  35328. 'composer/spdx-licenses' =>
  35329. array (
  35330. 'pretty_version' => '1.5.5',
  35331. 'version' => '1.5.5.0',
  35332. 'aliases' =>
  35333. array (
  35334. ),
  35335. 'reference' => 'de30328a7af8680efdc03e396aad24befd513200',
  35336. ),
  35337. 'composer/xdebug-handler' =>
  35338. array (
  35339. 'pretty_version' => '1.4.6',
  35340. 'version' => '1.4.6.0',
  35341. 'aliases' =>
  35342. array (
  35343. ),
  35344. 'reference' => 'f27e06cd9675801df441b3656569b328e04aa37c',
  35345. ),
  35346. 'justinrainbow/json-schema' =>
  35347. array (
  35348. 'pretty_version' => '5.2.10',
  35349. 'version' => '5.2.10.0',
  35350. 'aliases' =>
  35351. array (
  35352. ),
  35353. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  35354. ),
  35355. 'psr/log' =>
  35356. array (
  35357. 'pretty_version' => '1.1.3',
  35358. 'version' => '1.1.3.0',
  35359. 'aliases' =>
  35360. array (
  35361. ),
  35362. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  35363. ),
  35364. 'react/promise' =>
  35365. array (
  35366. 'pretty_version' => 'v1.2.1',
  35367. 'version' => '1.2.1.0',
  35368. 'aliases' =>
  35369. array (
  35370. ),
  35371. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  35372. ),
  35373. 'seld/jsonlint' =>
  35374. array (
  35375. 'pretty_version' => '1.8.3',
  35376. 'version' => '1.8.3.0',
  35377. 'aliases' =>
  35378. array (
  35379. ),
  35380. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  35381. ),
  35382. 'seld/phar-utils' =>
  35383. array (
  35384. 'pretty_version' => '1.1.1',
  35385. 'version' => '1.1.1.0',
  35386. 'aliases' =>
  35387. array (
  35388. ),
  35389. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  35390. ),
  35391. 'symfony/console' =>
  35392. array (
  35393. 'pretty_version' => 'v2.8.52',
  35394. 'version' => '2.8.52.0',
  35395. 'aliases' =>
  35396. array (
  35397. ),
  35398. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  35399. ),
  35400. 'symfony/debug' =>
  35401. array (
  35402. 'pretty_version' => 'v2.8.52',
  35403. 'version' => '2.8.52.0',
  35404. 'aliases' =>
  35405. array (
  35406. ),
  35407. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  35408. ),
  35409. 'symfony/filesystem' =>
  35410. array (
  35411. 'pretty_version' => 'v2.8.52',
  35412. 'version' => '2.8.52.0',
  35413. 'aliases' =>
  35414. array (
  35415. ),
  35416. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  35417. ),
  35418. 'symfony/finder' =>
  35419. array (
  35420. 'pretty_version' => 'v2.8.52',
  35421. 'version' => '2.8.52.0',
  35422. 'aliases' =>
  35423. array (
  35424. ),
  35425. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  35426. ),
  35427. 'symfony/polyfill-ctype' =>
  35428. array (
  35429. 'pretty_version' => 'v1.19.0',
  35430. 'version' => '1.19.0.0',
  35431. 'aliases' =>
  35432. array (
  35433. ),
  35434. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  35435. ),
  35436. 'symfony/polyfill-mbstring' =>
  35437. array (
  35438. 'pretty_version' => 'v1.19.0',
  35439. 'version' => '1.19.0.0',
  35440. 'aliases' =>
  35441. array (
  35442. ),
  35443. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  35444. ),
  35445. 'symfony/process' =>
  35446. array (
  35447. 'pretty_version' => 'v2.8.52',
  35448. 'version' => '2.8.52.0',
  35449. 'aliases' =>
  35450. array (
  35451. ),
  35452. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  35453. ),
  35454. ),
  35455. );
  35456. private static $canGetVendors;
  35457. private static $installedByVendor = array();
  35458. public static function getInstalledPackages()
  35459. {
  35460. $packages = array();
  35461. foreach (self::getInstalled() as $installed) {
  35462. $packages[] = array_keys($installed['versions']);
  35463. }
  35464. if (1 === \count($packages)) {
  35465. return $packages[0];
  35466. }
  35467. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  35468. }
  35469. public static function isInstalled($packageName)
  35470. {
  35471. foreach (self::getInstalled() as $installed) {
  35472. if (isset($installed['versions'][$packageName])) {
  35473. return true;
  35474. }
  35475. }
  35476. return false;
  35477. }
  35478. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  35479. {
  35480. $constraint = $parser->parseConstraints($constraint);
  35481. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  35482. return $provided->matches($constraint);
  35483. }
  35484. public static function getVersionRanges($packageName)
  35485. {
  35486. foreach (self::getInstalled() as $installed) {
  35487. if (!isset($installed['versions'][$packageName])) {
  35488. continue;
  35489. }
  35490. $ranges = array();
  35491. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  35492. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  35493. }
  35494. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  35495. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  35496. }
  35497. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  35498. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  35499. }
  35500. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  35501. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  35502. }
  35503. return implode(' || ', $ranges);
  35504. }
  35505. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35506. }
  35507. public static function getVersion($packageName)
  35508. {
  35509. foreach (self::getInstalled() as $installed) {
  35510. if (!isset($installed['versions'][$packageName])) {
  35511. continue;
  35512. }
  35513. if (!isset($installed['versions'][$packageName]['version'])) {
  35514. return null;
  35515. }
  35516. return $installed['versions'][$packageName]['version'];
  35517. }
  35518. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35519. }
  35520. public static function getPrettyVersion($packageName)
  35521. {
  35522. foreach (self::getInstalled() as $installed) {
  35523. if (!isset($installed['versions'][$packageName])) {
  35524. continue;
  35525. }
  35526. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  35527. return null;
  35528. }
  35529. return $installed['versions'][$packageName]['pretty_version'];
  35530. }
  35531. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35532. }
  35533. public static function getReference($packageName)
  35534. {
  35535. foreach (self::getInstalled() as $installed) {
  35536. if (!isset($installed['versions'][$packageName])) {
  35537. continue;
  35538. }
  35539. if (!isset($installed['versions'][$packageName]['reference'])) {
  35540. return null;
  35541. }
  35542. return $installed['versions'][$packageName]['reference'];
  35543. }
  35544. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35545. }
  35546. public static function getRootPackage()
  35547. {
  35548. $installed = self::getInstalled();
  35549. return $installed[0]['root'];
  35550. }
  35551. public static function getRawData()
  35552. {
  35553. return self::$installed;
  35554. }
  35555. public static function reload($data)
  35556. {
  35557. self::$installed = $data;
  35558. self::$installedByVendor = array();
  35559. }
  35560. private static function getInstalled()
  35561. {
  35562. if (null === self::$canGetVendors) {
  35563. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  35564. }
  35565. $installed = array();
  35566. if (self::$canGetVendors) {
  35567. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  35568. if (isset(self::$installedByVendor[$vendorDir])) {
  35569. $installed[] = self::$installedByVendor[$vendorDir];
  35570. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  35571. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  35572. }
  35573. }
  35574. }
  35575. $installed[] = self::$installed;
  35576. return $installed;
  35577. }
  35578. }
  35579. <?php
  35580. $vendorDir = dirname(dirname(__FILE__));
  35581. $baseDir = dirname($vendorDir);
  35582. return array(
  35583. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  35584. );
  35585. <?php
  35586. $vendorDir = dirname(dirname(__FILE__));
  35587. $baseDir = dirname($vendorDir);
  35588. return array(
  35589. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  35590. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  35591. '7844cce90d4037f1a077c08319eef109' => $vendorDir . '/react/promise/src/React/Promise/functions_include.php',
  35592. );
  35593. <?php
  35594. $vendorDir = dirname(dirname(__FILE__));
  35595. $baseDir = dirname($vendorDir);
  35596. return array(
  35597. 'React\\Promise' => array($vendorDir . '/react/promise/src'),
  35598. );
  35599. <?php
  35600. $vendorDir = dirname(dirname(__FILE__));
  35601. $baseDir = dirname($vendorDir);
  35602. return array(
  35603. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  35604. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  35605. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  35606. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  35607. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  35608. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  35609. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  35610. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  35611. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  35612. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  35613. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  35614. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  35615. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  35616. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  35617. 'Composer\\MetadataMinifier\\' => array($vendorDir . '/composer/metadata-minifier/src'),
  35618. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  35619. 'Composer\\' => array($baseDir . '/src/Composer'),
  35620. );
  35621. <?php
  35622. class ComposerAutoloaderInitComposerPhar1619521868
  35623. {
  35624. private static $loader;
  35625. public static function loadClassLoader($class)
  35626. {
  35627. if ('Composer\Autoload\ClassLoader' === $class) {
  35628. require __DIR__ . '/ClassLoader.php';
  35629. }
  35630. }
  35631. public static function getLoader()
  35632. {
  35633. if (null !== self::$loader) {
  35634. return self::$loader;
  35635. }
  35636. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1619521868', 'loadClassLoader'), true, true);
  35637. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
  35638. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1619521868', 'loadClassLoader'));
  35639. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  35640. if ($useStaticLoader) {
  35641. require __DIR__ . '/autoload_static.php';
  35642. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1619521868::getInitializer($loader));
  35643. } else {
  35644. $map = require __DIR__ . '/autoload_namespaces.php';
  35645. foreach ($map as $namespace => $path) {
  35646. $loader->set($namespace, $path);
  35647. }
  35648. $map = require __DIR__ . '/autoload_psr4.php';
  35649. foreach ($map as $namespace => $path) {
  35650. $loader->setPsr4($namespace, $path);
  35651. }
  35652. $classMap = require __DIR__ . '/autoload_classmap.php';
  35653. if ($classMap) {
  35654. $loader->addClassMap($classMap);
  35655. }
  35656. }
  35657. $loader->register(true);
  35658. if ($useStaticLoader) {
  35659. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1619521868::$files;
  35660. } else {
  35661. $includeFiles = require __DIR__ . '/autoload_files.php';
  35662. }
  35663. foreach ($includeFiles as $fileIdentifier => $file) {
  35664. composerRequireComposerPhar1619521868($fileIdentifier, $file);
  35665. }
  35666. return $loader;
  35667. }
  35668. }
  35669. function composerRequireComposerPhar1619521868($fileIdentifier, $file)
  35670. {
  35671. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  35672. require $file;
  35673. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  35674. }
  35675. }
  35676. <?php
  35677. namespace Composer\Autoload;
  35678. class ComposerStaticInitComposerPhar1619521868
  35679. {
  35680. public static $files = array (
  35681. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  35682. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  35683. '7844cce90d4037f1a077c08319eef109' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions_include.php',
  35684. );
  35685. public static $prefixLengthsPsr4 = array (
  35686. 'S' =>
  35687. array (
  35688. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  35689. 'Symfony\\Polyfill\\Ctype\\' => 23,
  35690. 'Symfony\\Component\\Process\\' => 26,
  35691. 'Symfony\\Component\\Finder\\' => 25,
  35692. 'Symfony\\Component\\Filesystem\\' => 29,
  35693. 'Symfony\\Component\\Debug\\' => 24,
  35694. 'Symfony\\Component\\Console\\' => 26,
  35695. 'Seld\\PharUtils\\' => 15,
  35696. 'Seld\\JsonLint\\' => 14,
  35697. ),
  35698. 'P' =>
  35699. array (
  35700. 'Psr\\Log\\' => 8,
  35701. ),
  35702. 'J' =>
  35703. array (
  35704. 'JsonSchema\\' => 11,
  35705. ),
  35706. 'C' =>
  35707. array (
  35708. 'Composer\\XdebugHandler\\' => 23,
  35709. 'Composer\\Spdx\\' => 14,
  35710. 'Composer\\Semver\\' => 16,
  35711. 'Composer\\MetadataMinifier\\' => 26,
  35712. 'Composer\\CaBundle\\' => 18,
  35713. 'Composer\\' => 9,
  35714. ),
  35715. );
  35716. public static $prefixDirsPsr4 = array (
  35717. 'Symfony\\Polyfill\\Mbstring\\' =>
  35718. array (
  35719. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  35720. ),
  35721. 'Symfony\\Polyfill\\Ctype\\' =>
  35722. array (
  35723. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  35724. ),
  35725. 'Symfony\\Component\\Process\\' =>
  35726. array (
  35727. 0 => __DIR__ . '/..' . '/symfony/process',
  35728. ),
  35729. 'Symfony\\Component\\Finder\\' =>
  35730. array (
  35731. 0 => __DIR__ . '/..' . '/symfony/finder',
  35732. ),
  35733. 'Symfony\\Component\\Filesystem\\' =>
  35734. array (
  35735. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  35736. ),
  35737. 'Symfony\\Component\\Debug\\' =>
  35738. array (
  35739. 0 => __DIR__ . '/..' . '/symfony/debug',
  35740. ),
  35741. 'Symfony\\Component\\Console\\' =>
  35742. array (
  35743. 0 => __DIR__ . '/..' . '/symfony/console',
  35744. ),
  35745. 'Seld\\PharUtils\\' =>
  35746. array (
  35747. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  35748. ),
  35749. 'Seld\\JsonLint\\' =>
  35750. array (
  35751. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  35752. ),
  35753. 'Psr\\Log\\' =>
  35754. array (
  35755. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  35756. ),
  35757. 'JsonSchema\\' =>
  35758. array (
  35759. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  35760. ),
  35761. 'Composer\\XdebugHandler\\' =>
  35762. array (
  35763. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  35764. ),
  35765. 'Composer\\Spdx\\' =>
  35766. array (
  35767. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  35768. ),
  35769. 'Composer\\Semver\\' =>
  35770. array (
  35771. 0 => __DIR__ . '/..' . '/composer/semver/src',
  35772. ),
  35773. 'Composer\\MetadataMinifier\\' =>
  35774. array (
  35775. 0 => __DIR__ . '/..' . '/composer/metadata-minifier/src',
  35776. ),
  35777. 'Composer\\CaBundle\\' =>
  35778. array (
  35779. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  35780. ),
  35781. 'Composer\\' =>
  35782. array (
  35783. 0 => __DIR__ . '/../..' . '/src/Composer',
  35784. ),
  35785. );
  35786. public static $prefixesPsr0 = array (
  35787. 'R' =>
  35788. array (
  35789. 'React\\Promise' =>
  35790. array (
  35791. 0 => __DIR__ . '/..' . '/react/promise/src',
  35792. ),
  35793. ),
  35794. );
  35795. public static $classMap = array (
  35796. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  35797. );
  35798. public static function getInitializer(ClassLoader $loader)
  35799. {
  35800. return \Closure::bind(function () use ($loader) {
  35801. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1619521868::$prefixLengthsPsr4;
  35802. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1619521868::$prefixDirsPsr4;
  35803. $loader->prefixesPsr0 = ComposerStaticInitComposerPhar1619521868::$prefixesPsr0;
  35804. $loader->classMap = ComposerStaticInitComposerPhar1619521868::$classMap;
  35805. }, null, ClassLoader::class);
  35806. }
  35807. }
  35808. Copyright (C) 2016 Composer
  35809. Permission is hereby granted, free of charge, to any person obtaining a copy of
  35810. this software and associated documentation files (the "Software"), to deal in
  35811. the Software without restriction, including without limitation the rights to
  35812. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  35813. of the Software, and to permit persons to whom the Software is furnished to do
  35814. so, subject to the following conditions:
  35815. The above copyright notice and this permission notice shall be included in all
  35816. copies or substantial portions of the Software.
  35817. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35818. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  35819. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  35820. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  35821. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  35822. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  35823. SOFTWARE.
  35824. ##
  35825. ## Bundle of CA Root Certificates
  35826. ##
  35827. ## Certificate data from Mozilla as of: Tue Dec 8 04:12:05 2020 GMT
  35828. ##
  35829. ## This is a bundle of X.509 certificates of public Certificate Authorities
  35830. ## (CA). These were automatically extracted from Mozilla's root certificates
  35831. ## file (certdata.txt). This file can be found in the mozilla source tree:
  35832. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  35833. ##
  35834. ## It contains the certificates in PEM format and therefore
  35835. ## can be directly used with curl / libcurl / php_curl, or with
  35836. ## an Apache+mod_ssl webserver for SSL client authentication.
  35837. ## Just configure this file as the SSLCACertificateFile.
  35838. ##
  35839. ## Conversion done with mk-ca-bundle.pl version 1.28.
  35840. ## SHA256: d820b8696d8ffe42064a1384a56a8981cdc7e7e198036bbb5fa04a6c282dd9a2
  35841. ##
  35842. GlobalSign Root CA
  35843. ==================
  35844. -----BEGIN CERTIFICATE-----
  35845. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  35846. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  35847. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  35848. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  35849. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  35850. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  35851. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  35852. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  35853. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  35854. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  35855. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  35856. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  35857. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  35858. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  35859. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  35860. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  35861. -----END CERTIFICATE-----
  35862. GlobalSign Root CA - R2
  35863. =======================
  35864. -----BEGIN CERTIFICATE-----
  35865. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  35866. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  35867. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  35868. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  35869. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  35870. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  35871. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  35872. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  35873. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  35874. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  35875. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  35876. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  35877. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  35878. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  35879. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  35880. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  35881. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  35882. -----END CERTIFICATE-----
  35883. Entrust.net Premium 2048 Secure Server CA
  35884. =========================================
  35885. -----BEGIN CERTIFICATE-----
  35886. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  35887. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  35888. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  35889. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  35890. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  35891. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  35892. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  35893. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  35894. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  35895. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  35896. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  35897. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  35898. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  35899. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  35900. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  35901. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  35902. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  35903. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  35904. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  35905. -----END CERTIFICATE-----
  35906. Baltimore CyberTrust Root
  35907. =========================
  35908. -----BEGIN CERTIFICATE-----
  35909. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  35910. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  35911. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  35912. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  35913. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  35914. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  35915. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  35916. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  35917. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  35918. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  35919. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  35920. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  35921. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  35922. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  35923. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  35924. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  35925. -----END CERTIFICATE-----
  35926. Entrust Root Certification Authority
  35927. ====================================
  35928. -----BEGIN CERTIFICATE-----
  35929. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  35930. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  35931. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  35932. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  35933. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  35934. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  35935. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  35936. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  35937. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  35938. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  35939. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  35940. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  35941. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  35942. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  35943. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  35944. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  35945. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  35946. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  35947. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  35948. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  35949. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  35950. -----END CERTIFICATE-----
  35951. GeoTrust Global CA
  35952. ==================
  35953. -----BEGIN CERTIFICATE-----
  35954. MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK
  35955. Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw
  35956. MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j
  35957. LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  35958. CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo
  35959. BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet
  35960. 8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc
  35961. T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU
  35962. vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD
  35963. AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk
  35964. DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q
  35965. zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4
  35966. d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2
  35967. mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p
  35968. XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm
  35969. Mw==
  35970. -----END CERTIFICATE-----
  35971. GeoTrust Universal CA
  35972. =====================
  35973. -----BEGIN CERTIFICATE-----
  35974. MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  35975. R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1
  35976. MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu
  35977. Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  35978. ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t
  35979. JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e
  35980. RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs
  35981. 7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d
  35982. 8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V
  35983. qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga
  35984. Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB
  35985. Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu
  35986. KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08
  35987. ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0
  35988. XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB
  35989. hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
  35990. aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2
  35991. qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL
  35992. oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK
  35993. xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF
  35994. KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2
  35995. DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK
  35996. xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU
  35997. p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI
  35998. P/rmMuGNG2+k5o7Y+SlIis5z/iw=
  35999. -----END CERTIFICATE-----
  36000. GeoTrust Universal CA 2
  36001. =======================
  36002. -----BEGIN CERTIFICATE-----
  36003. MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  36004. R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0
  36005. MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg
  36006. SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA
  36007. A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0
  36008. DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17
  36009. j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q
  36010. JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a
  36011. QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2
  36012. WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP
  36013. 20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn
  36014. ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC
  36015. SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG
  36016. 8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2
  36017. +/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E
  36018. BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z
  36019. dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ
  36020. 4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+
  36021. mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq
  36022. A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg
  36023. Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP
  36024. pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d
  36025. FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp
  36026. gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm
  36027. X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS
  36028. -----END CERTIFICATE-----
  36029. Comodo AAA Services root
  36030. ========================
  36031. -----BEGIN CERTIFICATE-----
  36032. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  36033. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  36034. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  36035. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  36036. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  36037. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  36038. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  36039. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  36040. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  36041. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  36042. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  36043. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  36044. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  36045. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  36046. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  36047. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  36048. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  36049. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  36050. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  36051. -----END CERTIFICATE-----
  36052. QuoVadis Root CA
  36053. ================
  36054. -----BEGIN CERTIFICATE-----
  36055. MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE
  36056. ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
  36057. eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz
  36058. MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp
  36059. cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD
  36060. EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF
  36061. AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk
  36062. J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL
  36063. F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL
  36064. YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen
  36065. AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w
  36066. PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y
  36067. ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7
  36068. MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj
  36069. YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs
  36070. ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh
  36071. Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW
  36072. Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu
  36073. BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw
  36074. FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0
  36075. aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6
  36076. tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo
  36077. fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul
  36078. LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x
  36079. gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi
  36080. 5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi
  36081. 5nrQNiOKSnQ2+Q==
  36082. -----END CERTIFICATE-----
  36083. QuoVadis Root CA 2
  36084. ==================
  36085. -----BEGIN CERTIFICATE-----
  36086. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  36087. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  36088. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  36089. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  36090. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  36091. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  36092. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  36093. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  36094. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  36095. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  36096. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  36097. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  36098. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  36099. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  36100. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  36101. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  36102. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  36103. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  36104. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  36105. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  36106. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  36107. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  36108. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  36109. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  36110. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  36111. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  36112. -----END CERTIFICATE-----
  36113. QuoVadis Root CA 3
  36114. ==================
  36115. -----BEGIN CERTIFICATE-----
  36116. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  36117. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  36118. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  36119. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  36120. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  36121. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  36122. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  36123. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  36124. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  36125. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  36126. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  36127. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  36128. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  36129. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  36130. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  36131. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  36132. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  36133. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  36134. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  36135. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  36136. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  36137. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  36138. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  36139. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  36140. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  36141. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  36142. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  36143. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  36144. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  36145. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  36146. -----END CERTIFICATE-----
  36147. Security Communication Root CA
  36148. ==============================
  36149. -----BEGIN CERTIFICATE-----
  36150. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  36151. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  36152. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  36153. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  36154. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  36155. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  36156. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  36157. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  36158. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  36159. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  36160. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  36161. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  36162. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  36163. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  36164. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  36165. FL39vmwLAw==
  36166. -----END CERTIFICATE-----
  36167. Sonera Class 2 Root CA
  36168. ======================
  36169. -----BEGIN CERTIFICATE-----
  36170. MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG
  36171. U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw
  36172. NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh
  36173. IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3
  36174. /Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT
  36175. dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG
  36176. f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P
  36177. tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH
  36178. nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT
  36179. XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt
  36180. 0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI
  36181. cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph
  36182. Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx
  36183. EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH
  36184. llpwrN9M
  36185. -----END CERTIFICATE-----
  36186. XRamp Global CA Root
  36187. ====================
  36188. -----BEGIN CERTIFICATE-----
  36189. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  36190. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  36191. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  36192. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  36193. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  36194. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  36195. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  36196. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  36197. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  36198. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  36199. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  36200. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  36201. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  36202. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  36203. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  36204. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  36205. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  36206. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  36207. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  36208. -----END CERTIFICATE-----
  36209. Go Daddy Class 2 CA
  36210. ===================
  36211. -----BEGIN CERTIFICATE-----
  36212. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  36213. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  36214. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  36215. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  36216. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  36217. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  36218. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  36219. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  36220. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  36221. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  36222. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  36223. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  36224. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  36225. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  36226. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  36227. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  36228. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  36229. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  36230. vZ8=
  36231. -----END CERTIFICATE-----
  36232. Starfield Class 2 CA
  36233. ====================
  36234. -----BEGIN CERTIFICATE-----
  36235. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  36236. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  36237. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  36238. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  36239. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  36240. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  36241. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  36242. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  36243. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  36244. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  36245. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  36246. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  36247. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  36248. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  36249. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  36250. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  36251. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  36252. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  36253. QBFGmh95DmK/D5fs4C8fF5Q=
  36254. -----END CERTIFICATE-----
  36255. DigiCert Assured ID Root CA
  36256. ===========================
  36257. -----BEGIN CERTIFICATE-----
  36258. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  36259. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  36260. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  36261. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  36262. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  36263. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  36264. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  36265. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  36266. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  36267. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  36268. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  36269. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  36270. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  36271. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  36272. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  36273. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  36274. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  36275. -----END CERTIFICATE-----
  36276. DigiCert Global Root CA
  36277. =======================
  36278. -----BEGIN CERTIFICATE-----
  36279. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  36280. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  36281. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  36282. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  36283. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  36284. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  36285. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  36286. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  36287. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  36288. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  36289. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  36290. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  36291. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  36292. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  36293. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  36294. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  36295. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  36296. -----END CERTIFICATE-----
  36297. DigiCert High Assurance EV Root CA
  36298. ==================================
  36299. -----BEGIN CERTIFICATE-----
  36300. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  36301. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  36302. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  36303. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  36304. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  36305. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  36306. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  36307. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  36308. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  36309. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  36310. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  36311. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  36312. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  36313. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  36314. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  36315. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  36316. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  36317. -----END CERTIFICATE-----
  36318. DST Root CA X3
  36319. ==============
  36320. -----BEGIN CERTIFICATE-----
  36321. MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK
  36322. ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X
  36323. DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1
  36324. cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD
  36325. ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT
  36326. rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9
  36327. UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy
  36328. xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d
  36329. utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T
  36330. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ
  36331. MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug
  36332. dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE
  36333. GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw
  36334. RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS
  36335. fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
  36336. -----END CERTIFICATE-----
  36337. SwissSign Gold CA - G2
  36338. ======================
  36339. -----BEGIN CERTIFICATE-----
  36340. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  36341. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  36342. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  36343. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  36344. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  36345. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  36346. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  36347. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  36348. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  36349. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  36350. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  36351. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  36352. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  36353. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  36354. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  36355. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  36356. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  36357. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  36358. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  36359. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  36360. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  36361. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  36362. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  36363. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  36364. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  36365. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  36366. -----END CERTIFICATE-----
  36367. SwissSign Silver CA - G2
  36368. ========================
  36369. -----BEGIN CERTIFICATE-----
  36370. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  36371. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  36372. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  36373. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  36374. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  36375. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  36376. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  36377. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  36378. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  36379. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  36380. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  36381. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  36382. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  36383. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  36384. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  36385. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  36386. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  36387. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  36388. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  36389. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  36390. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  36391. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  36392. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  36393. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  36394. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  36395. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  36396. -----END CERTIFICATE-----
  36397. GeoTrust Primary Certification Authority
  36398. ========================================
  36399. -----BEGIN CERTIFICATE-----
  36400. MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG
  36401. EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD
  36402. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx
  36403. CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ
  36404. cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  36405. CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN
  36406. b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9
  36407. nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge
  36408. RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt
  36409. tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  36410. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI
  36411. hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K
  36412. Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN
  36413. NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa
  36414. Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG
  36415. 1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=
  36416. -----END CERTIFICATE-----
  36417. thawte Primary Root CA
  36418. ======================
  36419. -----BEGIN CERTIFICATE-----
  36420. MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE
  36421. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36422. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36423. cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3
  36424. MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg
  36425. SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv
  36426. KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT
  36427. FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs
  36428. oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ
  36429. 1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc
  36430. q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K
  36431. aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p
  36432. afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD
  36433. VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF
  36434. AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE
  36435. uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX
  36436. xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89
  36437. jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH
  36438. z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA==
  36439. -----END CERTIFICATE-----
  36440. VeriSign Class 3 Public Primary Certification Authority - G5
  36441. ============================================================
  36442. -----BEGIN CERTIFICATE-----
  36443. MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
  36444. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36445. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36446. IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
  36447. ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
  36448. yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
  36449. biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
  36450. dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
  36451. YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  36452. ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
  36453. j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
  36454. Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
  36455. Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
  36456. fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
  36457. BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
  36458. Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
  36459. aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
  36460. SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
  36461. X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
  36462. KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
  36463. Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
  36464. ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
  36465. -----END CERTIFICATE-----
  36466. SecureTrust CA
  36467. ==============
  36468. -----BEGIN CERTIFICATE-----
  36469. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  36470. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  36471. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  36472. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  36473. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  36474. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  36475. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  36476. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  36477. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  36478. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  36479. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  36480. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  36481. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  36482. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  36483. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  36484. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  36485. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  36486. -----END CERTIFICATE-----
  36487. Secure Global CA
  36488. ================
  36489. -----BEGIN CERTIFICATE-----
  36490. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  36491. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  36492. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  36493. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  36494. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  36495. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  36496. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  36497. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  36498. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  36499. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  36500. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  36501. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  36502. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  36503. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  36504. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  36505. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  36506. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  36507. -----END CERTIFICATE-----
  36508. COMODO Certification Authority
  36509. ==============================
  36510. -----BEGIN CERTIFICATE-----
  36511. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  36512. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  36513. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  36514. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  36515. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  36516. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  36517. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  36518. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  36519. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  36520. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  36521. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  36522. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  36523. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  36524. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  36525. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  36526. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  36527. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  36528. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  36529. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  36530. -----END CERTIFICATE-----
  36531. Network Solutions Certificate Authority
  36532. =======================================
  36533. -----BEGIN CERTIFICATE-----
  36534. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  36535. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  36536. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  36537. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  36538. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  36539. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  36540. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  36541. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  36542. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  36543. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  36544. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  36545. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  36546. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  36547. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  36548. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  36549. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  36550. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  36551. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  36552. -----END CERTIFICATE-----
  36553. COMODO ECC Certification Authority
  36554. ==================================
  36555. -----BEGIN CERTIFICATE-----
  36556. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  36557. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  36558. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  36559. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  36560. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  36561. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  36562. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  36563. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  36564. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  36565. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  36566. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  36567. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  36568. -----END CERTIFICATE-----
  36569. Certigna
  36570. ========
  36571. -----BEGIN CERTIFICATE-----
  36572. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  36573. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  36574. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  36575. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  36576. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  36577. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  36578. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  36579. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  36580. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  36581. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  36582. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  36583. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  36584. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  36585. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  36586. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  36587. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  36588. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  36589. -----END CERTIFICATE-----
  36590. Cybertrust Global Root
  36591. ======================
  36592. -----BEGIN CERTIFICATE-----
  36593. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  36594. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  36595. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  36596. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  36597. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  36598. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  36599. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  36600. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  36601. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  36602. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  36603. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  36604. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  36605. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  36606. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  36607. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  36608. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  36609. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  36610. -----END CERTIFICATE-----
  36611. ePKI Root Certification Authority
  36612. =================================
  36613. -----BEGIN CERTIFICATE-----
  36614. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  36615. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  36616. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  36617. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  36618. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  36619. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  36620. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  36621. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  36622. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  36623. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  36624. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  36625. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  36626. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  36627. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  36628. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  36629. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  36630. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  36631. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  36632. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  36633. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  36634. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  36635. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  36636. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  36637. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  36638. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  36639. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  36640. -----END CERTIFICATE-----
  36641. certSIGN ROOT CA
  36642. ================
  36643. -----BEGIN CERTIFICATE-----
  36644. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  36645. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  36646. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  36647. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  36648. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  36649. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  36650. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  36651. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  36652. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  36653. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  36654. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  36655. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  36656. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  36657. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  36658. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  36659. -----END CERTIFICATE-----
  36660. GeoTrust Primary Certification Authority - G3
  36661. =============================================
  36662. -----BEGIN CERTIFICATE-----
  36663. MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE
  36664. BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0
  36665. IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy
  36666. eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz
  36667. NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo
  36668. YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT
  36669. LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI
  36670. hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j
  36671. K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE
  36672. c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C
  36673. IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu
  36674. dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC
  36675. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr
  36676. 2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9
  36677. cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE
  36678. Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD
  36679. AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s
  36680. t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt
  36681. -----END CERTIFICATE-----
  36682. thawte Primary Root CA - G2
  36683. ===========================
  36684. -----BEGIN CERTIFICATE-----
  36685. MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC
  36686. VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu
  36687. IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg
  36688. Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV
  36689. MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG
  36690. b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt
  36691. IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS
  36692. LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5
  36693. 8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU
  36694. mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN
  36695. G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K
  36696. rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==
  36697. -----END CERTIFICATE-----
  36698. thawte Primary Root CA - G3
  36699. ===========================
  36700. -----BEGIN CERTIFICATE-----
  36701. MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE
  36702. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36703. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36704. cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w
  36705. ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh
  36706. d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD
  36707. VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG
  36708. A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  36709. MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At
  36710. P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC
  36711. +BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY
  36712. 7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW
  36713. vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E
  36714. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ
  36715. KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK
  36716. A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu
  36717. t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC
  36718. 8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm
  36719. er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A=
  36720. -----END CERTIFICATE-----
  36721. GeoTrust Primary Certification Authority - G2
  36722. =============================================
  36723. -----BEGIN CERTIFICATE-----
  36724. MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC
  36725. VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu
  36726. Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD
  36727. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1
  36728. OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg
  36729. MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl
  36730. b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG
  36731. BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc
  36732. KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD
  36733. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+
  36734. EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m
  36735. ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2
  36736. npaqBA+K
  36737. -----END CERTIFICATE-----
  36738. VeriSign Universal Root Certification Authority
  36739. ===============================================
  36740. -----BEGIN CERTIFICATE-----
  36741. MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
  36742. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36743. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36744. IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
  36745. IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
  36746. UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
  36747. cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
  36748. IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
  36749. aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
  36750. 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
  36751. MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
  36752. 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
  36753. AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
  36754. tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
  36755. CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
  36756. a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
  36757. DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
  36758. Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
  36759. Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
  36760. P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
  36761. wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
  36762. mJO37M2CYfE45k+XmCpajQ==
  36763. -----END CERTIFICATE-----
  36764. VeriSign Class 3 Public Primary Certification Authority - G4
  36765. ============================================================
  36766. -----BEGIN CERTIFICATE-----
  36767. MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
  36768. VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
  36769. b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
  36770. ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
  36771. YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
  36772. MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
  36773. cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
  36774. b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
  36775. IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
  36776. Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
  36777. rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
  36778. /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
  36779. HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
  36780. Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
  36781. A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
  36782. AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
  36783. -----END CERTIFICATE-----
  36784. NetLock Arany (Class Gold) Főtanúsítvány
  36785. ========================================
  36786. -----BEGIN CERTIFICATE-----
  36787. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  36788. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  36789. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  36790. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  36791. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  36792. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  36793. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  36794. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  36795. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  36796. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  36797. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  36798. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  36799. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  36800. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  36801. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  36802. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  36803. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  36804. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  36805. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  36806. -----END CERTIFICATE-----
  36807. Hongkong Post Root CA 1
  36808. =======================
  36809. -----BEGIN CERTIFICATE-----
  36810. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  36811. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  36812. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  36813. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  36814. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  36815. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  36816. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  36817. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  36818. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  36819. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  36820. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  36821. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  36822. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  36823. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  36824. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  36825. -----END CERTIFICATE-----
  36826. SecureSign RootCA11
  36827. ===================
  36828. -----BEGIN CERTIFICATE-----
  36829. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  36830. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  36831. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  36832. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  36833. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  36834. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  36835. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  36836. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  36837. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  36838. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  36839. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  36840. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  36841. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  36842. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  36843. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  36844. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  36845. -----END CERTIFICATE-----
  36846. Microsec e-Szigno Root CA 2009
  36847. ==============================
  36848. -----BEGIN CERTIFICATE-----
  36849. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  36850. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  36851. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  36852. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  36853. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  36854. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  36855. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  36856. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  36857. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  36858. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  36859. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  36860. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  36861. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  36862. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  36863. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  36864. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  36865. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  36866. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  36867. LXpUq3DDfSJlgnCW
  36868. -----END CERTIFICATE-----
  36869. GlobalSign Root CA - R3
  36870. =======================
  36871. -----BEGIN CERTIFICATE-----
  36872. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  36873. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  36874. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  36875. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  36876. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  36877. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  36878. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  36879. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  36880. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  36881. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  36882. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  36883. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  36884. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  36885. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  36886. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  36887. kpeDMdmztcpHWD9f
  36888. -----END CERTIFICATE-----
  36889. Autoridad de Certificacion Firmaprofesional CIF A62634068
  36890. =========================================================
  36891. -----BEGIN CERTIFICATE-----
  36892. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  36893. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  36894. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  36895. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  36896. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  36897. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  36898. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  36899. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  36900. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  36901. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  36902. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  36903. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  36904. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  36905. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  36906. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  36907. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  36908. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  36909. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  36910. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  36911. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  36912. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  36913. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  36914. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  36915. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  36916. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  36917. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  36918. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  36919. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  36920. -----END CERTIFICATE-----
  36921. Izenpe.com
  36922. ==========
  36923. -----BEGIN CERTIFICATE-----
  36924. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  36925. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  36926. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  36927. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  36928. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  36929. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  36930. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  36931. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  36932. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  36933. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  36934. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  36935. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  36936. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  36937. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  36938. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  36939. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  36940. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  36941. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  36942. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  36943. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  36944. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  36945. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  36946. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  36947. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  36948. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  36949. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  36950. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  36951. -----END CERTIFICATE-----
  36952. Chambers of Commerce Root - 2008
  36953. ================================
  36954. -----BEGIN CERTIFICATE-----
  36955. MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD
  36956. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  36957. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  36958. QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy
  36959. Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl
  36960. ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF
  36961. EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl
  36962. cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
  36963. AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA
  36964. XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj
  36965. h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/
  36966. ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk
  36967. NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g
  36968. D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331
  36969. lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ
  36970. 0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj
  36971. ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2
  36972. EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI
  36973. G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ
  36974. BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh
  36975. bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh
  36976. bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC
  36977. CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH
  36978. AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1
  36979. wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH
  36980. 3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU
  36981. RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6
  36982. M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1
  36983. YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF
  36984. 9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK
  36985. zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG
  36986. nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg
  36987. OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ
  36988. -----END CERTIFICATE-----
  36989. Global Chambersign Root - 2008
  36990. ==============================
  36991. -----BEGIN CERTIFICATE-----
  36992. MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD
  36993. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  36994. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  36995. QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx
  36996. NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg
  36997. Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ
  36998. QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD
  36999. aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf
  37000. VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf
  37001. XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0
  37002. ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB
  37003. /gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA
  37004. TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M
  37005. H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe
  37006. Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF
  37007. HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh
  37008. wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB
  37009. AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT
  37010. BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE
  37011. BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm
  37012. aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm
  37013. aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp
  37014. 1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0
  37015. dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG
  37016. /5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6
  37017. ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s
  37018. dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg
  37019. 9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH
  37020. foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du
  37021. qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr
  37022. P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq
  37023. c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z
  37024. 09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B
  37025. -----END CERTIFICATE-----
  37026. Go Daddy Root Certificate Authority - G2
  37027. ========================================
  37028. -----BEGIN CERTIFICATE-----
  37029. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  37030. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  37031. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  37032. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  37033. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  37034. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  37035. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  37036. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  37037. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  37038. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  37039. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  37040. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  37041. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  37042. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  37043. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  37044. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  37045. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  37046. -----END CERTIFICATE-----
  37047. Starfield Root Certificate Authority - G2
  37048. =========================================
  37049. -----BEGIN CERTIFICATE-----
  37050. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  37051. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  37052. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  37053. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  37054. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  37055. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  37056. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  37057. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  37058. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  37059. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  37060. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  37061. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  37062. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  37063. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  37064. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  37065. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  37066. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  37067. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  37068. -----END CERTIFICATE-----
  37069. Starfield Services Root Certificate Authority - G2
  37070. ==================================================
  37071. -----BEGIN CERTIFICATE-----
  37072. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  37073. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  37074. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  37075. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  37076. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  37077. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  37078. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  37079. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  37080. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  37081. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  37082. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  37083. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  37084. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  37085. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  37086. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  37087. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  37088. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  37089. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  37090. -----END CERTIFICATE-----
  37091. AffirmTrust Commercial
  37092. ======================
  37093. -----BEGIN CERTIFICATE-----
  37094. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  37095. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  37096. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  37097. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  37098. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  37099. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  37100. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  37101. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  37102. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  37103. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  37104. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  37105. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  37106. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  37107. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  37108. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  37109. -----END CERTIFICATE-----
  37110. AffirmTrust Networking
  37111. ======================
  37112. -----BEGIN CERTIFICATE-----
  37113. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  37114. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  37115. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  37116. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  37117. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  37118. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  37119. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  37120. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  37121. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  37122. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  37123. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  37124. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  37125. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  37126. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  37127. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  37128. -----END CERTIFICATE-----
  37129. AffirmTrust Premium
  37130. ===================
  37131. -----BEGIN CERTIFICATE-----
  37132. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  37133. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  37134. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  37135. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  37136. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  37137. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  37138. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  37139. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  37140. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  37141. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  37142. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  37143. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  37144. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  37145. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  37146. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  37147. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  37148. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  37149. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  37150. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  37151. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  37152. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  37153. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  37154. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  37155. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  37156. -----END CERTIFICATE-----
  37157. AffirmTrust Premium ECC
  37158. =======================
  37159. -----BEGIN CERTIFICATE-----
  37160. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  37161. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  37162. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  37163. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  37164. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  37165. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  37166. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  37167. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  37168. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  37169. eQ==
  37170. -----END CERTIFICATE-----
  37171. Certum Trusted Network CA
  37172. =========================
  37173. -----BEGIN CERTIFICATE-----
  37174. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  37175. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  37176. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  37177. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  37178. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  37179. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  37180. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  37181. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  37182. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  37183. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  37184. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  37185. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  37186. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  37187. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  37188. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  37189. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  37190. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  37191. -----END CERTIFICATE-----
  37192. TWCA Root Certification Authority
  37193. =================================
  37194. -----BEGIN CERTIFICATE-----
  37195. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  37196. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  37197. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  37198. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  37199. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  37200. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  37201. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  37202. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  37203. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  37204. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  37205. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  37206. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  37207. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  37208. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  37209. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  37210. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  37211. -----END CERTIFICATE-----
  37212. Security Communication RootCA2
  37213. ==============================
  37214. -----BEGIN CERTIFICATE-----
  37215. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  37216. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  37217. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  37218. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  37219. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  37220. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  37221. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  37222. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  37223. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  37224. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  37225. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  37226. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  37227. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  37228. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  37229. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  37230. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  37231. -----END CERTIFICATE-----
  37232. EC-ACC
  37233. ======
  37234. -----BEGIN CERTIFICATE-----
  37235. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  37236. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  37237. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  37238. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  37239. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  37240. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  37241. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  37242. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  37243. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  37244. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  37245. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  37246. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  37247. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  37248. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  37249. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  37250. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  37251. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  37252. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  37253. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  37254. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  37255. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  37256. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  37257. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  37258. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  37259. 5EI=
  37260. -----END CERTIFICATE-----
  37261. Hellenic Academic and Research Institutions RootCA 2011
  37262. =======================================================
  37263. -----BEGIN CERTIFICATE-----
  37264. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  37265. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  37266. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  37267. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  37268. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  37269. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  37270. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  37271. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  37272. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  37273. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  37274. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  37275. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  37276. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  37277. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  37278. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  37279. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  37280. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  37281. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  37282. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  37283. -----END CERTIFICATE-----
  37284. Actalis Authentication Root CA
  37285. ==============================
  37286. -----BEGIN CERTIFICATE-----
  37287. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  37288. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  37289. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  37290. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  37291. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  37292. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  37293. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  37294. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  37295. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  37296. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  37297. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  37298. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  37299. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  37300. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  37301. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  37302. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  37303. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  37304. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  37305. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  37306. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  37307. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  37308. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  37309. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  37310. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  37311. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  37312. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  37313. -----END CERTIFICATE-----
  37314. Trustis FPS Root CA
  37315. ===================
  37316. -----BEGIN CERTIFICATE-----
  37317. MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG
  37318. EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290
  37319. IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV
  37320. BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ
  37321. KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ
  37322. RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk
  37323. H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa
  37324. cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt
  37325. o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA
  37326. AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd
  37327. BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c
  37328. GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC
  37329. yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P
  37330. 8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV
  37331. l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl
  37332. iB6XzCGcKQENZetX2fNXlrtIzYE=
  37333. -----END CERTIFICATE-----
  37334. Buypass Class 2 Root CA
  37335. =======================
  37336. -----BEGIN CERTIFICATE-----
  37337. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  37338. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  37339. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  37340. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  37341. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  37342. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  37343. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  37344. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  37345. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  37346. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  37347. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  37348. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  37349. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  37350. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  37351. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  37352. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  37353. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  37354. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  37355. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  37356. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  37357. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  37358. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  37359. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  37360. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  37361. rJgWVqA=
  37362. -----END CERTIFICATE-----
  37363. Buypass Class 3 Root CA
  37364. =======================
  37365. -----BEGIN CERTIFICATE-----
  37366. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  37367. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  37368. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  37369. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  37370. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  37371. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  37372. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  37373. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  37374. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  37375. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  37376. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  37377. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  37378. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  37379. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  37380. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  37381. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  37382. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  37383. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  37384. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  37385. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  37386. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  37387. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  37388. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  37389. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  37390. Cp/HuZc=
  37391. -----END CERTIFICATE-----
  37392. T-TeleSec GlobalRoot Class 3
  37393. ============================
  37394. -----BEGIN CERTIFICATE-----
  37395. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37396. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37397. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  37398. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37399. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37400. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  37401. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  37402. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  37403. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  37404. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  37405. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  37406. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  37407. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  37408. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  37409. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  37410. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  37411. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  37412. -----END CERTIFICATE-----
  37413. D-TRUST Root Class 3 CA 2 2009
  37414. ==============================
  37415. -----BEGIN CERTIFICATE-----
  37416. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37417. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  37418. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  37419. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  37420. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  37421. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  37422. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  37423. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  37424. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  37425. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  37426. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  37427. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  37428. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  37429. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  37430. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  37431. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  37432. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  37433. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  37434. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  37435. -----END CERTIFICATE-----
  37436. D-TRUST Root Class 3 CA 2 EV 2009
  37437. =================================
  37438. -----BEGIN CERTIFICATE-----
  37439. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37440. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37441. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37442. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37443. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  37444. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  37445. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  37446. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  37447. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  37448. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  37449. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  37450. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  37451. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  37452. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  37453. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  37454. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  37455. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  37456. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  37457. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  37458. w9y4AyHqnxbxLFS1
  37459. -----END CERTIFICATE-----
  37460. CA Disig Root R2
  37461. ================
  37462. -----BEGIN CERTIFICATE-----
  37463. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  37464. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  37465. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  37466. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  37467. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  37468. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  37469. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  37470. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  37471. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  37472. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  37473. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  37474. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  37475. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  37476. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  37477. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  37478. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  37479. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  37480. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  37481. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  37482. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  37483. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  37484. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  37485. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  37486. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  37487. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  37488. -----END CERTIFICATE-----
  37489. ACCVRAIZ1
  37490. =========
  37491. -----BEGIN CERTIFICATE-----
  37492. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  37493. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  37494. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  37495. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  37496. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  37497. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  37498. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  37499. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  37500. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  37501. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  37502. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  37503. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  37504. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  37505. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  37506. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  37507. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  37508. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  37509. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  37510. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  37511. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  37512. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  37513. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  37514. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  37515. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  37516. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  37517. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  37518. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  37519. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  37520. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  37521. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  37522. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  37523. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  37524. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  37525. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  37526. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  37527. EfbRD0tVNEYqi4Y7
  37528. -----END CERTIFICATE-----
  37529. TWCA Global Root CA
  37530. ===================
  37531. -----BEGIN CERTIFICATE-----
  37532. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  37533. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  37534. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  37535. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  37536. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  37537. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  37538. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  37539. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  37540. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  37541. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  37542. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  37543. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  37544. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  37545. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  37546. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  37547. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  37548. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  37549. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  37550. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  37551. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  37552. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  37553. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  37554. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  37555. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  37556. -----END CERTIFICATE-----
  37557. TeliaSonera Root CA v1
  37558. ======================
  37559. -----BEGIN CERTIFICATE-----
  37560. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  37561. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  37562. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  37563. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  37564. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  37565. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  37566. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  37567. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  37568. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  37569. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  37570. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  37571. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  37572. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  37573. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  37574. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  37575. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  37576. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  37577. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  37578. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  37579. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  37580. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  37581. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  37582. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  37583. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  37584. -----END CERTIFICATE-----
  37585. E-Tugra Certification Authority
  37586. ===============================
  37587. -----BEGIN CERTIFICATE-----
  37588. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  37589. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  37590. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  37591. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  37592. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  37593. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  37594. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  37595. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  37596. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  37597. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  37598. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  37599. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  37600. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  37601. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  37602. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  37603. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  37604. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  37605. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  37606. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  37607. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  37608. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  37609. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  37610. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  37611. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  37612. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  37613. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  37614. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  37615. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  37616. C7TbO6Orb1wdtn7os4I07QZcJA==
  37617. -----END CERTIFICATE-----
  37618. T-TeleSec GlobalRoot Class 2
  37619. ============================
  37620. -----BEGIN CERTIFICATE-----
  37621. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37622. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37623. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  37624. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37625. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37626. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  37627. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  37628. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  37629. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  37630. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  37631. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  37632. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  37633. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  37634. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  37635. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  37636. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  37637. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  37638. -----END CERTIFICATE-----
  37639. Atos TrustedRoot 2011
  37640. =====================
  37641. -----BEGIN CERTIFICATE-----
  37642. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  37643. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  37644. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  37645. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  37646. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  37647. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  37648. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  37649. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  37650. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  37651. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  37652. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  37653. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  37654. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  37655. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  37656. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  37657. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  37658. -----END CERTIFICATE-----
  37659. QuoVadis Root CA 1 G3
  37660. =====================
  37661. -----BEGIN CERTIFICATE-----
  37662. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37663. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37664. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  37665. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  37666. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  37667. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  37668. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  37669. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  37670. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  37671. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  37672. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  37673. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  37674. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  37675. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37676. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  37677. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  37678. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  37679. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  37680. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  37681. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  37682. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  37683. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  37684. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  37685. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  37686. hMJKzRwuJIczYOXD
  37687. -----END CERTIFICATE-----
  37688. QuoVadis Root CA 2 G3
  37689. =====================
  37690. -----BEGIN CERTIFICATE-----
  37691. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37692. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37693. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  37694. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  37695. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  37696. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  37697. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  37698. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  37699. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  37700. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  37701. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  37702. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  37703. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  37704. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37705. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  37706. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  37707. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  37708. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  37709. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  37710. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  37711. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  37712. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  37713. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  37714. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  37715. O3jtZsSOeWmD3n+M
  37716. -----END CERTIFICATE-----
  37717. QuoVadis Root CA 3 G3
  37718. =====================
  37719. -----BEGIN CERTIFICATE-----
  37720. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  37721. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37722. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  37723. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  37724. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  37725. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  37726. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  37727. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  37728. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  37729. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  37730. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  37731. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  37732. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  37733. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37734. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  37735. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  37736. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  37737. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  37738. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  37739. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  37740. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  37741. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  37742. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  37743. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  37744. PpxxVJkES/1Y+Zj0
  37745. -----END CERTIFICATE-----
  37746. DigiCert Assured ID Root G2
  37747. ===========================
  37748. -----BEGIN CERTIFICATE-----
  37749. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  37750. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  37751. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  37752. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  37753. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  37754. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  37755. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  37756. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  37757. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  37758. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  37759. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  37760. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  37761. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  37762. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  37763. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  37764. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  37765. IhNzbM8m9Yop5w==
  37766. -----END CERTIFICATE-----
  37767. DigiCert Assured ID Root G3
  37768. ===========================
  37769. -----BEGIN CERTIFICATE-----
  37770. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  37771. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  37772. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37773. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37774. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  37775. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  37776. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  37777. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  37778. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  37779. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  37780. 1vUhZscv6pZjamVFkpUBtA==
  37781. -----END CERTIFICATE-----
  37782. DigiCert Global Root G2
  37783. =======================
  37784. -----BEGIN CERTIFICATE-----
  37785. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  37786. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  37787. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  37788. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  37789. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  37790. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  37791. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  37792. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  37793. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  37794. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  37795. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  37796. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  37797. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  37798. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  37799. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  37800. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  37801. MrY=
  37802. -----END CERTIFICATE-----
  37803. DigiCert Global Root G3
  37804. =======================
  37805. -----BEGIN CERTIFICATE-----
  37806. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  37807. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  37808. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  37809. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  37810. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  37811. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  37812. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  37813. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  37814. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  37815. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  37816. VOKa5Vt8sycX
  37817. -----END CERTIFICATE-----
  37818. DigiCert Trusted Root G4
  37819. ========================
  37820. -----BEGIN CERTIFICATE-----
  37821. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  37822. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  37823. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37824. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37825. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  37826. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  37827. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  37828. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  37829. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  37830. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  37831. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  37832. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  37833. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  37834. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  37835. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  37836. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  37837. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  37838. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  37839. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  37840. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  37841. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  37842. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  37843. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  37844. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  37845. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  37846. 82Z+
  37847. -----END CERTIFICATE-----
  37848. COMODO RSA Certification Authority
  37849. ==================================
  37850. -----BEGIN CERTIFICATE-----
  37851. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  37852. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  37853. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  37854. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  37855. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  37856. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  37857. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  37858. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  37859. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  37860. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  37861. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  37862. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  37863. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  37864. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  37865. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  37866. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  37867. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  37868. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  37869. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  37870. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  37871. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  37872. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  37873. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  37874. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  37875. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  37876. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  37877. LaZRfyHBNVOFBkpdn627G190
  37878. -----END CERTIFICATE-----
  37879. USERTrust RSA Certification Authority
  37880. =====================================
  37881. -----BEGIN CERTIFICATE-----
  37882. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  37883. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37884. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37885. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  37886. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37887. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37888. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  37889. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  37890. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  37891. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  37892. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  37893. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  37894. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  37895. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  37896. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  37897. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  37898. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  37899. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  37900. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  37901. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  37902. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  37903. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  37904. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  37905. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  37906. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  37907. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  37908. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  37909. -----END CERTIFICATE-----
  37910. USERTrust ECC Certification Authority
  37911. =====================================
  37912. -----BEGIN CERTIFICATE-----
  37913. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  37914. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37915. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37916. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  37917. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37918. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37919. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  37920. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  37921. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  37922. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  37923. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  37924. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  37925. -----END CERTIFICATE-----
  37926. GlobalSign ECC Root CA - R4
  37927. ===========================
  37928. -----BEGIN CERTIFICATE-----
  37929. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  37930. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37931. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37932. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37933. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  37934. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  37935. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  37936. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  37937. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  37938. -----END CERTIFICATE-----
  37939. GlobalSign ECC Root CA - R5
  37940. ===========================
  37941. -----BEGIN CERTIFICATE-----
  37942. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  37943. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37944. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37945. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37946. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  37947. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  37948. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  37949. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  37950. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  37951. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  37952. -----END CERTIFICATE-----
  37953. Staat der Nederlanden Root CA - G3
  37954. ==================================
  37955. -----BEGIN CERTIFICATE-----
  37956. MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
  37957. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  37958. Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
  37959. TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
  37960. ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
  37961. olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
  37962. x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
  37963. EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
  37964. Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
  37965. mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5
  37966. 1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp
  37967. 07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHPbMk7ccHViLVlvMDo
  37968. FxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXtBznaqB16nzaeErAMZRKQFWDZJkBE
  37969. 41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTtXUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMB
  37970. AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleu
  37971. yjWcLhL75LpdINyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD
  37972. U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwpLiniyMMB8jPq
  37973. KqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8Ipf3YF3qKS9Ysr1YvY2WTxB1
  37974. v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixpgZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA
  37975. 8KCWAg8zxXHzniN9lLf9OtMJgwYh/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b
  37976. 8KKaa8MFSu1BYBQw0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0r
  37977. mj1AfsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq4BZ+Extq
  37978. 1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR1VmiiXTTn74eS9fGbbeI
  37979. JG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV
  37980. tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk=
  37981. -----END CERTIFICATE-----
  37982. Staat der Nederlanden EV Root CA
  37983. ================================
  37984. -----BEGIN CERTIFICATE-----
  37985. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  37986. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  37987. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  37988. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  37989. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  37990. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  37991. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  37992. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  37993. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  37994. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  37995. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  37996. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  37997. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  37998. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  37999. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  38000. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  38001. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  38002. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  38003. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  38004. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  38005. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  38006. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  38007. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  38008. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  38009. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  38010. -----END CERTIFICATE-----
  38011. IdenTrust Commercial Root CA 1
  38012. ==============================
  38013. -----BEGIN CERTIFICATE-----
  38014. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  38015. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  38016. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  38017. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  38018. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  38019. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  38020. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  38021. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  38022. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  38023. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  38024. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  38025. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  38026. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  38027. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  38028. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  38029. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  38030. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  38031. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  38032. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  38033. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  38034. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  38035. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  38036. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  38037. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  38038. cGzM7vRX+Bi6hG6H
  38039. -----END CERTIFICATE-----
  38040. IdenTrust Public Sector Root CA 1
  38041. =================================
  38042. -----BEGIN CERTIFICATE-----
  38043. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  38044. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  38045. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  38046. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  38047. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  38048. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  38049. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  38050. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  38051. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  38052. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  38053. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  38054. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  38055. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  38056. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  38057. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  38058. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  38059. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  38060. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  38061. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  38062. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  38063. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  38064. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  38065. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  38066. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  38067. 3Wl9af0AVqW3rLatt8o+Ae+c
  38068. -----END CERTIFICATE-----
  38069. Entrust Root Certification Authority - G2
  38070. =========================================
  38071. -----BEGIN CERTIFICATE-----
  38072. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  38073. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  38074. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  38075. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  38076. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  38077. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  38078. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  38079. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  38080. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  38081. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  38082. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  38083. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  38084. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  38085. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  38086. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  38087. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  38088. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  38089. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  38090. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  38091. e4pIb4tF9g==
  38092. -----END CERTIFICATE-----
  38093. Entrust Root Certification Authority - EC1
  38094. ==========================================
  38095. -----BEGIN CERTIFICATE-----
  38096. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  38097. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  38098. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  38099. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  38100. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  38101. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  38102. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  38103. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  38104. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  38105. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  38106. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  38107. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  38108. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  38109. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  38110. -----END CERTIFICATE-----
  38111. CFCA EV ROOT
  38112. ============
  38113. -----BEGIN CERTIFICATE-----
  38114. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  38115. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  38116. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  38117. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  38118. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  38119. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  38120. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  38121. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  38122. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  38123. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  38124. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  38125. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  38126. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  38127. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  38128. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  38129. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  38130. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  38131. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  38132. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  38133. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  38134. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  38135. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  38136. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  38137. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  38138. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  38139. -----END CERTIFICATE-----
  38140. OISTE WISeKey Global Root GB CA
  38141. ===============================
  38142. -----BEGIN CERTIFICATE-----
  38143. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  38144. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  38145. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  38146. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  38147. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  38148. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  38149. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  38150. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  38151. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  38152. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  38153. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  38154. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  38155. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  38156. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  38157. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  38158. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  38159. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  38160. -----END CERTIFICATE-----
  38161. SZAFIR ROOT CA2
  38162. ===============
  38163. -----BEGIN CERTIFICATE-----
  38164. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  38165. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  38166. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  38167. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  38168. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  38169. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  38170. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  38171. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  38172. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  38173. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  38174. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  38175. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  38176. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  38177. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  38178. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  38179. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  38180. -----END CERTIFICATE-----
  38181. Certum Trusted Network CA 2
  38182. ===========================
  38183. -----BEGIN CERTIFICATE-----
  38184. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  38185. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  38186. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  38187. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  38188. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  38189. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  38190. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  38191. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  38192. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  38193. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  38194. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  38195. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  38196. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  38197. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  38198. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  38199. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  38200. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  38201. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  38202. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  38203. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  38204. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  38205. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  38206. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  38207. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  38208. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  38209. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  38210. zAYspsbiDrW5viSP
  38211. -----END CERTIFICATE-----
  38212. Hellenic Academic and Research Institutions RootCA 2015
  38213. =======================================================
  38214. -----BEGIN CERTIFICATE-----
  38215. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  38216. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  38217. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  38218. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  38219. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  38220. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  38221. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  38222. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  38223. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  38224. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  38225. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  38226. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  38227. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  38228. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  38229. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  38230. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  38231. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  38232. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  38233. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  38234. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  38235. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  38236. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  38237. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  38238. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  38239. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  38240. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  38241. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  38242. p/UsQu0yrbYhnr68
  38243. -----END CERTIFICATE-----
  38244. Hellenic Academic and Research Institutions ECC RootCA 2015
  38245. ===========================================================
  38246. -----BEGIN CERTIFICATE-----
  38247. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  38248. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  38249. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  38250. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  38251. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  38252. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  38253. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  38254. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  38255. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  38256. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  38257. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  38258. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  38259. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  38260. -----END CERTIFICATE-----
  38261. ISRG Root X1
  38262. ============
  38263. -----BEGIN CERTIFICATE-----
  38264. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  38265. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  38266. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  38267. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  38268. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  38269. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  38270. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  38271. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  38272. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  38273. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  38274. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  38275. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  38276. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  38277. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  38278. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  38279. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  38280. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  38281. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  38282. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  38283. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  38284. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  38285. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  38286. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  38287. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  38288. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  38289. -----END CERTIFICATE-----
  38290. AC RAIZ FNMT-RCM
  38291. ================
  38292. -----BEGIN CERTIFICATE-----
  38293. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  38294. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  38295. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  38296. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  38297. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  38298. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  38299. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  38300. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  38301. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  38302. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  38303. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  38304. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  38305. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  38306. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  38307. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  38308. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  38309. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  38310. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  38311. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  38312. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  38313. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  38314. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  38315. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  38316. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  38317. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  38318. -----END CERTIFICATE-----
  38319. Amazon Root CA 1
  38320. ================
  38321. -----BEGIN CERTIFICATE-----
  38322. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  38323. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  38324. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  38325. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  38326. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  38327. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  38328. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  38329. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  38330. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  38331. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  38332. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  38333. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  38334. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  38335. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  38336. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  38337. -----END CERTIFICATE-----
  38338. Amazon Root CA 2
  38339. ================
  38340. -----BEGIN CERTIFICATE-----
  38341. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  38342. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  38343. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  38344. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  38345. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  38346. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  38347. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  38348. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  38349. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  38350. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  38351. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  38352. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  38353. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  38354. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  38355. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  38356. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  38357. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  38358. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  38359. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  38360. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  38361. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  38362. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  38363. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  38364. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  38365. -----END CERTIFICATE-----
  38366. Amazon Root CA 3
  38367. ================
  38368. -----BEGIN CERTIFICATE-----
  38369. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  38370. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  38371. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38372. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  38373. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  38374. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  38375. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  38376. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  38377. -----END CERTIFICATE-----
  38378. Amazon Root CA 4
  38379. ================
  38380. -----BEGIN CERTIFICATE-----
  38381. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  38382. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  38383. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38384. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  38385. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  38386. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  38387. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  38388. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  38389. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  38390. -----END CERTIFICATE-----
  38391. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  38392. =============================================
  38393. -----BEGIN CERTIFICATE-----
  38394. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  38395. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  38396. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  38397. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  38398. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  38399. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  38400. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  38401. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  38402. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  38403. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  38404. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  38405. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  38406. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  38407. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  38408. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  38409. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  38410. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  38411. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  38412. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  38413. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  38414. -----END CERTIFICATE-----
  38415. GDCA TrustAUTH R5 ROOT
  38416. ======================
  38417. -----BEGIN CERTIFICATE-----
  38418. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  38419. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  38420. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  38421. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  38422. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  38423. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  38424. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  38425. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  38426. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  38427. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  38428. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  38429. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  38430. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  38431. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  38432. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  38433. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  38434. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  38435. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  38436. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  38437. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  38438. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  38439. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  38440. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  38441. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  38442. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  38443. -----END CERTIFICATE-----
  38444. TrustCor RootCert CA-1
  38445. ======================
  38446. -----BEGIN CERTIFICATE-----
  38447. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  38448. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38449. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38450. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  38451. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  38452. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  38453. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  38454. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  38455. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  38456. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  38457. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  38458. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  38459. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  38460. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  38461. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  38462. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  38463. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  38464. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  38465. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  38466. -----END CERTIFICATE-----
  38467. TrustCor RootCert CA-2
  38468. ======================
  38469. -----BEGIN CERTIFICATE-----
  38470. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  38471. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  38472. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  38473. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  38474. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  38475. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  38476. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  38477. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  38478. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  38479. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  38480. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  38481. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  38482. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  38483. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  38484. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  38485. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  38486. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  38487. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  38488. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  38489. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  38490. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  38491. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  38492. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  38493. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  38494. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  38495. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  38496. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  38497. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  38498. -----END CERTIFICATE-----
  38499. TrustCor ECA-1
  38500. ==============
  38501. -----BEGIN CERTIFICATE-----
  38502. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  38503. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38504. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38505. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  38506. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  38507. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  38508. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  38509. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  38510. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  38511. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  38512. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  38513. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  38514. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  38515. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  38516. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  38517. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  38518. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  38519. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  38520. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  38521. -----END CERTIFICATE-----
  38522. SSL.com Root Certification Authority RSA
  38523. ========================================
  38524. -----BEGIN CERTIFICATE-----
  38525. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  38526. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  38527. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  38528. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38529. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  38530. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  38531. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  38532. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  38533. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  38534. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  38535. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  38536. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  38537. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  38538. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  38539. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  38540. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  38541. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  38542. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  38543. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  38544. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  38545. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  38546. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  38547. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  38548. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  38549. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  38550. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  38551. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  38552. -----END CERTIFICATE-----
  38553. SSL.com Root Certification Authority ECC
  38554. ========================================
  38555. -----BEGIN CERTIFICATE-----
  38556. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  38557. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  38558. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  38559. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  38560. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  38561. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  38562. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  38563. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  38564. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  38565. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  38566. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  38567. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  38568. -----END CERTIFICATE-----
  38569. SSL.com EV Root Certification Authority RSA R2
  38570. ==============================================
  38571. -----BEGIN CERTIFICATE-----
  38572. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  38573. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  38574. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  38575. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  38576. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  38577. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  38578. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  38579. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  38580. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  38581. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  38582. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  38583. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  38584. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  38585. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  38586. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  38587. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  38588. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  38589. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  38590. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  38591. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  38592. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  38593. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  38594. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  38595. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  38596. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  38597. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  38598. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  38599. -----END CERTIFICATE-----
  38600. SSL.com EV Root Certification Authority ECC
  38601. ===========================================
  38602. -----BEGIN CERTIFICATE-----
  38603. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  38604. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  38605. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  38606. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38607. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  38608. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  38609. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  38610. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  38611. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  38612. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  38613. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  38614. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  38615. -----END CERTIFICATE-----
  38616. GlobalSign Root CA - R6
  38617. =======================
  38618. -----BEGIN CERTIFICATE-----
  38619. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  38620. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  38621. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  38622. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  38623. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  38624. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  38625. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  38626. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  38627. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  38628. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  38629. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  38630. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  38631. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  38632. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  38633. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  38634. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  38635. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  38636. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  38637. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  38638. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  38639. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  38640. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  38641. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  38642. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  38643. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  38644. -----END CERTIFICATE-----
  38645. OISTE WISeKey Global Root GC CA
  38646. ===============================
  38647. -----BEGIN CERTIFICATE-----
  38648. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  38649. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  38650. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  38651. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  38652. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  38653. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  38654. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  38655. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  38656. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  38657. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  38658. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  38659. -----END CERTIFICATE-----
  38660. GTS Root R1
  38661. ===========
  38662. -----BEGIN CERTIFICATE-----
  38663. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38664. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38665. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38666. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  38667. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  38668. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  38669. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  38670. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  38671. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  38672. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  38673. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  38674. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  38675. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  38676. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38677. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  38678. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  38679. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  38680. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  38681. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  38682. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  38683. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  38684. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  38685. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  38686. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  38687. CFF1pkgl
  38688. -----END CERTIFICATE-----
  38689. GTS Root R2
  38690. ===========
  38691. -----BEGIN CERTIFICATE-----
  38692. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38693. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38694. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38695. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  38696. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  38697. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  38698. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  38699. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  38700. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  38701. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  38702. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  38703. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  38704. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  38705. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38706. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  38707. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  38708. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  38709. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  38710. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  38711. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  38712. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  38713. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  38714. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  38715. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  38716. o/DUhgkC
  38717. -----END CERTIFICATE-----
  38718. GTS Root R3
  38719. ===========
  38720. -----BEGIN CERTIFICATE-----
  38721. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38722. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38723. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38724. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  38725. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  38726. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  38727. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  38728. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  38729. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  38730. KaqW04MjyaR7YbPMAuhd
  38731. -----END CERTIFICATE-----
  38732. GTS Root R4
  38733. ===========
  38734. -----BEGIN CERTIFICATE-----
  38735. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38736. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38737. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38738. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  38739. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  38740. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  38741. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  38742. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  38743. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  38744. zPKwTdb+mciUqXWi4w==
  38745. -----END CERTIFICATE-----
  38746. UCA Global G2 Root
  38747. ==================
  38748. -----BEGIN CERTIFICATE-----
  38749. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  38750. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  38751. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  38752. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  38753. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  38754. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  38755. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  38756. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  38757. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  38758. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  38759. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  38760. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  38761. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  38762. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  38763. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  38764. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  38765. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  38766. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  38767. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  38768. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  38769. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  38770. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  38771. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  38772. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  38773. -----END CERTIFICATE-----
  38774. UCA Extended Validation Root
  38775. ============================
  38776. -----BEGIN CERTIFICATE-----
  38777. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  38778. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  38779. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  38780. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  38781. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  38782. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  38783. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  38784. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  38785. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  38786. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  38787. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  38788. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  38789. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  38790. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  38791. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  38792. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  38793. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  38794. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  38795. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  38796. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  38797. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  38798. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  38799. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  38800. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  38801. dhh2n1ax
  38802. -----END CERTIFICATE-----
  38803. Certigna Root CA
  38804. ================
  38805. -----BEGIN CERTIFICATE-----
  38806. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  38807. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  38808. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  38809. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  38810. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  38811. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  38812. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  38813. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  38814. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  38815. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  38816. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  38817. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  38818. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  38819. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  38820. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  38821. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  38822. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  38823. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  38824. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  38825. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  38826. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  38827. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  38828. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  38829. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  38830. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  38831. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  38832. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  38833. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  38834. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  38835. -----END CERTIFICATE-----
  38836. emSign Root CA - G1
  38837. ===================
  38838. -----BEGIN CERTIFICATE-----
  38839. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  38840. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  38841. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  38842. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  38843. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  38844. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  38845. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  38846. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  38847. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  38848. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  38849. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  38850. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  38851. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  38852. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  38853. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  38854. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  38855. iN66zB+Afko=
  38856. -----END CERTIFICATE-----
  38857. emSign ECC Root CA - G3
  38858. =======================
  38859. -----BEGIN CERTIFICATE-----
  38860. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  38861. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  38862. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  38863. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  38864. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  38865. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  38866. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  38867. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  38868. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  38869. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  38870. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  38871. -----END CERTIFICATE-----
  38872. emSign Root CA - C1
  38873. ===================
  38874. -----BEGIN CERTIFICATE-----
  38875. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  38876. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  38877. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  38878. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  38879. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  38880. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  38881. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  38882. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  38883. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  38884. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  38885. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  38886. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  38887. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  38888. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  38889. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  38890. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  38891. -----END CERTIFICATE-----
  38892. emSign ECC Root CA - C3
  38893. =======================
  38894. -----BEGIN CERTIFICATE-----
  38895. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  38896. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  38897. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  38898. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  38899. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  38900. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  38901. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  38902. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  38903. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  38904. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  38905. -----END CERTIFICATE-----
  38906. Hongkong Post Root CA 3
  38907. =======================
  38908. -----BEGIN CERTIFICATE-----
  38909. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  38910. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  38911. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  38912. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  38913. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  38914. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  38915. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  38916. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  38917. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  38918. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  38919. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  38920. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  38921. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  38922. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  38923. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  38924. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  38925. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  38926. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  38927. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  38928. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  38929. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  38930. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  38931. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  38932. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  38933. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  38934. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  38935. dBb9HxEGmpv0
  38936. -----END CERTIFICATE-----
  38937. Entrust Root Certification Authority - G4
  38938. =========================================
  38939. -----BEGIN CERTIFICATE-----
  38940. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  38941. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  38942. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  38943. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  38944. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  38945. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  38946. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  38947. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  38948. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  38949. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  38950. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  38951. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  38952. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  38953. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  38954. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  38955. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  38956. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  38957. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  38958. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  38959. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  38960. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  38961. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  38962. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  38963. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  38964. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  38965. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  38966. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  38967. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  38968. kcpG2om3PVODLAgfi49T3f+sHw==
  38969. -----END CERTIFICATE-----
  38970. Microsoft ECC Root Certificate Authority 2017
  38971. =============================================
  38972. -----BEGIN CERTIFICATE-----
  38973. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  38974. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  38975. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  38976. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  38977. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  38978. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  38979. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  38980. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  38981. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  38982. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  38983. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  38984. -----END CERTIFICATE-----
  38985. Microsoft RSA Root Certificate Authority 2017
  38986. =============================================
  38987. -----BEGIN CERTIFICATE-----
  38988. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  38989. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  38990. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  38991. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  38992. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  38993. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  38994. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  38995. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  38996. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  38997. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  38998. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  38999. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  39000. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  39001. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  39002. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  39003. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  39004. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  39005. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  39006. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  39007. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  39008. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  39009. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  39010. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  39011. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  39012. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  39013. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  39014. -----END CERTIFICATE-----
  39015. e-Szigno Root CA 2017
  39016. =====================
  39017. -----BEGIN CERTIFICATE-----
  39018. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  39019. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  39020. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  39021. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  39022. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  39023. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  39024. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  39025. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  39026. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  39027. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  39028. svxyqltZ+efcMQ==
  39029. -----END CERTIFICATE-----
  39030. certSIGN Root CA G2
  39031. ===================
  39032. -----BEGIN CERTIFICATE-----
  39033. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  39034. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  39035. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  39036. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  39037. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  39038. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  39039. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  39040. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  39041. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  39042. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  39043. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  39044. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  39045. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  39046. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  39047. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  39048. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  39049. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  39050. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  39051. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  39052. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  39053. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  39054. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  39055. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  39056. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  39057. -----END CERTIFICATE-----
  39058. Trustwave Global Certification Authority
  39059. ========================================
  39060. -----BEGIN CERTIFICATE-----
  39061. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  39062. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  39063. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  39064. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  39065. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  39066. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  39067. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  39068. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  39069. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  39070. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  39071. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  39072. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  39073. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  39074. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  39075. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  39076. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  39077. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  39078. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  39079. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  39080. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  39081. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  39082. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  39083. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  39084. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  39085. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  39086. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  39087. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  39088. -----END CERTIFICATE-----
  39089. Trustwave Global ECC P256 Certification Authority
  39090. =================================================
  39091. -----BEGIN CERTIFICATE-----
  39092. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  39093. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  39094. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  39095. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  39096. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  39097. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  39098. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  39099. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  39100. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  39101. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  39102. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  39103. -----END CERTIFICATE-----
  39104. Trustwave Global ECC P384 Certification Authority
  39105. =================================================
  39106. -----BEGIN CERTIFICATE-----
  39107. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  39108. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  39109. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  39110. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  39111. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  39112. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  39113. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  39114. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  39115. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  39116. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  39117. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  39118. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  39119. -----END CERTIFICATE-----
  39120. <?php
  39121. namespace Composer\CaBundle;
  39122. use Psr\Log\LoggerInterface;
  39123. use Symfony\Component\Process\PhpProcess;
  39124. class CaBundle
  39125. {
  39126. private static $caPath;
  39127. private static $caFileValidity = array();
  39128. private static $useOpensslParse;
  39129. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  39130. {
  39131. if (self::$caPath !== null) {
  39132. return self::$caPath;
  39133. }
  39134. $caBundlePaths = array();
  39135. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  39136. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  39137. $caBundlePaths[] = ini_get('openssl.cafile');
  39138. $caBundlePaths[] = ini_get('openssl.capath');
  39139. $otherLocations = array(
  39140. '/etc/pki/tls/certs/ca-bundle.crt',
  39141. '/etc/ssl/certs/ca-certificates.crt',
  39142. '/etc/ssl/ca-bundle.pem',
  39143. '/usr/local/share/certs/ca-root-nss.crt',
  39144. '/usr/ssl/certs/ca-bundle.crt',
  39145. '/opt/local/share/curl/curl-ca-bundle.crt',
  39146. '/usr/local/share/curl/curl-ca-bundle.crt',
  39147. '/usr/share/ssl/certs/ca-bundle.crt',
  39148. '/etc/ssl/cert.pem',
  39149. '/usr/local/etc/ssl/cert.pem',
  39150. '/usr/local/etc/openssl/cert.pem',
  39151. '/usr/local/etc/openssl@1.1/cert.pem',
  39152. );
  39153. foreach($otherLocations as $location) {
  39154. $otherLocations[] = dirname($location);
  39155. }
  39156. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  39157. foreach ($caBundlePaths as $caBundle) {
  39158. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  39159. return self::$caPath = $caBundle;
  39160. }
  39161. if ($caBundle && self::caDirUsable($caBundle)) {
  39162. return self::$caPath = $caBundle;
  39163. }
  39164. }
  39165. return self::$caPath = static::getBundledCaBundlePath();
  39166. }
  39167. public static function getBundledCaBundlePath()
  39168. {
  39169. $caBundleFile = __DIR__.'/../res/cacert.pem';
  39170. if (0 === strpos($caBundleFile, 'phar://')) {
  39171. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  39172. if (false === $tempCaBundleFile) {
  39173. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  39174. }
  39175. file_put_contents(
  39176. $tempCaBundleFile,
  39177. file_get_contents($caBundleFile)
  39178. );
  39179. register_shutdown_function(function() use ($tempCaBundleFile) {
  39180. @unlink($tempCaBundleFile);
  39181. });
  39182. $caBundleFile = $tempCaBundleFile;
  39183. }
  39184. return $caBundleFile;
  39185. }
  39186. public static function validateCaFile($filename, LoggerInterface $logger = null)
  39187. {
  39188. static $warned = false;
  39189. if (isset(self::$caFileValidity[$filename])) {
  39190. return self::$caFileValidity[$filename];
  39191. }
  39192. $contents = file_get_contents($filename);
  39193. if (!static::isOpensslParseSafe()) {
  39194. if (!$warned && $logger) {
  39195. $logger->warning(sprintf(
  39196. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  39197. PHP_VERSION
  39198. ));
  39199. $warned = true;
  39200. }
  39201. $isValid = !empty($contents);
  39202. } elseif (is_string($contents) && strlen($contents) > 0) {
  39203. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  39204. if (null === $contents) {
  39205. $isValid = false;
  39206. } else {
  39207. $isValid = (bool) openssl_x509_parse($contents);
  39208. }
  39209. } else {
  39210. $isValid = false;
  39211. }
  39212. if ($logger) {
  39213. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  39214. }
  39215. return self::$caFileValidity[$filename] = $isValid;
  39216. }
  39217. public static function isOpensslParseSafe()
  39218. {
  39219. if (null !== self::$useOpensslParse) {
  39220. return self::$useOpensslParse;
  39221. }
  39222. if (PHP_VERSION_ID >= 50600) {
  39223. return self::$useOpensslParse = true;
  39224. }
  39225. if (
  39226. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  39227. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  39228. || PHP_VERSION_ID >= 50507
  39229. ) {
  39230. return self::$useOpensslParse = true;
  39231. }
  39232. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  39233. return self::$useOpensslParse = false;
  39234. }
  39235. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  39236. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  39237. if (preg_match($regex, PHP_VERSION, $m)) {
  39238. return ((int) $m[1]) >= $fixedVersion;
  39239. }
  39240. return false;
  39241. };
  39242. if (
  39243. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  39244. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  39245. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  39246. ) {
  39247. return self::$useOpensslParse = true;
  39248. }
  39249. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  39250. return self::$useOpensslParse = false;
  39251. }
  39252. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  39253. $script = <<<'EOT'
  39254. error_reporting(-1);
  39255. $info = openssl_x509_parse(base64_decode('%s'));
  39256. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  39257. EOT;
  39258. $script = '<'."?php\n".sprintf($script, $cert);
  39259. try {
  39260. $process = new PhpProcess($script);
  39261. $process->mustRun();
  39262. } catch (\Exception $e) {
  39263. return self::$useOpensslParse = false;
  39264. }
  39265. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  39266. $errorOutput = trim($process->getErrorOutput());
  39267. if (
  39268. is_array($output)
  39269. && count($output) === 3
  39270. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  39271. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  39272. && $output[2] === 'int(-1)'
  39273. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  39274. ) {
  39275. return self::$useOpensslParse = true;
  39276. }
  39277. return self::$useOpensslParse = false;
  39278. }
  39279. public static function reset()
  39280. {
  39281. self::$caFileValidity = array();
  39282. self::$caPath = null;
  39283. self::$useOpensslParse = null;
  39284. }
  39285. private static function getEnvVariable($name)
  39286. {
  39287. if (isset($_SERVER[$name])) {
  39288. return (string) $_SERVER[$name];
  39289. }
  39290. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  39291. return (string) $value;
  39292. }
  39293. return false;
  39294. }
  39295. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  39296. {
  39297. return $certFile && @is_file($certFile) && @is_readable($certFile) && static::validateCaFile($certFile, $logger);
  39298. }
  39299. private static function caDirUsable($certDir)
  39300. {
  39301. return $certDir && @is_dir($certDir) && @is_readable($certDir) && glob($certDir . '/*');
  39302. }
  39303. }
  39304. <?php return array (
  39305. 'root' =>
  39306. array (
  39307. 'pretty_version' => '2.0.13',
  39308. 'version' => '2.0.13.0',
  39309. 'aliases' =>
  39310. array (
  39311. ),
  39312. 'reference' => '986e8b86b7b570632ad0a905c3726c33dd4c0efb',
  39313. 'name' => 'composer/composer',
  39314. ),
  39315. 'versions' =>
  39316. array (
  39317. 'composer/ca-bundle' =>
  39318. array (
  39319. 'pretty_version' => '1.2.9',
  39320. 'version' => '1.2.9.0',
  39321. 'aliases' =>
  39322. array (
  39323. ),
  39324. 'reference' => '78a0e288fdcebf92aa2318a8d3656168da6ac1a5',
  39325. ),
  39326. 'composer/composer' =>
  39327. array (
  39328. 'pretty_version' => '2.0.13',
  39329. 'version' => '2.0.13.0',
  39330. 'aliases' =>
  39331. array (
  39332. ),
  39333. 'reference' => '986e8b86b7b570632ad0a905c3726c33dd4c0efb',
  39334. ),
  39335. 'composer/metadata-minifier' =>
  39336. array (
  39337. 'pretty_version' => '1.0.0',
  39338. 'version' => '1.0.0.0',
  39339. 'aliases' =>
  39340. array (
  39341. ),
  39342. 'reference' => 'c549d23829536f0d0e984aaabbf02af91f443207',
  39343. ),
  39344. 'composer/semver' =>
  39345. array (
  39346. 'pretty_version' => '3.2.4',
  39347. 'version' => '3.2.4.0',
  39348. 'aliases' =>
  39349. array (
  39350. ),
  39351. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  39352. ),
  39353. 'composer/spdx-licenses' =>
  39354. array (
  39355. 'pretty_version' => '1.5.5',
  39356. 'version' => '1.5.5.0',
  39357. 'aliases' =>
  39358. array (
  39359. ),
  39360. 'reference' => 'de30328a7af8680efdc03e396aad24befd513200',
  39361. ),
  39362. 'composer/xdebug-handler' =>
  39363. array (
  39364. 'pretty_version' => '1.4.6',
  39365. 'version' => '1.4.6.0',
  39366. 'aliases' =>
  39367. array (
  39368. ),
  39369. 'reference' => 'f27e06cd9675801df441b3656569b328e04aa37c',
  39370. ),
  39371. 'justinrainbow/json-schema' =>
  39372. array (
  39373. 'pretty_version' => '5.2.10',
  39374. 'version' => '5.2.10.0',
  39375. 'aliases' =>
  39376. array (
  39377. ),
  39378. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  39379. ),
  39380. 'psr/log' =>
  39381. array (
  39382. 'pretty_version' => '1.1.3',
  39383. 'version' => '1.1.3.0',
  39384. 'aliases' =>
  39385. array (
  39386. ),
  39387. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  39388. ),
  39389. 'react/promise' =>
  39390. array (
  39391. 'pretty_version' => 'v1.2.1',
  39392. 'version' => '1.2.1.0',
  39393. 'aliases' =>
  39394. array (
  39395. ),
  39396. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  39397. ),
  39398. 'seld/jsonlint' =>
  39399. array (
  39400. 'pretty_version' => '1.8.3',
  39401. 'version' => '1.8.3.0',
  39402. 'aliases' =>
  39403. array (
  39404. ),
  39405. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  39406. ),
  39407. 'seld/phar-utils' =>
  39408. array (
  39409. 'pretty_version' => '1.1.1',
  39410. 'version' => '1.1.1.0',
  39411. 'aliases' =>
  39412. array (
  39413. ),
  39414. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  39415. ),
  39416. 'symfony/console' =>
  39417. array (
  39418. 'pretty_version' => 'v2.8.52',
  39419. 'version' => '2.8.52.0',
  39420. 'aliases' =>
  39421. array (
  39422. ),
  39423. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  39424. ),
  39425. 'symfony/debug' =>
  39426. array (
  39427. 'pretty_version' => 'v2.8.52',
  39428. 'version' => '2.8.52.0',
  39429. 'aliases' =>
  39430. array (
  39431. ),
  39432. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  39433. ),
  39434. 'symfony/filesystem' =>
  39435. array (
  39436. 'pretty_version' => 'v2.8.52',
  39437. 'version' => '2.8.52.0',
  39438. 'aliases' =>
  39439. array (
  39440. ),
  39441. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  39442. ),
  39443. 'symfony/finder' =>
  39444. array (
  39445. 'pretty_version' => 'v2.8.52',
  39446. 'version' => '2.8.52.0',
  39447. 'aliases' =>
  39448. array (
  39449. ),
  39450. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  39451. ),
  39452. 'symfony/polyfill-ctype' =>
  39453. array (
  39454. 'pretty_version' => 'v1.19.0',
  39455. 'version' => '1.19.0.0',
  39456. 'aliases' =>
  39457. array (
  39458. ),
  39459. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  39460. ),
  39461. 'symfony/polyfill-mbstring' =>
  39462. array (
  39463. 'pretty_version' => 'v1.19.0',
  39464. 'version' => '1.19.0.0',
  39465. 'aliases' =>
  39466. array (
  39467. ),
  39468. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  39469. ),
  39470. 'symfony/process' =>
  39471. array (
  39472. 'pretty_version' => 'v2.8.52',
  39473. 'version' => '2.8.52.0',
  39474. 'aliases' =>
  39475. array (
  39476. ),
  39477. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  39478. ),
  39479. ),
  39480. );
  39481. Copyright (C) 2021 Composer
  39482. Permission is hereby granted, free of charge, to any person obtaining a copy of
  39483. this software and associated documentation files (the "Software"), to deal in
  39484. the Software without restriction, including without limitation the rights to
  39485. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  39486. of the Software, and to permit persons to whom the Software is furnished to do
  39487. so, subject to the following conditions:
  39488. The above copyright notice and this permission notice shall be included in all
  39489. copies or substantial portions of the Software.
  39490. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39491. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  39492. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  39493. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39494. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39495. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  39496. SOFTWARE.
  39497. <?php
  39498. namespace Composer\MetadataMinifier;
  39499. class MetadataMinifier
  39500. {
  39501. public static function expand(array $versions)
  39502. {
  39503. $expanded = array();
  39504. $expandedVersion = null;
  39505. foreach ($versions as $versionData) {
  39506. if (!$expandedVersion) {
  39507. $expandedVersion = $versionData;
  39508. $expanded[] = $expandedVersion;
  39509. continue;
  39510. }
  39511. foreach ($versionData as $key => $val) {
  39512. if ($val === '__unset') {
  39513. unset($expandedVersion[$key]);
  39514. } else {
  39515. $expandedVersion[$key] = $val;
  39516. }
  39517. }
  39518. $expanded[] = $expandedVersion;
  39519. }
  39520. return $expanded;
  39521. }
  39522. public static function minify(array $versions)
  39523. {
  39524. $minifiedVersions = array();
  39525. $lastKnownVersionData = null;
  39526. foreach ($versions as $version) {
  39527. if (!$lastKnownVersionData) {
  39528. $lastKnownVersionData = $version;
  39529. $minifiedVersions[] = $version;
  39530. continue;
  39531. }
  39532. $minifiedVersion = array();
  39533. foreach ($version as $key => $val) {
  39534. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  39535. $minifiedVersion[$key] = $val;
  39536. $lastKnownVersionData[$key] = $val;
  39537. }
  39538. }
  39539. foreach ($lastKnownVersionData as $key => $val) {
  39540. if (!isset($version[$key])) {
  39541. $minifiedVersion[$key] = "__unset";
  39542. unset($lastKnownVersionData[$key]);
  39543. }
  39544. }
  39545. $minifiedVersions[] = $minifiedVersion;
  39546. }
  39547. return $minifiedVersions;
  39548. }
  39549. }
  39550. Copyright (C) 2015 Composer
  39551. Permission is hereby granted, free of charge, to any person obtaining a copy of
  39552. this software and associated documentation files (the "Software"), to deal in
  39553. the Software without restriction, including without limitation the rights to
  39554. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  39555. of the Software, and to permit persons to whom the Software is furnished to do
  39556. so, subject to the following conditions:
  39557. The above copyright notice and this permission notice shall be included in all
  39558. copies or substantial portions of the Software.
  39559. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39560. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  39561. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  39562. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39563. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39564. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  39565. SOFTWARE.
  39566. <?php
  39567. namespace Composer\Semver;
  39568. use Composer\Semver\Constraint\Constraint;
  39569. class Comparator
  39570. {
  39571. public static function greaterThan($version1, $version2)
  39572. {
  39573. return self::compare($version1, '>', $version2);
  39574. }
  39575. public static function greaterThanOrEqualTo($version1, $version2)
  39576. {
  39577. return self::compare($version1, '>=', $version2);
  39578. }
  39579. public static function lessThan($version1, $version2)
  39580. {
  39581. return self::compare($version1, '<', $version2);
  39582. }
  39583. public static function lessThanOrEqualTo($version1, $version2)
  39584. {
  39585. return self::compare($version1, '<=', $version2);
  39586. }
  39587. public static function equalTo($version1, $version2)
  39588. {
  39589. return self::compare($version1, '==', $version2);
  39590. }
  39591. public static function notEqualTo($version1, $version2)
  39592. {
  39593. return self::compare($version1, '!=', $version2);
  39594. }
  39595. public static function compare($version1, $operator, $version2)
  39596. {
  39597. $constraint = new Constraint($operator, $version2);
  39598. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  39599. }
  39600. }
  39601. <?php
  39602. namespace Composer\Semver;
  39603. use Composer\Semver\Constraint\Constraint;
  39604. use Composer\Semver\Constraint\ConstraintInterface;
  39605. class CompilingMatcher
  39606. {
  39607. private static $compiledCheckerCache = array();
  39608. private static $enabled;
  39609. private static $transOpInt = array(
  39610. Constraint::OP_EQ => '==',
  39611. Constraint::OP_LT => '<',
  39612. Constraint::OP_LE => '<=',
  39613. Constraint::OP_GT => '>',
  39614. Constraint::OP_GE => '>=',
  39615. Constraint::OP_NE => '!=',
  39616. );
  39617. public static function match(ConstraintInterface $constraint, $operator, $version)
  39618. {
  39619. if (self::$enabled === null) {
  39620. self::$enabled = !\in_array('eval', explode(',', ini_get('disable_functions')), true);
  39621. }
  39622. if (!self::$enabled) {
  39623. return $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  39624. }
  39625. $cacheKey = $operator.$constraint;
  39626. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  39627. $code = $constraint->compile($operator);
  39628. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  39629. } else {
  39630. $function = self::$compiledCheckerCache[$cacheKey];
  39631. }
  39632. return $function($version, strpos($version, 'dev-') === 0);
  39633. }
  39634. }
  39635. <?php
  39636. namespace Composer\Semver\Constraint;
  39637. class Bound
  39638. {
  39639. private $version;
  39640. private $isInclusive;
  39641. public function __construct($version, $isInclusive)
  39642. {
  39643. $this->version = $version;
  39644. $this->isInclusive = $isInclusive;
  39645. }
  39646. public function getVersion()
  39647. {
  39648. return $this->version;
  39649. }
  39650. public function isInclusive()
  39651. {
  39652. return $this->isInclusive;
  39653. }
  39654. public function isZero()
  39655. {
  39656. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  39657. }
  39658. public function isPositiveInfinity()
  39659. {
  39660. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  39661. }
  39662. public function compareTo(Bound $other, $operator)
  39663. {
  39664. if (!\in_array($operator, array('<', '>'), true)) {
  39665. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  39666. }
  39667. if ($this == $other) {
  39668. return false;
  39669. }
  39670. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  39671. if (0 !== $compareResult) {
  39672. return (('>' === $operator) ? 1 : -1) === $compareResult;
  39673. }
  39674. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  39675. }
  39676. public function __toString()
  39677. {
  39678. return sprintf(
  39679. '%s [%s]',
  39680. $this->getVersion(),
  39681. $this->isInclusive() ? 'inclusive' : 'exclusive'
  39682. );
  39683. }
  39684. public static function zero()
  39685. {
  39686. return new Bound('0.0.0.0-dev', true);
  39687. }
  39688. public static function positiveInfinity()
  39689. {
  39690. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  39691. }
  39692. }
  39693. <?php
  39694. namespace Composer\Semver\Constraint;
  39695. class Constraint implements ConstraintInterface
  39696. {
  39697. const OP_EQ = 0;
  39698. const OP_LT = 1;
  39699. const OP_LE = 2;
  39700. const OP_GT = 3;
  39701. const OP_GE = 4;
  39702. const OP_NE = 5;
  39703. private static $transOpStr = array(
  39704. '=' => self::OP_EQ,
  39705. '==' => self::OP_EQ,
  39706. '<' => self::OP_LT,
  39707. '<=' => self::OP_LE,
  39708. '>' => self::OP_GT,
  39709. '>=' => self::OP_GE,
  39710. '<>' => self::OP_NE,
  39711. '!=' => self::OP_NE,
  39712. );
  39713. private static $transOpInt = array(
  39714. self::OP_EQ => '==',
  39715. self::OP_LT => '<',
  39716. self::OP_LE => '<=',
  39717. self::OP_GT => '>',
  39718. self::OP_GE => '>=',
  39719. self::OP_NE => '!=',
  39720. );
  39721. protected $operator;
  39722. protected $version;
  39723. protected $prettyString;
  39724. protected $lowerBound;
  39725. protected $upperBound;
  39726. public function __construct($operator, $version)
  39727. {
  39728. if (!isset(self::$transOpStr[$operator])) {
  39729. throw new \InvalidArgumentException(sprintf(
  39730. 'Invalid operator "%s" given, expected one of: %s',
  39731. $operator,
  39732. implode(', ', self::getSupportedOperators())
  39733. ));
  39734. }
  39735. $this->operator = self::$transOpStr[$operator];
  39736. $this->version = $version;
  39737. }
  39738. public function getVersion()
  39739. {
  39740. return $this->version;
  39741. }
  39742. public function getOperator()
  39743. {
  39744. return self::$transOpInt[$this->operator];
  39745. }
  39746. public function matches(ConstraintInterface $provider)
  39747. {
  39748. if ($provider instanceof self) {
  39749. return $this->matchSpecific($provider);
  39750. }
  39751. return $provider->matches($this);
  39752. }
  39753. public function setPrettyString($prettyString)
  39754. {
  39755. $this->prettyString = $prettyString;
  39756. }
  39757. public function getPrettyString()
  39758. {
  39759. if ($this->prettyString) {
  39760. return $this->prettyString;
  39761. }
  39762. return $this->__toString();
  39763. }
  39764. public static function getSupportedOperators()
  39765. {
  39766. return array_keys(self::$transOpStr);
  39767. }
  39768. public static function getOperatorConstant($operator)
  39769. {
  39770. return self::$transOpStr[$operator];
  39771. }
  39772. public function versionCompare($a, $b, $operator, $compareBranches = false)
  39773. {
  39774. if (!isset(self::$transOpStr[$operator])) {
  39775. throw new \InvalidArgumentException(sprintf(
  39776. 'Invalid operator "%s" given, expected one of: %s',
  39777. $operator,
  39778. implode(', ', self::getSupportedOperators())
  39779. ));
  39780. }
  39781. $aIsBranch = strpos($a, 'dev-') === 0;
  39782. $bIsBranch = strpos($b, 'dev-') === 0;
  39783. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  39784. return $a !== $b;
  39785. }
  39786. if ($aIsBranch && $bIsBranch) {
  39787. return $operator === '==' && $a === $b;
  39788. }
  39789. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  39790. return false;
  39791. }
  39792. return \version_compare($a, $b, $operator);
  39793. }
  39794. public function compile($otherOperator)
  39795. {
  39796. if (strpos($this->version, 'dev-') === 0) {
  39797. if (self::OP_EQ === $this->operator) {
  39798. if (self::OP_EQ === $otherOperator) {
  39799. return sprintf('$b && $v === %s', \var_export($this->version, true));
  39800. }
  39801. if (self::OP_NE === $otherOperator) {
  39802. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39803. }
  39804. return 'false';
  39805. }
  39806. if (self::OP_NE === $this->operator) {
  39807. if (self::OP_EQ === $otherOperator) {
  39808. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39809. }
  39810. if (self::OP_NE === $otherOperator) {
  39811. return 'true';
  39812. }
  39813. return '!$b';
  39814. }
  39815. return 'false';
  39816. }
  39817. if (self::OP_EQ === $this->operator) {
  39818. if (self::OP_EQ === $otherOperator) {
  39819. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  39820. }
  39821. if (self::OP_NE === $otherOperator) {
  39822. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  39823. }
  39824. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  39825. }
  39826. if (self::OP_NE === $this->operator) {
  39827. if (self::OP_EQ === $otherOperator) {
  39828. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  39829. }
  39830. if (self::OP_NE === $otherOperator) {
  39831. return 'true';
  39832. }
  39833. return '!$b';
  39834. }
  39835. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  39836. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  39837. return '!$b';
  39838. }
  39839. } elseif (self::OP_GT === $this->operator || self::OP_GE === $this->operator) {
  39840. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  39841. return '!$b';
  39842. }
  39843. }
  39844. if (self::OP_NE === $otherOperator) {
  39845. return 'true';
  39846. }
  39847. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  39848. if ($this->operator === self::OP_LE) {
  39849. if ($otherOperator === self::OP_GT) {
  39850. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39851. }
  39852. } elseif ($this->operator === self::OP_GE) {
  39853. if ($otherOperator === self::OP_LT) {
  39854. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39855. }
  39856. }
  39857. return sprintf('!$b && %s', $codeComparison);
  39858. }
  39859. public function matchSpecific(Constraint $provider, $compareBranches = false)
  39860. {
  39861. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  39862. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  39863. $isEqualOp = self::OP_EQ === $this->operator;
  39864. $isNonEqualOp = self::OP_NE === $this->operator;
  39865. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  39866. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  39867. if ($isNonEqualOp || $isProviderNonEqualOp) {
  39868. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  39869. return false;
  39870. }
  39871. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  39872. return false;
  39873. }
  39874. if (!$isEqualOp && !$isProviderEqualOp) {
  39875. return true;
  39876. }
  39877. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  39878. }
  39879. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  39880. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  39881. }
  39882. $version1 = $isEqualOp ? $this->version : $provider->version;
  39883. $version2 = $isEqualOp ? $provider->version : $this->version;
  39884. $operator = $isEqualOp ? $provider->operator : $this->operator;
  39885. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  39886. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  39887. && self::$transOpInt[$this->operator] !== $noEqualOp
  39888. && \version_compare($provider->version, $this->version, '=='));
  39889. }
  39890. return false;
  39891. }
  39892. public function __toString()
  39893. {
  39894. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  39895. }
  39896. public function getLowerBound()
  39897. {
  39898. $this->extractBounds();
  39899. return $this->lowerBound;
  39900. }
  39901. public function getUpperBound()
  39902. {
  39903. $this->extractBounds();
  39904. return $this->upperBound;
  39905. }
  39906. private function extractBounds()
  39907. {
  39908. if (null !== $this->lowerBound) {
  39909. return;
  39910. }
  39911. if (strpos($this->version, 'dev-') === 0) {
  39912. $this->lowerBound = Bound::zero();
  39913. $this->upperBound = Bound::positiveInfinity();
  39914. return;
  39915. }
  39916. switch ($this->operator) {
  39917. case self::OP_EQ:
  39918. $this->lowerBound = new Bound($this->version, true);
  39919. $this->upperBound = new Bound($this->version, true);
  39920. break;
  39921. case self::OP_LT:
  39922. $this->lowerBound = Bound::zero();
  39923. $this->upperBound = new Bound($this->version, false);
  39924. break;
  39925. case self::OP_LE:
  39926. $this->lowerBound = Bound::zero();
  39927. $this->upperBound = new Bound($this->version, true);
  39928. break;
  39929. case self::OP_GT:
  39930. $this->lowerBound = new Bound($this->version, false);
  39931. $this->upperBound = Bound::positiveInfinity();
  39932. break;
  39933. case self::OP_GE:
  39934. $this->lowerBound = new Bound($this->version, true);
  39935. $this->upperBound = Bound::positiveInfinity();
  39936. break;
  39937. case self::OP_NE:
  39938. $this->lowerBound = Bound::zero();
  39939. $this->upperBound = Bound::positiveInfinity();
  39940. break;
  39941. }
  39942. }
  39943. }
  39944. <?php
  39945. namespace Composer\Semver\Constraint;
  39946. interface ConstraintInterface
  39947. {
  39948. public function matches(ConstraintInterface $provider);
  39949. public function compile($operator);
  39950. public function getUpperBound();
  39951. public function getLowerBound();
  39952. public function getPrettyString();
  39953. public function setPrettyString($prettyString);
  39954. public function __toString();
  39955. }
  39956. <?php
  39957. namespace Composer\Semver\Constraint;
  39958. class MatchAllConstraint implements ConstraintInterface
  39959. {
  39960. protected $prettyString;
  39961. public function matches(ConstraintInterface $provider)
  39962. {
  39963. return true;
  39964. }
  39965. public function compile($operator)
  39966. {
  39967. return 'true';
  39968. }
  39969. public function setPrettyString($prettyString)
  39970. {
  39971. $this->prettyString = $prettyString;
  39972. }
  39973. public function getPrettyString()
  39974. {
  39975. if ($this->prettyString) {
  39976. return $this->prettyString;
  39977. }
  39978. return (string) $this;
  39979. }
  39980. public function __toString()
  39981. {
  39982. return '*';
  39983. }
  39984. public function getUpperBound()
  39985. {
  39986. return Bound::positiveInfinity();
  39987. }
  39988. public function getLowerBound()
  39989. {
  39990. return Bound::zero();
  39991. }
  39992. }
  39993. <?php
  39994. namespace Composer\Semver\Constraint;
  39995. class MatchNoneConstraint implements ConstraintInterface
  39996. {
  39997. protected $prettyString;
  39998. public function matches(ConstraintInterface $provider)
  39999. {
  40000. return false;
  40001. }
  40002. public function compile($operator)
  40003. {
  40004. return 'false';
  40005. }
  40006. public function setPrettyString($prettyString)
  40007. {
  40008. $this->prettyString = $prettyString;
  40009. }
  40010. public function getPrettyString()
  40011. {
  40012. if ($this->prettyString) {
  40013. return $this->prettyString;
  40014. }
  40015. return (string) $this;
  40016. }
  40017. public function __toString()
  40018. {
  40019. return '[]';
  40020. }
  40021. public function getUpperBound()
  40022. {
  40023. return new Bound('0.0.0.0-dev', false);
  40024. }
  40025. public function getLowerBound()
  40026. {
  40027. return new Bound('0.0.0.0-dev', false);
  40028. }
  40029. }
  40030. <?php
  40031. namespace Composer\Semver\Constraint;
  40032. class MultiConstraint implements ConstraintInterface
  40033. {
  40034. protected $constraints;
  40035. protected $prettyString;
  40036. protected $string;
  40037. protected $conjunctive;
  40038. protected $lowerBound;
  40039. protected $upperBound;
  40040. public function __construct(array $constraints, $conjunctive = true)
  40041. {
  40042. if (\count($constraints) < 2) {
  40043. throw new \InvalidArgumentException(
  40044. 'Must provide at least two constraints for a MultiConstraint. Use '.
  40045. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  40046. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  40047. );
  40048. }
  40049. $this->constraints = $constraints;
  40050. $this->conjunctive = $conjunctive;
  40051. }
  40052. public function getConstraints()
  40053. {
  40054. return $this->constraints;
  40055. }
  40056. public function isConjunctive()
  40057. {
  40058. return $this->conjunctive;
  40059. }
  40060. public function isDisjunctive()
  40061. {
  40062. return !$this->conjunctive;
  40063. }
  40064. public function compile($otherOperator)
  40065. {
  40066. $parts = array();
  40067. foreach ($this->constraints as $constraint) {
  40068. $code = $constraint->compile($otherOperator);
  40069. if ($code === 'true') {
  40070. if (!$this->conjunctive) {
  40071. return 'true';
  40072. }
  40073. } elseif ($code === 'false') {
  40074. if ($this->conjunctive) {
  40075. return 'false';
  40076. }
  40077. } else {
  40078. $parts[] = '('.$code.')';
  40079. }
  40080. }
  40081. if (!$parts) {
  40082. return $this->conjunctive ? 'true' : 'false';
  40083. }
  40084. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  40085. }
  40086. public function matches(ConstraintInterface $provider)
  40087. {
  40088. if (false === $this->conjunctive) {
  40089. foreach ($this->constraints as $constraint) {
  40090. if ($provider->matches($constraint)) {
  40091. return true;
  40092. }
  40093. }
  40094. return false;
  40095. }
  40096. foreach ($this->constraints as $constraint) {
  40097. if (!$provider->matches($constraint)) {
  40098. return false;
  40099. }
  40100. }
  40101. return true;
  40102. }
  40103. public function setPrettyString($prettyString)
  40104. {
  40105. $this->prettyString = $prettyString;
  40106. }
  40107. public function getPrettyString()
  40108. {
  40109. if ($this->prettyString) {
  40110. return $this->prettyString;
  40111. }
  40112. return (string) $this;
  40113. }
  40114. public function __toString()
  40115. {
  40116. if ($this->string !== null) {
  40117. return $this->string;
  40118. }
  40119. $constraints = array();
  40120. foreach ($this->constraints as $constraint) {
  40121. $constraints[] = (string) $constraint;
  40122. }
  40123. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  40124. }
  40125. public function getLowerBound()
  40126. {
  40127. $this->extractBounds();
  40128. return $this->lowerBound;
  40129. }
  40130. public function getUpperBound()
  40131. {
  40132. $this->extractBounds();
  40133. return $this->upperBound;
  40134. }
  40135. public static function create(array $constraints, $conjunctive = true)
  40136. {
  40137. if (0 === \count($constraints)) {
  40138. return new MatchAllConstraint();
  40139. }
  40140. if (1 === \count($constraints)) {
  40141. return $constraints[0];
  40142. }
  40143. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  40144. if ($optimized !== null) {
  40145. list($constraints, $conjunctive) = $optimized;
  40146. if (\count($constraints) === 1) {
  40147. return $constraints[0];
  40148. }
  40149. }
  40150. return new self($constraints, $conjunctive);
  40151. }
  40152. private static function optimizeConstraints(array $constraints, $conjunctive)
  40153. {
  40154. if (!$conjunctive) {
  40155. $left = $constraints[0];
  40156. $mergedConstraints = array();
  40157. $optimized = false;
  40158. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  40159. $right = $constraints[$i];
  40160. if (
  40161. $left instanceof self
  40162. && $left->conjunctive
  40163. && $right instanceof self
  40164. && $right->conjunctive
  40165. && \count($left->constraints) === 2
  40166. && \count($right->constraints) === 2
  40167. && ($left0 = (string) $left->constraints[0])
  40168. && $left0[0] === '>' && $left0[1] === '='
  40169. && ($left1 = (string) $left->constraints[1])
  40170. && $left1[0] === '<'
  40171. && ($right0 = (string) $right->constraints[0])
  40172. && $right0[0] === '>' && $right0[1] === '='
  40173. && ($right1 = (string) $right->constraints[1])
  40174. && $right1[0] === '<'
  40175. && substr($left1, 2) === substr($right0, 3)
  40176. ) {
  40177. $optimized = true;
  40178. $left = new MultiConstraint(
  40179. array(
  40180. $left->constraints[0],
  40181. $right->constraints[1],
  40182. ),
  40183. true);
  40184. } else {
  40185. $mergedConstraints[] = $left;
  40186. $left = $right;
  40187. }
  40188. }
  40189. if ($optimized) {
  40190. $mergedConstraints[] = $left;
  40191. return array($mergedConstraints, false);
  40192. }
  40193. }
  40194. return null;
  40195. }
  40196. private function extractBounds()
  40197. {
  40198. if (null !== $this->lowerBound) {
  40199. return;
  40200. }
  40201. foreach ($this->constraints as $constraint) {
  40202. if (null === $this->lowerBound && null === $this->upperBound) {
  40203. $this->lowerBound = $constraint->getLowerBound();
  40204. $this->upperBound = $constraint->getUpperBound();
  40205. continue;
  40206. }
  40207. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  40208. $this->lowerBound = $constraint->getLowerBound();
  40209. }
  40210. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  40211. $this->upperBound = $constraint->getUpperBound();
  40212. }
  40213. }
  40214. }
  40215. }
  40216. <?php
  40217. namespace Composer\Semver;
  40218. use Composer\Semver\Constraint\Constraint;
  40219. class Interval
  40220. {
  40221. private $start;
  40222. private $end;
  40223. public function __construct(Constraint $start, Constraint $end)
  40224. {
  40225. $this->start = $start;
  40226. $this->end = $end;
  40227. }
  40228. public function getStart()
  40229. {
  40230. return $this->start;
  40231. }
  40232. public function getEnd()
  40233. {
  40234. return $this->end;
  40235. }
  40236. public static function fromZero()
  40237. {
  40238. static $zero;
  40239. if (null === $zero) {
  40240. $zero = new Constraint('>=', '0.0.0.0-dev');
  40241. }
  40242. return $zero;
  40243. }
  40244. public static function untilPositiveInfinity()
  40245. {
  40246. static $positiveInfinity;
  40247. if (null === $positiveInfinity) {
  40248. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  40249. }
  40250. return $positiveInfinity;
  40251. }
  40252. public static function any()
  40253. {
  40254. return new self(self::fromZero(), self::untilPositiveInfinity());
  40255. }
  40256. public static function anyDev()
  40257. {
  40258. return array('names' => array(), 'exclude' => true);
  40259. }
  40260. public static function noDev()
  40261. {
  40262. return array('names' => array(), 'exclude' => false);
  40263. }
  40264. }
  40265. <?php
  40266. namespace Composer\Semver;
  40267. use Composer\Semver\Constraint\Constraint;
  40268. use Composer\Semver\Constraint\ConstraintInterface;
  40269. use Composer\Semver\Constraint\MatchAllConstraint;
  40270. use Composer\Semver\Constraint\MatchNoneConstraint;
  40271. use Composer\Semver\Constraint\MultiConstraint;
  40272. class Intervals
  40273. {
  40274. private static $intervalsCache = array();
  40275. private static $opSortOrder = array(
  40276. '>=' => -3,
  40277. '<' => -2,
  40278. '>' => 2,
  40279. '<=' => 3,
  40280. );
  40281. public static function clear()
  40282. {
  40283. self::$intervalsCache = array();
  40284. }
  40285. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  40286. {
  40287. if ($constraint instanceof MatchAllConstraint) {
  40288. return true;
  40289. }
  40290. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  40291. return false;
  40292. }
  40293. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  40294. $candidateIntervals = self::get($candidate);
  40295. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  40296. return false;
  40297. }
  40298. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  40299. if (!isset($candidateIntervals['numeric'][$index])) {
  40300. return false;
  40301. }
  40302. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  40303. return false;
  40304. }
  40305. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  40306. return false;
  40307. }
  40308. }
  40309. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  40310. return false;
  40311. }
  40312. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  40313. return false;
  40314. }
  40315. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  40316. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  40317. return false;
  40318. }
  40319. }
  40320. return true;
  40321. }
  40322. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  40323. {
  40324. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  40325. return true;
  40326. }
  40327. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  40328. return false;
  40329. }
  40330. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  40331. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  40332. }
  40333. public static function compactConstraint(ConstraintInterface $constraint)
  40334. {
  40335. if (!$constraint instanceof MultiConstraint) {
  40336. return $constraint;
  40337. }
  40338. $intervals = self::generateIntervals($constraint);
  40339. $constraints = array();
  40340. $hasNumericMatchAll = false;
  40341. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  40342. $constraints[] = $intervals['numeric'][0]->getStart();
  40343. $hasNumericMatchAll = true;
  40344. } else {
  40345. $unEqualConstraints = array();
  40346. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  40347. $interval = $intervals['numeric'][$i];
  40348. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  40349. $nextInterval = $intervals['numeric'][$i+1];
  40350. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  40351. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  40352. $unEqualConstraints[] = $interval->getStart();
  40353. }
  40354. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  40355. continue;
  40356. }
  40357. }
  40358. if (\count($unEqualConstraints) > 0) {
  40359. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  40360. $unEqualConstraints[] = $interval->getEnd();
  40361. }
  40362. if (\count($unEqualConstraints) > 1) {
  40363. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  40364. } else {
  40365. $constraints[] = $unEqualConstraints[0];
  40366. }
  40367. $unEqualConstraints = array();
  40368. continue;
  40369. }
  40370. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  40371. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  40372. continue;
  40373. }
  40374. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  40375. $constraints[] = $interval->getEnd();
  40376. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  40377. $constraints[] = $interval->getStart();
  40378. } else {
  40379. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  40380. }
  40381. }
  40382. }
  40383. $devConstraints = array();
  40384. if (0 === \count($intervals['branches']['names'])) {
  40385. if ($intervals['branches']['exclude']) {
  40386. if ($hasNumericMatchAll) {
  40387. return new MatchAllConstraint;
  40388. }
  40389. }
  40390. } else {
  40391. foreach ($intervals['branches']['names'] as $branchName) {
  40392. if ($intervals['branches']['exclude']) {
  40393. $devConstraints[] = new Constraint('!=', $branchName);
  40394. } else {
  40395. $devConstraints[] = new Constraint('==', $branchName);
  40396. }
  40397. }
  40398. if ($intervals['branches']['exclude']) {
  40399. if (\count($constraints) > 1) {
  40400. return new MultiConstraint(array_merge(
  40401. array(new MultiConstraint($constraints, false)),
  40402. $devConstraints
  40403. ), true);
  40404. }
  40405. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  40406. if (\count($devConstraints) > 1) {
  40407. return new MultiConstraint($devConstraints, true);
  40408. }
  40409. return $devConstraints[0];
  40410. }
  40411. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  40412. }
  40413. $constraints = array_merge($constraints, $devConstraints);
  40414. }
  40415. if (\count($constraints) > 1) {
  40416. return new MultiConstraint($constraints, false);
  40417. }
  40418. if (\count($constraints) === 1) {
  40419. return $constraints[0];
  40420. }
  40421. return new MatchNoneConstraint;
  40422. }
  40423. public static function get(ConstraintInterface $constraint)
  40424. {
  40425. $key = (string) $constraint;
  40426. if (!isset(self::$intervalsCache[$key])) {
  40427. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  40428. }
  40429. return self::$intervalsCache[$key];
  40430. }
  40431. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  40432. {
  40433. if ($constraint instanceof MatchAllConstraint) {
  40434. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  40435. }
  40436. if ($constraint instanceof MatchNoneConstraint) {
  40437. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  40438. }
  40439. if ($constraint instanceof Constraint) {
  40440. return self::generateSingleConstraintIntervals($constraint);
  40441. }
  40442. if (!$constraint instanceof MultiConstraint) {
  40443. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  40444. }
  40445. $constraints = $constraint->getConstraints();
  40446. $numericGroups = array();
  40447. $constraintBranches = array();
  40448. foreach ($constraints as $c) {
  40449. $res = self::get($c);
  40450. $numericGroups[] = $res['numeric'];
  40451. $constraintBranches[] = $res['branches'];
  40452. }
  40453. if ($constraint->isDisjunctive()) {
  40454. $branches = Interval::noDev();
  40455. foreach ($constraintBranches as $b) {
  40456. if ($b['exclude']) {
  40457. if ($branches['exclude']) {
  40458. $branches['names'] = array_intersect($branches['names'], $b['names']);
  40459. } else {
  40460. $branches['exclude'] = true;
  40461. $branches['names'] = array_diff($b['names'], $branches['names']);
  40462. }
  40463. } else {
  40464. if ($branches['exclude']) {
  40465. $branches['names'] = array_diff($branches['names'], $b['names']);
  40466. } else {
  40467. $branches['names'] = array_merge($branches['names'], $b['names']);
  40468. }
  40469. }
  40470. }
  40471. } else {
  40472. $branches = Interval::anyDev();
  40473. foreach ($constraintBranches as $b) {
  40474. if ($b['exclude']) {
  40475. if ($branches['exclude']) {
  40476. $branches['names'] = array_merge($branches['names'], $b['names']);
  40477. } else {
  40478. $branches['names'] = array_diff($branches['names'], $b['names']);
  40479. }
  40480. } else {
  40481. if ($branches['exclude']) {
  40482. $branches['names'] = array_diff($b['names'], $branches['names']);
  40483. $branches['exclude'] = false;
  40484. } else {
  40485. $branches['names'] = array_intersect($branches['names'], $b['names']);
  40486. }
  40487. }
  40488. }
  40489. }
  40490. $branches['names'] = array_unique($branches['names']);
  40491. if (\count($numericGroups) === 1) {
  40492. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  40493. }
  40494. $borders = array();
  40495. foreach ($numericGroups as $group) {
  40496. foreach ($group as $interval) {
  40497. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  40498. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  40499. }
  40500. }
  40501. $opSortOrder = self::$opSortOrder;
  40502. usort($borders, function ($a, $b) use ($opSortOrder) {
  40503. $order = version_compare($a['version'], $b['version']);
  40504. if ($order === 0) {
  40505. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  40506. }
  40507. return $order;
  40508. });
  40509. $activeIntervals = 0;
  40510. $intervals = array();
  40511. $index = 0;
  40512. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  40513. $active = false;
  40514. $start = null;
  40515. foreach ($borders as $border) {
  40516. if ($border['side'] === 'start') {
  40517. $activeIntervals++;
  40518. } else {
  40519. $activeIntervals--;
  40520. }
  40521. if (!$active && $activeIntervals >= $activationThreshold) {
  40522. $start = new Constraint($border['operator'], $border['version']);
  40523. $active = true;
  40524. }
  40525. if ($active && $activeIntervals < $activationThreshold) {
  40526. $active = false;
  40527. if (
  40528. version_compare($start->getVersion(), $border['version'], '=')
  40529. && (
  40530. ($start->getOperator() === '>' && $border['operator'] === '<=')
  40531. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  40532. )
  40533. ) {
  40534. unset($intervals[$index]);
  40535. } else {
  40536. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  40537. $index++;
  40538. if ($stopOnFirstValidInterval) {
  40539. break;
  40540. }
  40541. }
  40542. $start = null;
  40543. }
  40544. }
  40545. return array('numeric' => $intervals, 'branches' => $branches);
  40546. }
  40547. private static function generateSingleConstraintIntervals(Constraint $constraint)
  40548. {
  40549. $op = $constraint->getOperator();
  40550. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  40551. $intervals = array();
  40552. $branches = array('names' => array(), 'exclude' => false);
  40553. if ($op === '!=') {
  40554. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  40555. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  40556. } elseif ($op === '==') {
  40557. $branches['names'][] = $constraint->getVersion();
  40558. }
  40559. return array(
  40560. 'numeric' => $intervals,
  40561. 'branches' => $branches,
  40562. );
  40563. }
  40564. if ($op[0] === '>') {
  40565. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  40566. }
  40567. if ($op[0] === '<') {
  40568. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  40569. }
  40570. if ($op === '!=') {
  40571. return array('numeric' => array(
  40572. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  40573. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  40574. ), 'branches' => Interval::anyDev());
  40575. }
  40576. return array('numeric' => array(
  40577. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  40578. ), 'branches' => Interval::noDev());
  40579. }
  40580. }
  40581. <?php
  40582. namespace Composer\Semver;
  40583. use Composer\Semver\Constraint\Constraint;
  40584. class Semver
  40585. {
  40586. const SORT_ASC = 1;
  40587. const SORT_DESC = -1;
  40588. private static $versionParser;
  40589. public static function satisfies($version, $constraints)
  40590. {
  40591. if (null === self::$versionParser) {
  40592. self::$versionParser = new VersionParser();
  40593. }
  40594. $versionParser = self::$versionParser;
  40595. $provider = new Constraint('==', $versionParser->normalize($version));
  40596. $parsedConstraints = $versionParser->parseConstraints($constraints);
  40597. return $parsedConstraints->matches($provider);
  40598. }
  40599. public static function satisfiedBy(array $versions, $constraints)
  40600. {
  40601. $versions = array_filter($versions, function ($version) use ($constraints) {
  40602. return Semver::satisfies($version, $constraints);
  40603. });
  40604. return array_values($versions);
  40605. }
  40606. public static function sort(array $versions)
  40607. {
  40608. return self::usort($versions, self::SORT_ASC);
  40609. }
  40610. public static function rsort(array $versions)
  40611. {
  40612. return self::usort($versions, self::SORT_DESC);
  40613. }
  40614. private static function usort(array $versions, $direction)
  40615. {
  40616. if (null === self::$versionParser) {
  40617. self::$versionParser = new VersionParser();
  40618. }
  40619. $versionParser = self::$versionParser;
  40620. $normalized = array();
  40621. foreach ($versions as $key => $version) {
  40622. $normalizedVersion = $versionParser->normalize($version);
  40623. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  40624. $normalized[] = array($normalizedVersion, $key);
  40625. }
  40626. usort($normalized, function (array $left, array $right) use ($direction) {
  40627. if ($left[0] === $right[0]) {
  40628. return 0;
  40629. }
  40630. if (Comparator::lessThan($left[0], $right[0])) {
  40631. return -$direction;
  40632. }
  40633. return $direction;
  40634. });
  40635. $sorted = array();
  40636. foreach ($normalized as $item) {
  40637. $sorted[] = $versions[$item[1]];
  40638. }
  40639. return $sorted;
  40640. }
  40641. }
  40642. <?php
  40643. namespace Composer\Semver;
  40644. use Composer\Semver\Constraint\ConstraintInterface;
  40645. use Composer\Semver\Constraint\MatchAllConstraint;
  40646. use Composer\Semver\Constraint\MultiConstraint;
  40647. use Composer\Semver\Constraint\Constraint;
  40648. class VersionParser
  40649. {
  40650. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  40651. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  40652. public static function parseStability($version)
  40653. {
  40654. $version = preg_replace('{#.+$}', '', $version);
  40655. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  40656. return 'dev';
  40657. }
  40658. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  40659. if (!empty($match[3])) {
  40660. return 'dev';
  40661. }
  40662. if (!empty($match[1])) {
  40663. if ('beta' === $match[1] || 'b' === $match[1]) {
  40664. return 'beta';
  40665. }
  40666. if ('alpha' === $match[1] || 'a' === $match[1]) {
  40667. return 'alpha';
  40668. }
  40669. if ('rc' === $match[1]) {
  40670. return 'RC';
  40671. }
  40672. }
  40673. return 'stable';
  40674. }
  40675. public static function normalizeStability($stability)
  40676. {
  40677. $stability = strtolower($stability);
  40678. return $stability === 'rc' ? 'RC' : $stability;
  40679. }
  40680. public function normalize($version, $fullVersion = null)
  40681. {
  40682. $version = trim($version);
  40683. $origVersion = $version;
  40684. if (null === $fullVersion) {
  40685. $fullVersion = $version;
  40686. }
  40687. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  40688. $version = $match[1];
  40689. }
  40690. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  40691. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  40692. }
  40693. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  40694. $version = 'dev-' . $version;
  40695. }
  40696. if (stripos($version, 'dev-') === 0) {
  40697. return 'dev-' . substr($version, 4);
  40698. }
  40699. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  40700. $version = $match[1];
  40701. }
  40702. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  40703. $version = $matches[1]
  40704. . (!empty($matches[2]) ? $matches[2] : '.0')
  40705. . (!empty($matches[3]) ? $matches[3] : '.0')
  40706. . (!empty($matches[4]) ? $matches[4] : '.0');
  40707. $index = 5;
  40708. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  40709. $version = preg_replace('{\D}', '.', $matches[1]);
  40710. $index = 2;
  40711. }
  40712. if (isset($index)) {
  40713. if (!empty($matches[$index])) {
  40714. if ('stable' === $matches[$index]) {
  40715. return $version;
  40716. }
  40717. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  40718. }
  40719. if (!empty($matches[$index + 2])) {
  40720. $version .= '-dev';
  40721. }
  40722. return $version;
  40723. }
  40724. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  40725. try {
  40726. $normalized = $this->normalizeBranch($match[1]);
  40727. if (strpos($normalized, 'dev-') === false) {
  40728. return $normalized;
  40729. }
  40730. } catch (\Exception $e) {
  40731. }
  40732. }
  40733. $extraMessage = '';
  40734. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  40735. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  40736. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  40737. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  40738. }
  40739. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  40740. }
  40741. public function parseNumericAliasPrefix($branch)
  40742. {
  40743. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  40744. return $matches['version'] . '.';
  40745. }
  40746. return false;
  40747. }
  40748. public function normalizeBranch($name)
  40749. {
  40750. $name = trim($name);
  40751. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  40752. $version = '';
  40753. for ($i = 1; $i < 5; ++$i) {
  40754. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  40755. }
  40756. return str_replace('x', '9999999', $version) . '-dev';
  40757. }
  40758. return 'dev-' . $name;
  40759. }
  40760. public function normalizeDefaultBranch($name)
  40761. {
  40762. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  40763. return '9999999-dev';
  40764. }
  40765. return $name;
  40766. }
  40767. public function parseConstraints($constraints)
  40768. {
  40769. $prettyConstraint = $constraints;
  40770. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  40771. $orGroups = array();
  40772. foreach ($orConstraints as $constraints) {
  40773. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  40774. if (\count($andConstraints) > 1) {
  40775. $constraintObjects = array();
  40776. foreach ($andConstraints as $constraint) {
  40777. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  40778. $constraintObjects[] = $parsedConstraint;
  40779. }
  40780. }
  40781. } else {
  40782. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  40783. }
  40784. if (1 === \count($constraintObjects)) {
  40785. $constraint = $constraintObjects[0];
  40786. } else {
  40787. $constraint = new MultiConstraint($constraintObjects);
  40788. }
  40789. $orGroups[] = $constraint;
  40790. }
  40791. $constraint = MultiConstraint::create($orGroups, false);
  40792. $constraint->setPrettyString($prettyConstraint);
  40793. return $constraint;
  40794. }
  40795. private function parseConstraint($constraint)
  40796. {
  40797. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  40798. $constraint = $match[1];
  40799. }
  40800. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  40801. $constraint = '' !== $match[1] ? $match[1] : '*';
  40802. if ($match[2] !== 'stable') {
  40803. $stabilityModifier = $match[2];
  40804. }
  40805. }
  40806. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  40807. $constraint = $match[1];
  40808. }
  40809. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  40810. if (!empty($match[1]) || !empty($match[2])) {
  40811. return array(new Constraint('>=', '0.0.0.0-dev'));
  40812. }
  40813. return array(new MatchAllConstraint());
  40814. }
  40815. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  40816. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  40817. if (strpos($constraint, '~>') === 0) {
  40818. throw new \UnexpectedValueException(
  40819. 'Could not parse version constraint ' . $constraint . ': ' .
  40820. 'Invalid operator "~>", you probably meant to use the "~" operator'
  40821. );
  40822. }
  40823. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  40824. $position = 4;
  40825. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40826. $position = 3;
  40827. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40828. $position = 2;
  40829. } else {
  40830. $position = 1;
  40831. }
  40832. if (!empty($matches[8])) {
  40833. $position++;
  40834. }
  40835. $stabilitySuffix = '';
  40836. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40837. $stabilitySuffix .= '-dev';
  40838. }
  40839. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40840. $lowerBound = new Constraint('>=', $lowVersion);
  40841. $highPosition = max(1, $position - 1);
  40842. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  40843. $upperBound = new Constraint('<', $highVersion);
  40844. return array(
  40845. $lowerBound,
  40846. $upperBound,
  40847. );
  40848. }
  40849. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  40850. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  40851. $position = 1;
  40852. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  40853. $position = 2;
  40854. } else {
  40855. $position = 3;
  40856. }
  40857. $stabilitySuffix = '';
  40858. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40859. $stabilitySuffix .= '-dev';
  40860. }
  40861. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40862. $lowerBound = new Constraint('>=', $lowVersion);
  40863. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40864. $upperBound = new Constraint('<', $highVersion);
  40865. return array(
  40866. $lowerBound,
  40867. $upperBound,
  40868. );
  40869. }
  40870. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  40871. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40872. $position = 3;
  40873. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40874. $position = 2;
  40875. } else {
  40876. $position = 1;
  40877. }
  40878. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  40879. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40880. if ($lowVersion === '0.0.0.0-dev') {
  40881. return array(new Constraint('<', $highVersion));
  40882. }
  40883. return array(
  40884. new Constraint('>=', $lowVersion),
  40885. new Constraint('<', $highVersion),
  40886. );
  40887. }
  40888. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  40889. $lowStabilitySuffix = '';
  40890. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  40891. $lowStabilitySuffix = '-dev';
  40892. }
  40893. $lowVersion = $this->normalize($matches['from']);
  40894. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  40895. $empty = function ($x) {
  40896. return ($x === 0 || $x === '0') ? false : empty($x);
  40897. };
  40898. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  40899. $highVersion = $this->normalize($matches['to']);
  40900. $upperBound = new Constraint('<=', $highVersion);
  40901. } else {
  40902. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  40903. $this->normalize($matches['to']);
  40904. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  40905. $upperBound = new Constraint('<', $highVersion);
  40906. }
  40907. return array(
  40908. $lowerBound,
  40909. $upperBound,
  40910. );
  40911. }
  40912. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  40913. try {
  40914. try {
  40915. $version = $this->normalize($matches[2]);
  40916. } catch (\UnexpectedValueException $e) {
  40917. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  40918. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  40919. } else {
  40920. throw $e;
  40921. }
  40922. }
  40923. $op = $matches[1] ?: '=';
  40924. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  40925. $version .= '-' . $stabilityModifier;
  40926. } elseif ('<' === $op || '>=' === $op) {
  40927. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  40928. if (strpos($matches[2], 'dev-') !== 0) {
  40929. $version .= '-dev';
  40930. }
  40931. }
  40932. }
  40933. return array(new Constraint($matches[1] ?: '=', $version));
  40934. } catch (\Exception $e) {
  40935. }
  40936. }
  40937. $message = 'Could not parse version constraint ' . $constraint;
  40938. if (isset($e)) {
  40939. $message .= ': ' . $e->getMessage();
  40940. }
  40941. throw new \UnexpectedValueException($message);
  40942. }
  40943. private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
  40944. {
  40945. for ($i = 4; $i > 0; --$i) {
  40946. if ($i > $position) {
  40947. $matches[$i] = $pad;
  40948. } elseif ($i === $position && $increment) {
  40949. $matches[$i] += $increment;
  40950. if ($matches[$i] < 0) {
  40951. $matches[$i] = $pad;
  40952. --$position;
  40953. if ($i === 1) {
  40954. return null;
  40955. }
  40956. }
  40957. }
  40958. }
  40959. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  40960. }
  40961. private function expandStability($stability)
  40962. {
  40963. $stability = strtolower($stability);
  40964. switch ($stability) {
  40965. case 'a':
  40966. return 'alpha';
  40967. case 'b':
  40968. return 'beta';
  40969. case 'p':
  40970. case 'pl':
  40971. return 'patch';
  40972. case 'rc':
  40973. return 'RC';
  40974. default:
  40975. return $stability;
  40976. }
  40977. }
  40978. }
  40979. Copyright (C) 2015 Composer
  40980. Permission is hereby granted, free of charge, to any person obtaining a copy of
  40981. this software and associated documentation files (the "Software"), to deal in
  40982. the Software without restriction, including without limitation the rights to
  40983. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  40984. of the Software, and to permit persons to whom the Software is furnished to do
  40985. so, subject to the following conditions:
  40986. The above copyright notice and this permission notice shall be included in all
  40987. copies or substantial portions of the Software.
  40988. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  40989. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40990. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  40991. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  40992. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  40993. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  40994. SOFTWARE.
  40995. {
  40996. "389-exception": [
  40997. "389 Directory Server Exception"
  40998. ],
  40999. "Autoconf-exception-2.0": [
  41000. "Autoconf exception 2.0"
  41001. ],
  41002. "Autoconf-exception-3.0": [
  41003. "Autoconf exception 3.0"
  41004. ],
  41005. "Bison-exception-2.2": [
  41006. "Bison exception 2.2"
  41007. ],
  41008. "Bootloader-exception": [
  41009. "Bootloader Distribution Exception"
  41010. ],
  41011. "Classpath-exception-2.0": [
  41012. "Classpath exception 2.0"
  41013. ],
  41014. "CLISP-exception-2.0": [
  41015. "CLISP exception 2.0"
  41016. ],
  41017. "DigiRule-FOSS-exception": [
  41018. "DigiRule FOSS License Exception"
  41019. ],
  41020. "eCos-exception-2.0": [
  41021. "eCos exception 2.0"
  41022. ],
  41023. "Fawkes-Runtime-exception": [
  41024. "Fawkes Runtime Exception"
  41025. ],
  41026. "FLTK-exception": [
  41027. "FLTK exception"
  41028. ],
  41029. "Font-exception-2.0": [
  41030. "Font exception 2.0"
  41031. ],
  41032. "freertos-exception-2.0": [
  41033. "FreeRTOS Exception 2.0"
  41034. ],
  41035. "GCC-exception-2.0": [
  41036. "GCC Runtime Library exception 2.0"
  41037. ],
  41038. "GCC-exception-3.1": [
  41039. "GCC Runtime Library exception 3.1"
  41040. ],
  41041. "gnu-javamail-exception": [
  41042. "GNU JavaMail exception"
  41043. ],
  41044. "GPL-3.0-linking-exception": [
  41045. "GPL-3.0 Linking Exception"
  41046. ],
  41047. "GPL-3.0-linking-source-exception": [
  41048. "GPL-3.0 Linking Exception (with Corresponding Source)"
  41049. ],
  41050. "GPL-CC-1.0": [
  41051. "GPL Cooperation Commitment 1.0"
  41052. ],
  41053. "i2p-gpl-java-exception": [
  41054. "i2p GPL+Java Exception"
  41055. ],
  41056. "LGPL-3.0-linking-exception": [
  41057. "LGPL-3.0 Linking Exception"
  41058. ],
  41059. "Libtool-exception": [
  41060. "Libtool Exception"
  41061. ],
  41062. "Linux-syscall-note": [
  41063. "Linux Syscall Note"
  41064. ],
  41065. "LLVM-exception": [
  41066. "LLVM Exception"
  41067. ],
  41068. "LZMA-exception": [
  41069. "LZMA exception"
  41070. ],
  41071. "mif-exception": [
  41072. "Macros and Inline Functions Exception"
  41073. ],
  41074. "Nokia-Qt-exception-1.1": [
  41075. "Nokia Qt LGPL exception 1.1"
  41076. ],
  41077. "OCaml-LGPL-linking-exception": [
  41078. "OCaml LGPL Linking Exception"
  41079. ],
  41080. "OCCT-exception-1.0": [
  41081. "Open CASCADE Exception 1.0"
  41082. ],
  41083. "OpenJDK-assembly-exception-1.0": [
  41084. "OpenJDK Assembly exception 1.0"
  41085. ],
  41086. "openvpn-openssl-exception": [
  41087. "OpenVPN OpenSSL Exception"
  41088. ],
  41089. "PS-or-PDF-font-exception-20170817": [
  41090. "PS/PDF font exception (2017-08-17)"
  41091. ],
  41092. "Qt-GPL-exception-1.0": [
  41093. "Qt GPL exception 1.0"
  41094. ],
  41095. "Qt-LGPL-exception-1.1": [
  41096. "Qt LGPL exception 1.1"
  41097. ],
  41098. "Qwt-exception-1.0": [
  41099. "Qwt exception 1.0"
  41100. ],
  41101. "SHL-2.0": [
  41102. "Solderpad Hardware License v2.0"
  41103. ],
  41104. "SHL-2.1": [
  41105. "Solderpad Hardware License v2.1"
  41106. ],
  41107. "Swift-exception": [
  41108. "Swift Exception"
  41109. ],
  41110. "u-boot-exception-2.0": [
  41111. "U-Boot exception 2.0"
  41112. ],
  41113. "Universal-FOSS-exception-1.0": [
  41114. "Universal FOSS Exception, Version 1.0"
  41115. ],
  41116. "WxWindows-exception-3.1": [
  41117. "WxWindows Library Exception 3.1"
  41118. ]
  41119. }{
  41120. "0BSD": [
  41121. "BSD Zero Clause License",
  41122. true,
  41123. false
  41124. ],
  41125. "AAL": [
  41126. "Attribution Assurance License",
  41127. true,
  41128. false
  41129. ],
  41130. "Abstyles": [
  41131. "Abstyles License",
  41132. false,
  41133. false
  41134. ],
  41135. "Adobe-2006": [
  41136. "Adobe Systems Incorporated Source Code License Agreement",
  41137. false,
  41138. false
  41139. ],
  41140. "Adobe-Glyph": [
  41141. "Adobe Glyph List License",
  41142. false,
  41143. false
  41144. ],
  41145. "ADSL": [
  41146. "Amazon Digital Services License",
  41147. false,
  41148. false
  41149. ],
  41150. "AFL-1.1": [
  41151. "Academic Free License v1.1",
  41152. true,
  41153. false
  41154. ],
  41155. "AFL-1.2": [
  41156. "Academic Free License v1.2",
  41157. true,
  41158. false
  41159. ],
  41160. "AFL-2.0": [
  41161. "Academic Free License v2.0",
  41162. true,
  41163. false
  41164. ],
  41165. "AFL-2.1": [
  41166. "Academic Free License v2.1",
  41167. true,
  41168. false
  41169. ],
  41170. "AFL-3.0": [
  41171. "Academic Free License v3.0",
  41172. true,
  41173. false
  41174. ],
  41175. "Afmparse": [
  41176. "Afmparse License",
  41177. false,
  41178. false
  41179. ],
  41180. "AGPL-1.0": [
  41181. "Affero General Public License v1.0",
  41182. false,
  41183. true
  41184. ],
  41185. "AGPL-1.0-only": [
  41186. "Affero General Public License v1.0 only",
  41187. false,
  41188. false
  41189. ],
  41190. "AGPL-1.0-or-later": [
  41191. "Affero General Public License v1.0 or later",
  41192. false,
  41193. false
  41194. ],
  41195. "AGPL-3.0": [
  41196. "GNU Affero General Public License v3.0",
  41197. true,
  41198. true
  41199. ],
  41200. "AGPL-3.0-only": [
  41201. "GNU Affero General Public License v3.0 only",
  41202. true,
  41203. false
  41204. ],
  41205. "AGPL-3.0-or-later": [
  41206. "GNU Affero General Public License v3.0 or later",
  41207. true,
  41208. false
  41209. ],
  41210. "Aladdin": [
  41211. "Aladdin Free Public License",
  41212. false,
  41213. false
  41214. ],
  41215. "AMDPLPA": [
  41216. "AMD's plpa_map.c License",
  41217. false,
  41218. false
  41219. ],
  41220. "AML": [
  41221. "Apple MIT License",
  41222. false,
  41223. false
  41224. ],
  41225. "AMPAS": [
  41226. "Academy of Motion Picture Arts and Sciences BSD",
  41227. false,
  41228. false
  41229. ],
  41230. "ANTLR-PD": [
  41231. "ANTLR Software Rights Notice",
  41232. false,
  41233. false
  41234. ],
  41235. "ANTLR-PD-fallback": [
  41236. "ANTLR Software Rights Notice with license fallback",
  41237. false,
  41238. false
  41239. ],
  41240. "Apache-1.0": [
  41241. "Apache License 1.0",
  41242. false,
  41243. false
  41244. ],
  41245. "Apache-1.1": [
  41246. "Apache License 1.1",
  41247. true,
  41248. false
  41249. ],
  41250. "Apache-2.0": [
  41251. "Apache License 2.0",
  41252. true,
  41253. false
  41254. ],
  41255. "APAFML": [
  41256. "Adobe Postscript AFM License",
  41257. false,
  41258. false
  41259. ],
  41260. "APL-1.0": [
  41261. "Adaptive Public License 1.0",
  41262. true,
  41263. false
  41264. ],
  41265. "APSL-1.0": [
  41266. "Apple Public Source License 1.0",
  41267. true,
  41268. false
  41269. ],
  41270. "APSL-1.1": [
  41271. "Apple Public Source License 1.1",
  41272. true,
  41273. false
  41274. ],
  41275. "APSL-1.2": [
  41276. "Apple Public Source License 1.2",
  41277. true,
  41278. false
  41279. ],
  41280. "APSL-2.0": [
  41281. "Apple Public Source License 2.0",
  41282. true,
  41283. false
  41284. ],
  41285. "Artistic-1.0": [
  41286. "Artistic License 1.0",
  41287. true,
  41288. false
  41289. ],
  41290. "Artistic-1.0-cl8": [
  41291. "Artistic License 1.0 w/clause 8",
  41292. true,
  41293. false
  41294. ],
  41295. "Artistic-1.0-Perl": [
  41296. "Artistic License 1.0 (Perl)",
  41297. true,
  41298. false
  41299. ],
  41300. "Artistic-2.0": [
  41301. "Artistic License 2.0",
  41302. true,
  41303. false
  41304. ],
  41305. "Bahyph": [
  41306. "Bahyph License",
  41307. false,
  41308. false
  41309. ],
  41310. "Barr": [
  41311. "Barr License",
  41312. false,
  41313. false
  41314. ],
  41315. "Beerware": [
  41316. "Beerware License",
  41317. false,
  41318. false
  41319. ],
  41320. "BitTorrent-1.0": [
  41321. "BitTorrent Open Source License v1.0",
  41322. false,
  41323. false
  41324. ],
  41325. "BitTorrent-1.1": [
  41326. "BitTorrent Open Source License v1.1",
  41327. false,
  41328. false
  41329. ],
  41330. "blessing": [
  41331. "SQLite Blessing",
  41332. false,
  41333. false
  41334. ],
  41335. "BlueOak-1.0.0": [
  41336. "Blue Oak Model License 1.0.0",
  41337. false,
  41338. false
  41339. ],
  41340. "Borceux": [
  41341. "Borceux license",
  41342. false,
  41343. false
  41344. ],
  41345. "BSD-1-Clause": [
  41346. "BSD 1-Clause License",
  41347. true,
  41348. false
  41349. ],
  41350. "BSD-2-Clause": [
  41351. "BSD 2-Clause \"Simplified\" License",
  41352. true,
  41353. false
  41354. ],
  41355. "BSD-2-Clause-FreeBSD": [
  41356. "BSD 2-Clause FreeBSD License",
  41357. false,
  41358. true
  41359. ],
  41360. "BSD-2-Clause-NetBSD": [
  41361. "BSD 2-Clause NetBSD License",
  41362. false,
  41363. true
  41364. ],
  41365. "BSD-2-Clause-Patent": [
  41366. "BSD-2-Clause Plus Patent License",
  41367. true,
  41368. false
  41369. ],
  41370. "BSD-2-Clause-Views": [
  41371. "BSD 2-Clause with views sentence",
  41372. false,
  41373. false
  41374. ],
  41375. "BSD-3-Clause": [
  41376. "BSD 3-Clause \"New\" or \"Revised\" License",
  41377. true,
  41378. false
  41379. ],
  41380. "BSD-3-Clause-Attribution": [
  41381. "BSD with attribution",
  41382. false,
  41383. false
  41384. ],
  41385. "BSD-3-Clause-Clear": [
  41386. "BSD 3-Clause Clear License",
  41387. false,
  41388. false
  41389. ],
  41390. "BSD-3-Clause-LBNL": [
  41391. "Lawrence Berkeley National Labs BSD variant license",
  41392. true,
  41393. false
  41394. ],
  41395. "BSD-3-Clause-No-Nuclear-License": [
  41396. "BSD 3-Clause No Nuclear License",
  41397. false,
  41398. false
  41399. ],
  41400. "BSD-3-Clause-No-Nuclear-License-2014": [
  41401. "BSD 3-Clause No Nuclear License 2014",
  41402. false,
  41403. false
  41404. ],
  41405. "BSD-3-Clause-No-Nuclear-Warranty": [
  41406. "BSD 3-Clause No Nuclear Warranty",
  41407. false,
  41408. false
  41409. ],
  41410. "BSD-3-Clause-Open-MPI": [
  41411. "BSD 3-Clause Open MPI variant",
  41412. false,
  41413. false
  41414. ],
  41415. "BSD-4-Clause": [
  41416. "BSD 4-Clause \"Original\" or \"Old\" License",
  41417. false,
  41418. false
  41419. ],
  41420. "BSD-4-Clause-UC": [
  41421. "BSD-4-Clause (University of California-Specific)",
  41422. false,
  41423. false
  41424. ],
  41425. "BSD-Protection": [
  41426. "BSD Protection License",
  41427. false,
  41428. false
  41429. ],
  41430. "BSD-Source-Code": [
  41431. "BSD Source Code Attribution",
  41432. false,
  41433. false
  41434. ],
  41435. "BSL-1.0": [
  41436. "Boost Software License 1.0",
  41437. true,
  41438. false
  41439. ],
  41440. "BUSL-1.1": [
  41441. "Business Source License 1.1",
  41442. false,
  41443. false
  41444. ],
  41445. "bzip2-1.0.5": [
  41446. "bzip2 and libbzip2 License v1.0.5",
  41447. false,
  41448. false
  41449. ],
  41450. "bzip2-1.0.6": [
  41451. "bzip2 and libbzip2 License v1.0.6",
  41452. false,
  41453. false
  41454. ],
  41455. "CAL-1.0": [
  41456. "Cryptographic Autonomy License 1.0",
  41457. true,
  41458. false
  41459. ],
  41460. "CAL-1.0-Combined-Work-Exception": [
  41461. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  41462. true,
  41463. false
  41464. ],
  41465. "Caldera": [
  41466. "Caldera License",
  41467. false,
  41468. false
  41469. ],
  41470. "CATOSL-1.1": [
  41471. "Computer Associates Trusted Open Source License 1.1",
  41472. true,
  41473. false
  41474. ],
  41475. "CC-BY-1.0": [
  41476. "Creative Commons Attribution 1.0 Generic",
  41477. false,
  41478. false
  41479. ],
  41480. "CC-BY-2.0": [
  41481. "Creative Commons Attribution 2.0 Generic",
  41482. false,
  41483. false
  41484. ],
  41485. "CC-BY-2.5": [
  41486. "Creative Commons Attribution 2.5 Generic",
  41487. false,
  41488. false
  41489. ],
  41490. "CC-BY-3.0": [
  41491. "Creative Commons Attribution 3.0 Unported",
  41492. false,
  41493. false
  41494. ],
  41495. "CC-BY-3.0-AT": [
  41496. "Creative Commons Attribution 3.0 Austria",
  41497. false,
  41498. false
  41499. ],
  41500. "CC-BY-3.0-US": [
  41501. "Creative Commons Attribution 3.0 United States",
  41502. false,
  41503. false
  41504. ],
  41505. "CC-BY-4.0": [
  41506. "Creative Commons Attribution 4.0 International",
  41507. false,
  41508. false
  41509. ],
  41510. "CC-BY-NC-1.0": [
  41511. "Creative Commons Attribution Non Commercial 1.0 Generic",
  41512. false,
  41513. false
  41514. ],
  41515. "CC-BY-NC-2.0": [
  41516. "Creative Commons Attribution Non Commercial 2.0 Generic",
  41517. false,
  41518. false
  41519. ],
  41520. "CC-BY-NC-2.5": [
  41521. "Creative Commons Attribution Non Commercial 2.5 Generic",
  41522. false,
  41523. false
  41524. ],
  41525. "CC-BY-NC-3.0": [
  41526. "Creative Commons Attribution Non Commercial 3.0 Unported",
  41527. false,
  41528. false
  41529. ],
  41530. "CC-BY-NC-4.0": [
  41531. "Creative Commons Attribution Non Commercial 4.0 International",
  41532. false,
  41533. false
  41534. ],
  41535. "CC-BY-NC-ND-1.0": [
  41536. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  41537. false,
  41538. false
  41539. ],
  41540. "CC-BY-NC-ND-2.0": [
  41541. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  41542. false,
  41543. false
  41544. ],
  41545. "CC-BY-NC-ND-2.5": [
  41546. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  41547. false,
  41548. false
  41549. ],
  41550. "CC-BY-NC-ND-3.0": [
  41551. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  41552. false,
  41553. false
  41554. ],
  41555. "CC-BY-NC-ND-3.0-IGO": [
  41556. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  41557. false,
  41558. false
  41559. ],
  41560. "CC-BY-NC-ND-4.0": [
  41561. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  41562. false,
  41563. false
  41564. ],
  41565. "CC-BY-NC-SA-1.0": [
  41566. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  41567. false,
  41568. false
  41569. ],
  41570. "CC-BY-NC-SA-2.0": [
  41571. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  41572. false,
  41573. false
  41574. ],
  41575. "CC-BY-NC-SA-2.5": [
  41576. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  41577. false,
  41578. false
  41579. ],
  41580. "CC-BY-NC-SA-3.0": [
  41581. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  41582. false,
  41583. false
  41584. ],
  41585. "CC-BY-NC-SA-4.0": [
  41586. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  41587. false,
  41588. false
  41589. ],
  41590. "CC-BY-ND-1.0": [
  41591. "Creative Commons Attribution No Derivatives 1.0 Generic",
  41592. false,
  41593. false
  41594. ],
  41595. "CC-BY-ND-2.0": [
  41596. "Creative Commons Attribution No Derivatives 2.0 Generic",
  41597. false,
  41598. false
  41599. ],
  41600. "CC-BY-ND-2.5": [
  41601. "Creative Commons Attribution No Derivatives 2.5 Generic",
  41602. false,
  41603. false
  41604. ],
  41605. "CC-BY-ND-3.0": [
  41606. "Creative Commons Attribution No Derivatives 3.0 Unported",
  41607. false,
  41608. false
  41609. ],
  41610. "CC-BY-ND-4.0": [
  41611. "Creative Commons Attribution No Derivatives 4.0 International",
  41612. false,
  41613. false
  41614. ],
  41615. "CC-BY-SA-1.0": [
  41616. "Creative Commons Attribution Share Alike 1.0 Generic",
  41617. false,
  41618. false
  41619. ],
  41620. "CC-BY-SA-2.0": [
  41621. "Creative Commons Attribution Share Alike 2.0 Generic",
  41622. false,
  41623. false
  41624. ],
  41625. "CC-BY-SA-2.0-UK": [
  41626. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  41627. false,
  41628. false
  41629. ],
  41630. "CC-BY-SA-2.5": [
  41631. "Creative Commons Attribution Share Alike 2.5 Generic",
  41632. false,
  41633. false
  41634. ],
  41635. "CC-BY-SA-3.0": [
  41636. "Creative Commons Attribution Share Alike 3.0 Unported",
  41637. false,
  41638. false
  41639. ],
  41640. "CC-BY-SA-3.0-AT": [
  41641. "Creative Commons Attribution-Share Alike 3.0 Austria",
  41642. false,
  41643. false
  41644. ],
  41645. "CC-BY-SA-4.0": [
  41646. "Creative Commons Attribution Share Alike 4.0 International",
  41647. false,
  41648. false
  41649. ],
  41650. "CC-PDDC": [
  41651. "Creative Commons Public Domain Dedication and Certification",
  41652. false,
  41653. false
  41654. ],
  41655. "CC0-1.0": [
  41656. "Creative Commons Zero v1.0 Universal",
  41657. false,
  41658. false
  41659. ],
  41660. "CDDL-1.0": [
  41661. "Common Development and Distribution License 1.0",
  41662. true,
  41663. false
  41664. ],
  41665. "CDDL-1.1": [
  41666. "Common Development and Distribution License 1.1",
  41667. false,
  41668. false
  41669. ],
  41670. "CDLA-Permissive-1.0": [
  41671. "Community Data License Agreement Permissive 1.0",
  41672. false,
  41673. false
  41674. ],
  41675. "CDLA-Sharing-1.0": [
  41676. "Community Data License Agreement Sharing 1.0",
  41677. false,
  41678. false
  41679. ],
  41680. "CECILL-1.0": [
  41681. "CeCILL Free Software License Agreement v1.0",
  41682. false,
  41683. false
  41684. ],
  41685. "CECILL-1.1": [
  41686. "CeCILL Free Software License Agreement v1.1",
  41687. false,
  41688. false
  41689. ],
  41690. "CECILL-2.0": [
  41691. "CeCILL Free Software License Agreement v2.0",
  41692. false,
  41693. false
  41694. ],
  41695. "CECILL-2.1": [
  41696. "CeCILL Free Software License Agreement v2.1",
  41697. true,
  41698. false
  41699. ],
  41700. "CECILL-B": [
  41701. "CeCILL-B Free Software License Agreement",
  41702. false,
  41703. false
  41704. ],
  41705. "CECILL-C": [
  41706. "CeCILL-C Free Software License Agreement",
  41707. false,
  41708. false
  41709. ],
  41710. "CERN-OHL-1.1": [
  41711. "CERN Open Hardware Licence v1.1",
  41712. false,
  41713. false
  41714. ],
  41715. "CERN-OHL-1.2": [
  41716. "CERN Open Hardware Licence v1.2",
  41717. false,
  41718. false
  41719. ],
  41720. "CERN-OHL-P-2.0": [
  41721. "CERN Open Hardware Licence Version 2 - Permissive",
  41722. false,
  41723. false
  41724. ],
  41725. "CERN-OHL-S-2.0": [
  41726. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  41727. false,
  41728. false
  41729. ],
  41730. "CERN-OHL-W-2.0": [
  41731. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  41732. false,
  41733. false
  41734. ],
  41735. "ClArtistic": [
  41736. "Clarified Artistic License",
  41737. false,
  41738. false
  41739. ],
  41740. "CNRI-Jython": [
  41741. "CNRI Jython License",
  41742. false,
  41743. false
  41744. ],
  41745. "CNRI-Python": [
  41746. "CNRI Python License",
  41747. true,
  41748. false
  41749. ],
  41750. "CNRI-Python-GPL-Compatible": [
  41751. "CNRI Python Open Source GPL Compatible License Agreement",
  41752. false,
  41753. false
  41754. ],
  41755. "Condor-1.1": [
  41756. "Condor Public License v1.1",
  41757. false,
  41758. false
  41759. ],
  41760. "copyleft-next-0.3.0": [
  41761. "copyleft-next 0.3.0",
  41762. false,
  41763. false
  41764. ],
  41765. "copyleft-next-0.3.1": [
  41766. "copyleft-next 0.3.1",
  41767. false,
  41768. false
  41769. ],
  41770. "CPAL-1.0": [
  41771. "Common Public Attribution License 1.0",
  41772. true,
  41773. false
  41774. ],
  41775. "CPL-1.0": [
  41776. "Common Public License 1.0",
  41777. true,
  41778. false
  41779. ],
  41780. "CPOL-1.02": [
  41781. "Code Project Open License 1.02",
  41782. false,
  41783. false
  41784. ],
  41785. "Crossword": [
  41786. "Crossword License",
  41787. false,
  41788. false
  41789. ],
  41790. "CrystalStacker": [
  41791. "CrystalStacker License",
  41792. false,
  41793. false
  41794. ],
  41795. "CUA-OPL-1.0": [
  41796. "CUA Office Public License v1.0",
  41797. true,
  41798. false
  41799. ],
  41800. "Cube": [
  41801. "Cube License",
  41802. false,
  41803. false
  41804. ],
  41805. "curl": [
  41806. "curl License",
  41807. false,
  41808. false
  41809. ],
  41810. "D-FSL-1.0": [
  41811. "Deutsche Freie Software Lizenz",
  41812. false,
  41813. false
  41814. ],
  41815. "diffmark": [
  41816. "diffmark license",
  41817. false,
  41818. false
  41819. ],
  41820. "DOC": [
  41821. "DOC License",
  41822. false,
  41823. false
  41824. ],
  41825. "Dotseqn": [
  41826. "Dotseqn License",
  41827. false,
  41828. false
  41829. ],
  41830. "DSDP": [
  41831. "DSDP License",
  41832. false,
  41833. false
  41834. ],
  41835. "dvipdfm": [
  41836. "dvipdfm License",
  41837. false,
  41838. false
  41839. ],
  41840. "ECL-1.0": [
  41841. "Educational Community License v1.0",
  41842. true,
  41843. false
  41844. ],
  41845. "ECL-2.0": [
  41846. "Educational Community License v2.0",
  41847. true,
  41848. false
  41849. ],
  41850. "eCos-2.0": [
  41851. "eCos license version 2.0",
  41852. false,
  41853. true
  41854. ],
  41855. "EFL-1.0": [
  41856. "Eiffel Forum License v1.0",
  41857. true,
  41858. false
  41859. ],
  41860. "EFL-2.0": [
  41861. "Eiffel Forum License v2.0",
  41862. true,
  41863. false
  41864. ],
  41865. "eGenix": [
  41866. "eGenix.com Public License 1.1.0",
  41867. false,
  41868. false
  41869. ],
  41870. "Entessa": [
  41871. "Entessa Public License v1.0",
  41872. true,
  41873. false
  41874. ],
  41875. "EPICS": [
  41876. "EPICS Open License",
  41877. false,
  41878. false
  41879. ],
  41880. "EPL-1.0": [
  41881. "Eclipse Public License 1.0",
  41882. true,
  41883. false
  41884. ],
  41885. "EPL-2.0": [
  41886. "Eclipse Public License 2.0",
  41887. true,
  41888. false
  41889. ],
  41890. "ErlPL-1.1": [
  41891. "Erlang Public License v1.1",
  41892. false,
  41893. false
  41894. ],
  41895. "etalab-2.0": [
  41896. "Etalab Open License 2.0",
  41897. false,
  41898. false
  41899. ],
  41900. "EUDatagrid": [
  41901. "EU DataGrid Software License",
  41902. true,
  41903. false
  41904. ],
  41905. "EUPL-1.0": [
  41906. "European Union Public License 1.0",
  41907. false,
  41908. false
  41909. ],
  41910. "EUPL-1.1": [
  41911. "European Union Public License 1.1",
  41912. true,
  41913. false
  41914. ],
  41915. "EUPL-1.2": [
  41916. "European Union Public License 1.2",
  41917. true,
  41918. false
  41919. ],
  41920. "Eurosym": [
  41921. "Eurosym License",
  41922. false,
  41923. false
  41924. ],
  41925. "Fair": [
  41926. "Fair License",
  41927. true,
  41928. false
  41929. ],
  41930. "Frameworx-1.0": [
  41931. "Frameworx Open License 1.0",
  41932. true,
  41933. false
  41934. ],
  41935. "FreeImage": [
  41936. "FreeImage Public License v1.0",
  41937. false,
  41938. false
  41939. ],
  41940. "FSFAP": [
  41941. "FSF All Permissive License",
  41942. false,
  41943. false
  41944. ],
  41945. "FSFUL": [
  41946. "FSF Unlimited License",
  41947. false,
  41948. false
  41949. ],
  41950. "FSFULLR": [
  41951. "FSF Unlimited License (with License Retention)",
  41952. false,
  41953. false
  41954. ],
  41955. "FTL": [
  41956. "Freetype Project License",
  41957. false,
  41958. false
  41959. ],
  41960. "GFDL-1.1": [
  41961. "GNU Free Documentation License v1.1",
  41962. false,
  41963. true
  41964. ],
  41965. "GFDL-1.1-invariants-only": [
  41966. "GNU Free Documentation License v1.1 only - invariants",
  41967. false,
  41968. false
  41969. ],
  41970. "GFDL-1.1-invariants-or-later": [
  41971. "GNU Free Documentation License v1.1 or later - invariants",
  41972. false,
  41973. false
  41974. ],
  41975. "GFDL-1.1-no-invariants-only": [
  41976. "GNU Free Documentation License v1.1 only - no invariants",
  41977. false,
  41978. false
  41979. ],
  41980. "GFDL-1.1-no-invariants-or-later": [
  41981. "GNU Free Documentation License v1.1 or later - no invariants",
  41982. false,
  41983. false
  41984. ],
  41985. "GFDL-1.1-only": [
  41986. "GNU Free Documentation License v1.1 only",
  41987. false,
  41988. false
  41989. ],
  41990. "GFDL-1.1-or-later": [
  41991. "GNU Free Documentation License v1.1 or later",
  41992. false,
  41993. false
  41994. ],
  41995. "GFDL-1.2": [
  41996. "GNU Free Documentation License v1.2",
  41997. false,
  41998. true
  41999. ],
  42000. "GFDL-1.2-invariants-only": [
  42001. "GNU Free Documentation License v1.2 only - invariants",
  42002. false,
  42003. false
  42004. ],
  42005. "GFDL-1.2-invariants-or-later": [
  42006. "GNU Free Documentation License v1.2 or later - invariants",
  42007. false,
  42008. false
  42009. ],
  42010. "GFDL-1.2-no-invariants-only": [
  42011. "GNU Free Documentation License v1.2 only - no invariants",
  42012. false,
  42013. false
  42014. ],
  42015. "GFDL-1.2-no-invariants-or-later": [
  42016. "GNU Free Documentation License v1.2 or later - no invariants",
  42017. false,
  42018. false
  42019. ],
  42020. "GFDL-1.2-only": [
  42021. "GNU Free Documentation License v1.2 only",
  42022. false,
  42023. false
  42024. ],
  42025. "GFDL-1.2-or-later": [
  42026. "GNU Free Documentation License v1.2 or later",
  42027. false,
  42028. false
  42029. ],
  42030. "GFDL-1.3": [
  42031. "GNU Free Documentation License v1.3",
  42032. false,
  42033. true
  42034. ],
  42035. "GFDL-1.3-invariants-only": [
  42036. "GNU Free Documentation License v1.3 only - invariants",
  42037. false,
  42038. false
  42039. ],
  42040. "GFDL-1.3-invariants-or-later": [
  42041. "GNU Free Documentation License v1.3 or later - invariants",
  42042. false,
  42043. false
  42044. ],
  42045. "GFDL-1.3-no-invariants-only": [
  42046. "GNU Free Documentation License v1.3 only - no invariants",
  42047. false,
  42048. false
  42049. ],
  42050. "GFDL-1.3-no-invariants-or-later": [
  42051. "GNU Free Documentation License v1.3 or later - no invariants",
  42052. false,
  42053. false
  42054. ],
  42055. "GFDL-1.3-only": [
  42056. "GNU Free Documentation License v1.3 only",
  42057. false,
  42058. false
  42059. ],
  42060. "GFDL-1.3-or-later": [
  42061. "GNU Free Documentation License v1.3 or later",
  42062. false,
  42063. false
  42064. ],
  42065. "Giftware": [
  42066. "Giftware License",
  42067. false,
  42068. false
  42069. ],
  42070. "GL2PS": [
  42071. "GL2PS License",
  42072. false,
  42073. false
  42074. ],
  42075. "Glide": [
  42076. "3dfx Glide License",
  42077. false,
  42078. false
  42079. ],
  42080. "Glulxe": [
  42081. "Glulxe License",
  42082. false,
  42083. false
  42084. ],
  42085. "GLWTPL": [
  42086. "Good Luck With That Public License",
  42087. false,
  42088. false
  42089. ],
  42090. "gnuplot": [
  42091. "gnuplot License",
  42092. false,
  42093. false
  42094. ],
  42095. "GPL-1.0": [
  42096. "GNU General Public License v1.0 only",
  42097. false,
  42098. true
  42099. ],
  42100. "GPL-1.0+": [
  42101. "GNU General Public License v1.0 or later",
  42102. false,
  42103. true
  42104. ],
  42105. "GPL-1.0-only": [
  42106. "GNU General Public License v1.0 only",
  42107. false,
  42108. false
  42109. ],
  42110. "GPL-1.0-or-later": [
  42111. "GNU General Public License v1.0 or later",
  42112. false,
  42113. false
  42114. ],
  42115. "GPL-2.0": [
  42116. "GNU General Public License v2.0 only",
  42117. true,
  42118. true
  42119. ],
  42120. "GPL-2.0+": [
  42121. "GNU General Public License v2.0 or later",
  42122. true,
  42123. true
  42124. ],
  42125. "GPL-2.0-only": [
  42126. "GNU General Public License v2.0 only",
  42127. true,
  42128. false
  42129. ],
  42130. "GPL-2.0-or-later": [
  42131. "GNU General Public License v2.0 or later",
  42132. true,
  42133. false
  42134. ],
  42135. "GPL-2.0-with-autoconf-exception": [
  42136. "GNU General Public License v2.0 w/Autoconf exception",
  42137. false,
  42138. true
  42139. ],
  42140. "GPL-2.0-with-bison-exception": [
  42141. "GNU General Public License v2.0 w/Bison exception",
  42142. false,
  42143. true
  42144. ],
  42145. "GPL-2.0-with-classpath-exception": [
  42146. "GNU General Public License v2.0 w/Classpath exception",
  42147. false,
  42148. true
  42149. ],
  42150. "GPL-2.0-with-font-exception": [
  42151. "GNU General Public License v2.0 w/Font exception",
  42152. false,
  42153. true
  42154. ],
  42155. "GPL-2.0-with-GCC-exception": [
  42156. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  42157. false,
  42158. true
  42159. ],
  42160. "GPL-3.0": [
  42161. "GNU General Public License v3.0 only",
  42162. true,
  42163. true
  42164. ],
  42165. "GPL-3.0+": [
  42166. "GNU General Public License v3.0 or later",
  42167. true,
  42168. true
  42169. ],
  42170. "GPL-3.0-only": [
  42171. "GNU General Public License v3.0 only",
  42172. true,
  42173. false
  42174. ],
  42175. "GPL-3.0-or-later": [
  42176. "GNU General Public License v3.0 or later",
  42177. true,
  42178. false
  42179. ],
  42180. "GPL-3.0-with-autoconf-exception": [
  42181. "GNU General Public License v3.0 w/Autoconf exception",
  42182. false,
  42183. true
  42184. ],
  42185. "GPL-3.0-with-GCC-exception": [
  42186. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  42187. true,
  42188. true
  42189. ],
  42190. "gSOAP-1.3b": [
  42191. "gSOAP Public License v1.3b",
  42192. false,
  42193. false
  42194. ],
  42195. "HaskellReport": [
  42196. "Haskell Language Report License",
  42197. false,
  42198. false
  42199. ],
  42200. "Hippocratic-2.1": [
  42201. "Hippocratic License 2.1",
  42202. false,
  42203. false
  42204. ],
  42205. "HPND": [
  42206. "Historical Permission Notice and Disclaimer",
  42207. true,
  42208. false
  42209. ],
  42210. "HPND-sell-variant": [
  42211. "Historical Permission Notice and Disclaimer - sell variant",
  42212. false,
  42213. false
  42214. ],
  42215. "HTMLTIDY": [
  42216. "HTML Tidy License",
  42217. false,
  42218. false
  42219. ],
  42220. "IBM-pibs": [
  42221. "IBM PowerPC Initialization and Boot Software",
  42222. false,
  42223. false
  42224. ],
  42225. "ICU": [
  42226. "ICU License",
  42227. false,
  42228. false
  42229. ],
  42230. "IJG": [
  42231. "Independent JPEG Group License",
  42232. false,
  42233. false
  42234. ],
  42235. "ImageMagick": [
  42236. "ImageMagick License",
  42237. false,
  42238. false
  42239. ],
  42240. "iMatix": [
  42241. "iMatix Standard Function Library Agreement",
  42242. false,
  42243. false
  42244. ],
  42245. "Imlib2": [
  42246. "Imlib2 License",
  42247. false,
  42248. false
  42249. ],
  42250. "Info-ZIP": [
  42251. "Info-ZIP License",
  42252. false,
  42253. false
  42254. ],
  42255. "Intel": [
  42256. "Intel Open Source License",
  42257. true,
  42258. false
  42259. ],
  42260. "Intel-ACPI": [
  42261. "Intel ACPI Software License Agreement",
  42262. false,
  42263. false
  42264. ],
  42265. "Interbase-1.0": [
  42266. "Interbase Public License v1.0",
  42267. false,
  42268. false
  42269. ],
  42270. "IPA": [
  42271. "IPA Font License",
  42272. true,
  42273. false
  42274. ],
  42275. "IPL-1.0": [
  42276. "IBM Public License v1.0",
  42277. true,
  42278. false
  42279. ],
  42280. "ISC": [
  42281. "ISC License",
  42282. true,
  42283. false
  42284. ],
  42285. "JasPer-2.0": [
  42286. "JasPer License",
  42287. false,
  42288. false
  42289. ],
  42290. "JPNIC": [
  42291. "Japan Network Information Center License",
  42292. false,
  42293. false
  42294. ],
  42295. "JSON": [
  42296. "JSON License",
  42297. false,
  42298. false
  42299. ],
  42300. "LAL-1.2": [
  42301. "Licence Art Libre 1.2",
  42302. false,
  42303. false
  42304. ],
  42305. "LAL-1.3": [
  42306. "Licence Art Libre 1.3",
  42307. false,
  42308. false
  42309. ],
  42310. "Latex2e": [
  42311. "Latex2e License",
  42312. false,
  42313. false
  42314. ],
  42315. "Leptonica": [
  42316. "Leptonica License",
  42317. false,
  42318. false
  42319. ],
  42320. "LGPL-2.0": [
  42321. "GNU Library General Public License v2 only",
  42322. true,
  42323. true
  42324. ],
  42325. "LGPL-2.0+": [
  42326. "GNU Library General Public License v2 or later",
  42327. true,
  42328. true
  42329. ],
  42330. "LGPL-2.0-only": [
  42331. "GNU Library General Public License v2 only",
  42332. true,
  42333. false
  42334. ],
  42335. "LGPL-2.0-or-later": [
  42336. "GNU Library General Public License v2 or later",
  42337. true,
  42338. false
  42339. ],
  42340. "LGPL-2.1": [
  42341. "GNU Lesser General Public License v2.1 only",
  42342. true,
  42343. true
  42344. ],
  42345. "LGPL-2.1+": [
  42346. "GNU Library General Public License v2.1 or later",
  42347. true,
  42348. true
  42349. ],
  42350. "LGPL-2.1-only": [
  42351. "GNU Lesser General Public License v2.1 only",
  42352. true,
  42353. false
  42354. ],
  42355. "LGPL-2.1-or-later": [
  42356. "GNU Lesser General Public License v2.1 or later",
  42357. true,
  42358. false
  42359. ],
  42360. "LGPL-3.0": [
  42361. "GNU Lesser General Public License v3.0 only",
  42362. true,
  42363. true
  42364. ],
  42365. "LGPL-3.0+": [
  42366. "GNU Lesser General Public License v3.0 or later",
  42367. true,
  42368. true
  42369. ],
  42370. "LGPL-3.0-only": [
  42371. "GNU Lesser General Public License v3.0 only",
  42372. true,
  42373. false
  42374. ],
  42375. "LGPL-3.0-or-later": [
  42376. "GNU Lesser General Public License v3.0 or later",
  42377. true,
  42378. false
  42379. ],
  42380. "LGPLLR": [
  42381. "Lesser General Public License For Linguistic Resources",
  42382. false,
  42383. false
  42384. ],
  42385. "Libpng": [
  42386. "libpng License",
  42387. false,
  42388. false
  42389. ],
  42390. "libpng-2.0": [
  42391. "PNG Reference Library version 2",
  42392. false,
  42393. false
  42394. ],
  42395. "libselinux-1.0": [
  42396. "libselinux public domain notice",
  42397. false,
  42398. false
  42399. ],
  42400. "libtiff": [
  42401. "libtiff License",
  42402. false,
  42403. false
  42404. ],
  42405. "LiLiQ-P-1.1": [
  42406. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  42407. true,
  42408. false
  42409. ],
  42410. "LiLiQ-R-1.1": [
  42411. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  42412. true,
  42413. false
  42414. ],
  42415. "LiLiQ-Rplus-1.1": [
  42416. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  42417. true,
  42418. false
  42419. ],
  42420. "Linux-OpenIB": [
  42421. "Linux Kernel Variant of OpenIB.org license",
  42422. false,
  42423. false
  42424. ],
  42425. "LPL-1.0": [
  42426. "Lucent Public License Version 1.0",
  42427. true,
  42428. false
  42429. ],
  42430. "LPL-1.02": [
  42431. "Lucent Public License v1.02",
  42432. true,
  42433. false
  42434. ],
  42435. "LPPL-1.0": [
  42436. "LaTeX Project Public License v1.0",
  42437. false,
  42438. false
  42439. ],
  42440. "LPPL-1.1": [
  42441. "LaTeX Project Public License v1.1",
  42442. false,
  42443. false
  42444. ],
  42445. "LPPL-1.2": [
  42446. "LaTeX Project Public License v1.2",
  42447. false,
  42448. false
  42449. ],
  42450. "LPPL-1.3a": [
  42451. "LaTeX Project Public License v1.3a",
  42452. false,
  42453. false
  42454. ],
  42455. "LPPL-1.3c": [
  42456. "LaTeX Project Public License v1.3c",
  42457. true,
  42458. false
  42459. ],
  42460. "MakeIndex": [
  42461. "MakeIndex License",
  42462. false,
  42463. false
  42464. ],
  42465. "MirOS": [
  42466. "The MirOS Licence",
  42467. true,
  42468. false
  42469. ],
  42470. "MIT": [
  42471. "MIT License",
  42472. true,
  42473. false
  42474. ],
  42475. "MIT-0": [
  42476. "MIT No Attribution",
  42477. true,
  42478. false
  42479. ],
  42480. "MIT-advertising": [
  42481. "Enlightenment License (e16)",
  42482. false,
  42483. false
  42484. ],
  42485. "MIT-CMU": [
  42486. "CMU License",
  42487. false,
  42488. false
  42489. ],
  42490. "MIT-enna": [
  42491. "enna License",
  42492. false,
  42493. false
  42494. ],
  42495. "MIT-feh": [
  42496. "feh License",
  42497. false,
  42498. false
  42499. ],
  42500. "MIT-open-group": [
  42501. "MIT Open Group variant",
  42502. false,
  42503. false
  42504. ],
  42505. "MITNFA": [
  42506. "MIT +no-false-attribs license",
  42507. false,
  42508. false
  42509. ],
  42510. "Motosoto": [
  42511. "Motosoto License",
  42512. true,
  42513. false
  42514. ],
  42515. "mpich2": [
  42516. "mpich2 License",
  42517. false,
  42518. false
  42519. ],
  42520. "MPL-1.0": [
  42521. "Mozilla Public License 1.0",
  42522. true,
  42523. false
  42524. ],
  42525. "MPL-1.1": [
  42526. "Mozilla Public License 1.1",
  42527. true,
  42528. false
  42529. ],
  42530. "MPL-2.0": [
  42531. "Mozilla Public License 2.0",
  42532. true,
  42533. false
  42534. ],
  42535. "MPL-2.0-no-copyleft-exception": [
  42536. "Mozilla Public License 2.0 (no copyleft exception)",
  42537. true,
  42538. false
  42539. ],
  42540. "MS-PL": [
  42541. "Microsoft Public License",
  42542. true,
  42543. false
  42544. ],
  42545. "MS-RL": [
  42546. "Microsoft Reciprocal License",
  42547. true,
  42548. false
  42549. ],
  42550. "MTLL": [
  42551. "Matrix Template Library License",
  42552. false,
  42553. false
  42554. ],
  42555. "MulanPSL-1.0": [
  42556. "Mulan Permissive Software License, Version 1",
  42557. false,
  42558. false
  42559. ],
  42560. "MulanPSL-2.0": [
  42561. "Mulan Permissive Software License, Version 2",
  42562. true,
  42563. false
  42564. ],
  42565. "Multics": [
  42566. "Multics License",
  42567. true,
  42568. false
  42569. ],
  42570. "Mup": [
  42571. "Mup License",
  42572. false,
  42573. false
  42574. ],
  42575. "NASA-1.3": [
  42576. "NASA Open Source Agreement 1.3",
  42577. true,
  42578. false
  42579. ],
  42580. "Naumen": [
  42581. "Naumen Public License",
  42582. true,
  42583. false
  42584. ],
  42585. "NBPL-1.0": [
  42586. "Net Boolean Public License v1",
  42587. false,
  42588. false
  42589. ],
  42590. "NCGL-UK-2.0": [
  42591. "Non-Commercial Government Licence",
  42592. false,
  42593. false
  42594. ],
  42595. "NCSA": [
  42596. "University of Illinois/NCSA Open Source License",
  42597. true,
  42598. false
  42599. ],
  42600. "Net-SNMP": [
  42601. "Net-SNMP License",
  42602. false,
  42603. false
  42604. ],
  42605. "NetCDF": [
  42606. "NetCDF license",
  42607. false,
  42608. false
  42609. ],
  42610. "Newsletr": [
  42611. "Newsletr License",
  42612. false,
  42613. false
  42614. ],
  42615. "NGPL": [
  42616. "Nethack General Public License",
  42617. true,
  42618. false
  42619. ],
  42620. "NIST-PD": [
  42621. "NIST Public Domain Notice",
  42622. false,
  42623. false
  42624. ],
  42625. "NIST-PD-fallback": [
  42626. "NIST Public Domain Notice with license fallback",
  42627. false,
  42628. false
  42629. ],
  42630. "NLOD-1.0": [
  42631. "Norwegian Licence for Open Government Data",
  42632. false,
  42633. false
  42634. ],
  42635. "NLPL": [
  42636. "No Limit Public License",
  42637. false,
  42638. false
  42639. ],
  42640. "Nokia": [
  42641. "Nokia Open Source License",
  42642. true,
  42643. false
  42644. ],
  42645. "NOSL": [
  42646. "Netizen Open Source License",
  42647. false,
  42648. false
  42649. ],
  42650. "Noweb": [
  42651. "Noweb License",
  42652. false,
  42653. false
  42654. ],
  42655. "NPL-1.0": [
  42656. "Netscape Public License v1.0",
  42657. false,
  42658. false
  42659. ],
  42660. "NPL-1.1": [
  42661. "Netscape Public License v1.1",
  42662. false,
  42663. false
  42664. ],
  42665. "NPOSL-3.0": [
  42666. "Non-Profit Open Software License 3.0",
  42667. true,
  42668. false
  42669. ],
  42670. "NRL": [
  42671. "NRL License",
  42672. false,
  42673. false
  42674. ],
  42675. "NTP": [
  42676. "NTP License",
  42677. true,
  42678. false
  42679. ],
  42680. "NTP-0": [
  42681. "NTP No Attribution",
  42682. false,
  42683. false
  42684. ],
  42685. "Nunit": [
  42686. "Nunit License",
  42687. false,
  42688. true
  42689. ],
  42690. "O-UDA-1.0": [
  42691. "Open Use of Data Agreement v1.0",
  42692. false,
  42693. false
  42694. ],
  42695. "OCCT-PL": [
  42696. "Open CASCADE Technology Public License",
  42697. false,
  42698. false
  42699. ],
  42700. "OCLC-2.0": [
  42701. "OCLC Research Public License 2.0",
  42702. true,
  42703. false
  42704. ],
  42705. "ODbL-1.0": [
  42706. "ODC Open Database License v1.0",
  42707. false,
  42708. false
  42709. ],
  42710. "ODC-By-1.0": [
  42711. "Open Data Commons Attribution License v1.0",
  42712. false,
  42713. false
  42714. ],
  42715. "OFL-1.0": [
  42716. "SIL Open Font License 1.0",
  42717. false,
  42718. false
  42719. ],
  42720. "OFL-1.0-no-RFN": [
  42721. "SIL Open Font License 1.0 with no Reserved Font Name",
  42722. false,
  42723. false
  42724. ],
  42725. "OFL-1.0-RFN": [
  42726. "SIL Open Font License 1.0 with Reserved Font Name",
  42727. false,
  42728. false
  42729. ],
  42730. "OFL-1.1": [
  42731. "SIL Open Font License 1.1",
  42732. true,
  42733. false
  42734. ],
  42735. "OFL-1.1-no-RFN": [
  42736. "SIL Open Font License 1.1 with no Reserved Font Name",
  42737. true,
  42738. false
  42739. ],
  42740. "OFL-1.1-RFN": [
  42741. "SIL Open Font License 1.1 with Reserved Font Name",
  42742. true,
  42743. false
  42744. ],
  42745. "OGC-1.0": [
  42746. "OGC Software License, Version 1.0",
  42747. false,
  42748. false
  42749. ],
  42750. "OGL-Canada-2.0": [
  42751. "Open Government Licence - Canada",
  42752. false,
  42753. false
  42754. ],
  42755. "OGL-UK-1.0": [
  42756. "Open Government Licence v1.0",
  42757. false,
  42758. false
  42759. ],
  42760. "OGL-UK-2.0": [
  42761. "Open Government Licence v2.0",
  42762. false,
  42763. false
  42764. ],
  42765. "OGL-UK-3.0": [
  42766. "Open Government Licence v3.0",
  42767. false,
  42768. false
  42769. ],
  42770. "OGTSL": [
  42771. "Open Group Test Suite License",
  42772. true,
  42773. false
  42774. ],
  42775. "OLDAP-1.1": [
  42776. "Open LDAP Public License v1.1",
  42777. false,
  42778. false
  42779. ],
  42780. "OLDAP-1.2": [
  42781. "Open LDAP Public License v1.2",
  42782. false,
  42783. false
  42784. ],
  42785. "OLDAP-1.3": [
  42786. "Open LDAP Public License v1.3",
  42787. false,
  42788. false
  42789. ],
  42790. "OLDAP-1.4": [
  42791. "Open LDAP Public License v1.4",
  42792. false,
  42793. false
  42794. ],
  42795. "OLDAP-2.0": [
  42796. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  42797. false,
  42798. false
  42799. ],
  42800. "OLDAP-2.0.1": [
  42801. "Open LDAP Public License v2.0.1",
  42802. false,
  42803. false
  42804. ],
  42805. "OLDAP-2.1": [
  42806. "Open LDAP Public License v2.1",
  42807. false,
  42808. false
  42809. ],
  42810. "OLDAP-2.2": [
  42811. "Open LDAP Public License v2.2",
  42812. false,
  42813. false
  42814. ],
  42815. "OLDAP-2.2.1": [
  42816. "Open LDAP Public License v2.2.1",
  42817. false,
  42818. false
  42819. ],
  42820. "OLDAP-2.2.2": [
  42821. "Open LDAP Public License 2.2.2",
  42822. false,
  42823. false
  42824. ],
  42825. "OLDAP-2.3": [
  42826. "Open LDAP Public License v2.3",
  42827. false,
  42828. false
  42829. ],
  42830. "OLDAP-2.4": [
  42831. "Open LDAP Public License v2.4",
  42832. false,
  42833. false
  42834. ],
  42835. "OLDAP-2.5": [
  42836. "Open LDAP Public License v2.5",
  42837. false,
  42838. false
  42839. ],
  42840. "OLDAP-2.6": [
  42841. "Open LDAP Public License v2.6",
  42842. false,
  42843. false
  42844. ],
  42845. "OLDAP-2.7": [
  42846. "Open LDAP Public License v2.7",
  42847. false,
  42848. false
  42849. ],
  42850. "OLDAP-2.8": [
  42851. "Open LDAP Public License v2.8",
  42852. true,
  42853. false
  42854. ],
  42855. "OML": [
  42856. "Open Market License",
  42857. false,
  42858. false
  42859. ],
  42860. "OpenSSL": [
  42861. "OpenSSL License",
  42862. false,
  42863. false
  42864. ],
  42865. "OPL-1.0": [
  42866. "Open Public License v1.0",
  42867. false,
  42868. false
  42869. ],
  42870. "OSET-PL-2.1": [
  42871. "OSET Public License version 2.1",
  42872. true,
  42873. false
  42874. ],
  42875. "OSL-1.0": [
  42876. "Open Software License 1.0",
  42877. true,
  42878. false
  42879. ],
  42880. "OSL-1.1": [
  42881. "Open Software License 1.1",
  42882. false,
  42883. false
  42884. ],
  42885. "OSL-2.0": [
  42886. "Open Software License 2.0",
  42887. true,
  42888. false
  42889. ],
  42890. "OSL-2.1": [
  42891. "Open Software License 2.1",
  42892. true,
  42893. false
  42894. ],
  42895. "OSL-3.0": [
  42896. "Open Software License 3.0",
  42897. true,
  42898. false
  42899. ],
  42900. "Parity-6.0.0": [
  42901. "The Parity Public License 6.0.0",
  42902. false,
  42903. false
  42904. ],
  42905. "Parity-7.0.0": [
  42906. "The Parity Public License 7.0.0",
  42907. false,
  42908. false
  42909. ],
  42910. "PDDL-1.0": [
  42911. "ODC Public Domain Dedication & License 1.0",
  42912. false,
  42913. false
  42914. ],
  42915. "PHP-3.0": [
  42916. "PHP License v3.0",
  42917. true,
  42918. false
  42919. ],
  42920. "PHP-3.01": [
  42921. "PHP License v3.01",
  42922. true,
  42923. false
  42924. ],
  42925. "Plexus": [
  42926. "Plexus Classworlds License",
  42927. false,
  42928. false
  42929. ],
  42930. "PolyForm-Noncommercial-1.0.0": [
  42931. "PolyForm Noncommercial License 1.0.0",
  42932. false,
  42933. false
  42934. ],
  42935. "PolyForm-Small-Business-1.0.0": [
  42936. "PolyForm Small Business License 1.0.0",
  42937. false,
  42938. false
  42939. ],
  42940. "PostgreSQL": [
  42941. "PostgreSQL License",
  42942. true,
  42943. false
  42944. ],
  42945. "PSF-2.0": [
  42946. "Python Software Foundation License 2.0",
  42947. false,
  42948. false
  42949. ],
  42950. "psfrag": [
  42951. "psfrag License",
  42952. false,
  42953. false
  42954. ],
  42955. "psutils": [
  42956. "psutils License",
  42957. false,
  42958. false
  42959. ],
  42960. "Python-2.0": [
  42961. "Python License 2.0",
  42962. true,
  42963. false
  42964. ],
  42965. "Qhull": [
  42966. "Qhull License",
  42967. false,
  42968. false
  42969. ],
  42970. "QPL-1.0": [
  42971. "Q Public License 1.0",
  42972. true,
  42973. false
  42974. ],
  42975. "Rdisc": [
  42976. "Rdisc License",
  42977. false,
  42978. false
  42979. ],
  42980. "RHeCos-1.1": [
  42981. "Red Hat eCos Public License v1.1",
  42982. false,
  42983. false
  42984. ],
  42985. "RPL-1.1": [
  42986. "Reciprocal Public License 1.1",
  42987. true,
  42988. false
  42989. ],
  42990. "RPL-1.5": [
  42991. "Reciprocal Public License 1.5",
  42992. true,
  42993. false
  42994. ],
  42995. "RPSL-1.0": [
  42996. "RealNetworks Public Source License v1.0",
  42997. true,
  42998. false
  42999. ],
  43000. "RSA-MD": [
  43001. "RSA Message-Digest License",
  43002. false,
  43003. false
  43004. ],
  43005. "RSCPL": [
  43006. "Ricoh Source Code Public License",
  43007. true,
  43008. false
  43009. ],
  43010. "Ruby": [
  43011. "Ruby License",
  43012. false,
  43013. false
  43014. ],
  43015. "SAX-PD": [
  43016. "Sax Public Domain Notice",
  43017. false,
  43018. false
  43019. ],
  43020. "Saxpath": [
  43021. "Saxpath License",
  43022. false,
  43023. false
  43024. ],
  43025. "SCEA": [
  43026. "SCEA Shared Source License",
  43027. false,
  43028. false
  43029. ],
  43030. "Sendmail": [
  43031. "Sendmail License",
  43032. false,
  43033. false
  43034. ],
  43035. "Sendmail-8.23": [
  43036. "Sendmail License 8.23",
  43037. false,
  43038. false
  43039. ],
  43040. "SGI-B-1.0": [
  43041. "SGI Free Software License B v1.0",
  43042. false,
  43043. false
  43044. ],
  43045. "SGI-B-1.1": [
  43046. "SGI Free Software License B v1.1",
  43047. false,
  43048. false
  43049. ],
  43050. "SGI-B-2.0": [
  43051. "SGI Free Software License B v2.0",
  43052. false,
  43053. false
  43054. ],
  43055. "SHL-0.5": [
  43056. "Solderpad Hardware License v0.5",
  43057. false,
  43058. false
  43059. ],
  43060. "SHL-0.51": [
  43061. "Solderpad Hardware License, Version 0.51",
  43062. false,
  43063. false
  43064. ],
  43065. "SimPL-2.0": [
  43066. "Simple Public License 2.0",
  43067. true,
  43068. false
  43069. ],
  43070. "SISSL": [
  43071. "Sun Industry Standards Source License v1.1",
  43072. true,
  43073. false
  43074. ],
  43075. "SISSL-1.2": [
  43076. "Sun Industry Standards Source License v1.2",
  43077. false,
  43078. false
  43079. ],
  43080. "Sleepycat": [
  43081. "Sleepycat License",
  43082. true,
  43083. false
  43084. ],
  43085. "SMLNJ": [
  43086. "Standard ML of New Jersey License",
  43087. false,
  43088. false
  43089. ],
  43090. "SMPPL": [
  43091. "Secure Messaging Protocol Public License",
  43092. false,
  43093. false
  43094. ],
  43095. "SNIA": [
  43096. "SNIA Public License 1.1",
  43097. false,
  43098. false
  43099. ],
  43100. "Spencer-86": [
  43101. "Spencer License 86",
  43102. false,
  43103. false
  43104. ],
  43105. "Spencer-94": [
  43106. "Spencer License 94",
  43107. false,
  43108. false
  43109. ],
  43110. "Spencer-99": [
  43111. "Spencer License 99",
  43112. false,
  43113. false
  43114. ],
  43115. "SPL-1.0": [
  43116. "Sun Public License v1.0",
  43117. true,
  43118. false
  43119. ],
  43120. "SSH-OpenSSH": [
  43121. "SSH OpenSSH license",
  43122. false,
  43123. false
  43124. ],
  43125. "SSH-short": [
  43126. "SSH short notice",
  43127. false,
  43128. false
  43129. ],
  43130. "SSPL-1.0": [
  43131. "Server Side Public License, v 1",
  43132. false,
  43133. false
  43134. ],
  43135. "StandardML-NJ": [
  43136. "Standard ML of New Jersey License",
  43137. false,
  43138. true
  43139. ],
  43140. "SugarCRM-1.1.3": [
  43141. "SugarCRM Public License v1.1.3",
  43142. false,
  43143. false
  43144. ],
  43145. "SWL": [
  43146. "Scheme Widget Library (SWL) Software License Agreement",
  43147. false,
  43148. false
  43149. ],
  43150. "TAPR-OHL-1.0": [
  43151. "TAPR Open Hardware License v1.0",
  43152. false,
  43153. false
  43154. ],
  43155. "TCL": [
  43156. "TCL/TK License",
  43157. false,
  43158. false
  43159. ],
  43160. "TCP-wrappers": [
  43161. "TCP Wrappers License",
  43162. false,
  43163. false
  43164. ],
  43165. "TMate": [
  43166. "TMate Open Source License",
  43167. false,
  43168. false
  43169. ],
  43170. "TORQUE-1.1": [
  43171. "TORQUE v2.5+ Software License v1.1",
  43172. false,
  43173. false
  43174. ],
  43175. "TOSL": [
  43176. "Trusster Open Source License",
  43177. false,
  43178. false
  43179. ],
  43180. "TU-Berlin-1.0": [
  43181. "Technische Universitaet Berlin License 1.0",
  43182. false,
  43183. false
  43184. ],
  43185. "TU-Berlin-2.0": [
  43186. "Technische Universitaet Berlin License 2.0",
  43187. false,
  43188. false
  43189. ],
  43190. "UCL-1.0": [
  43191. "Upstream Compatibility License v1.0",
  43192. true,
  43193. false
  43194. ],
  43195. "Unicode-DFS-2015": [
  43196. "Unicode License Agreement - Data Files and Software (2015)",
  43197. false,
  43198. false
  43199. ],
  43200. "Unicode-DFS-2016": [
  43201. "Unicode License Agreement - Data Files and Software (2016)",
  43202. true,
  43203. false
  43204. ],
  43205. "Unicode-TOU": [
  43206. "Unicode Terms of Use",
  43207. false,
  43208. false
  43209. ],
  43210. "Unlicense": [
  43211. "The Unlicense",
  43212. true,
  43213. false
  43214. ],
  43215. "UPL-1.0": [
  43216. "Universal Permissive License v1.0",
  43217. true,
  43218. false
  43219. ],
  43220. "Vim": [
  43221. "Vim License",
  43222. false,
  43223. false
  43224. ],
  43225. "VOSTROM": [
  43226. "VOSTROM Public License for Open Source",
  43227. false,
  43228. false
  43229. ],
  43230. "VSL-1.0": [
  43231. "Vovida Software License v1.0",
  43232. true,
  43233. false
  43234. ],
  43235. "W3C": [
  43236. "W3C Software Notice and License (2002-12-31)",
  43237. true,
  43238. false
  43239. ],
  43240. "W3C-19980720": [
  43241. "W3C Software Notice and License (1998-07-20)",
  43242. false,
  43243. false
  43244. ],
  43245. "W3C-20150513": [
  43246. "W3C Software Notice and Document License (2015-05-13)",
  43247. false,
  43248. false
  43249. ],
  43250. "Watcom-1.0": [
  43251. "Sybase Open Watcom Public License 1.0",
  43252. true,
  43253. false
  43254. ],
  43255. "Wsuipa": [
  43256. "Wsuipa License",
  43257. false,
  43258. false
  43259. ],
  43260. "WTFPL": [
  43261. "Do What The F*ck You Want To Public License",
  43262. false,
  43263. false
  43264. ],
  43265. "wxWindows": [
  43266. "wxWindows Library License",
  43267. false,
  43268. true
  43269. ],
  43270. "X11": [
  43271. "X11 License",
  43272. false,
  43273. false
  43274. ],
  43275. "Xerox": [
  43276. "Xerox License",
  43277. false,
  43278. false
  43279. ],
  43280. "XFree86-1.1": [
  43281. "XFree86 License 1.1",
  43282. false,
  43283. false
  43284. ],
  43285. "xinetd": [
  43286. "xinetd License",
  43287. false,
  43288. false
  43289. ],
  43290. "Xnet": [
  43291. "X.Net License",
  43292. true,
  43293. false
  43294. ],
  43295. "xpp": [
  43296. "XPP License",
  43297. false,
  43298. false
  43299. ],
  43300. "XSkat": [
  43301. "XSkat License",
  43302. false,
  43303. false
  43304. ],
  43305. "YPL-1.0": [
  43306. "Yahoo! Public License v1.0",
  43307. false,
  43308. false
  43309. ],
  43310. "YPL-1.1": [
  43311. "Yahoo! Public License v1.1",
  43312. false,
  43313. false
  43314. ],
  43315. "Zed": [
  43316. "Zed License",
  43317. false,
  43318. false
  43319. ],
  43320. "Zend-2.0": [
  43321. "Zend License v2.0",
  43322. false,
  43323. false
  43324. ],
  43325. "Zimbra-1.3": [
  43326. "Zimbra Public License v1.3",
  43327. false,
  43328. false
  43329. ],
  43330. "Zimbra-1.4": [
  43331. "Zimbra Public License v1.4",
  43332. false,
  43333. false
  43334. ],
  43335. "Zlib": [
  43336. "zlib License",
  43337. true,
  43338. false
  43339. ],
  43340. "zlib-acknowledgement": [
  43341. "zlib/libpng License with Acknowledgement",
  43342. false,
  43343. false
  43344. ],
  43345. "ZPL-1.1": [
  43346. "Zope Public License 1.1",
  43347. false,
  43348. false
  43349. ],
  43350. "ZPL-2.0": [
  43351. "Zope Public License 2.0",
  43352. true,
  43353. false
  43354. ],
  43355. "ZPL-2.1": [
  43356. "Zope Public License 2.1",
  43357. false,
  43358. false
  43359. ]
  43360. }<?php
  43361. namespace Composer\Spdx;
  43362. class SpdxLicenses
  43363. {
  43364. const LICENSES_FILE = 'spdx-licenses.json';
  43365. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  43366. private $licenses;
  43367. private $licensesExpression;
  43368. private $exceptions;
  43369. private $exceptionsExpression;
  43370. public function __construct()
  43371. {
  43372. $this->loadLicenses();
  43373. $this->loadExceptions();
  43374. }
  43375. public function getLicenseByIdentifier($identifier)
  43376. {
  43377. $key = strtolower($identifier);
  43378. if (!isset($this->licenses[$key])) {
  43379. return;
  43380. }
  43381. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  43382. return array(
  43383. $name,
  43384. $isOsiApproved,
  43385. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  43386. $isDeprecatedLicenseId,
  43387. );
  43388. }
  43389. public function getLicenses()
  43390. {
  43391. return $this->licenses;
  43392. }
  43393. public function getExceptionByIdentifier($identifier)
  43394. {
  43395. $key = strtolower($identifier);
  43396. if (!isset($this->exceptions[$key])) {
  43397. return;
  43398. }
  43399. list($identifier, $name) = $this->exceptions[$key];
  43400. return array(
  43401. $name,
  43402. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  43403. );
  43404. }
  43405. public function getIdentifierByName($name)
  43406. {
  43407. foreach ($this->licenses as $licenseData) {
  43408. if ($licenseData[1] === $name) {
  43409. return $licenseData[0];
  43410. }
  43411. }
  43412. foreach ($this->exceptions as $licenseData) {
  43413. if ($licenseData[1] === $name) {
  43414. return $licenseData[0];
  43415. }
  43416. }
  43417. }
  43418. public function isOsiApprovedByIdentifier($identifier)
  43419. {
  43420. return $this->licenses[strtolower($identifier)][2];
  43421. }
  43422. public function isDeprecatedByIdentifier($identifier)
  43423. {
  43424. return $this->licenses[strtolower($identifier)][3];
  43425. }
  43426. public function validate($license)
  43427. {
  43428. if (is_array($license)) {
  43429. $count = count($license);
  43430. if ($count !== count(array_filter($license, 'is_string'))) {
  43431. throw new \InvalidArgumentException('Array of strings expected.');
  43432. }
  43433. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  43434. }
  43435. if (!is_string($license)) {
  43436. throw new \InvalidArgumentException(sprintf(
  43437. 'Array or String expected, %s given.',
  43438. gettype($license)
  43439. ));
  43440. }
  43441. return $this->isValidLicenseString($license);
  43442. }
  43443. public static function getResourcesDir()
  43444. {
  43445. return dirname(__DIR__) . '/res';
  43446. }
  43447. private function loadLicenses()
  43448. {
  43449. if (null !== $this->licenses) {
  43450. return;
  43451. }
  43452. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  43453. $this->licenses = array();
  43454. foreach (json_decode($json, true) as $identifier => $license) {
  43455. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  43456. }
  43457. }
  43458. private function loadExceptions()
  43459. {
  43460. if (null !== $this->exceptions) {
  43461. return;
  43462. }
  43463. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  43464. $this->exceptions = array();
  43465. foreach (json_decode($json, true) as $identifier => $exception) {
  43466. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  43467. }
  43468. }
  43469. private function getLicensesExpression()
  43470. {
  43471. if (null === $this->licensesExpression) {
  43472. $licenses = array_map('preg_quote', array_keys($this->licenses));
  43473. rsort($licenses);
  43474. $licenses = implode('|', $licenses);
  43475. $this->licensesExpression = $licenses;
  43476. }
  43477. return $this->licensesExpression;
  43478. }
  43479. private function getExceptionsExpression()
  43480. {
  43481. if (null === $this->exceptionsExpression) {
  43482. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  43483. rsort($exceptions);
  43484. $exceptions = implode('|', $exceptions);
  43485. $this->exceptionsExpression = $exceptions;
  43486. }
  43487. return $this->exceptionsExpression;
  43488. }
  43489. private function isValidLicenseString($license)
  43490. {
  43491. if (isset($this->licenses[strtolower($license)])) {
  43492. return true;
  43493. }
  43494. $licenses = $this->getLicensesExpression();
  43495. $exceptions = $this->getExceptionsExpression();
  43496. $regex = <<<REGEX
  43497. {
  43498. (?(DEFINE)
  43499. # idstring: 1*( ALPHA / DIGIT / - / . )
  43500. (?<idstring>[\pL\pN.-]{1,})
  43501. # license-id: taken from list
  43502. (?<licenseid>${licenses})
  43503. # license-exception-id: taken from list
  43504. (?<licenseexceptionid>${exceptions})
  43505. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  43506. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  43507. # simple-expresssion: license-id / license-id+ / license-ref
  43508. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  43509. # compound-expression: 1*(
  43510. # simple-expression /
  43511. # simple-expression WITH license-exception-id /
  43512. # compound-expression AND compound-expression /
  43513. # compound-expression OR compound-expression
  43514. # ) / ( compound-expression ) )
  43515. (?<compound_head>
  43516. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  43517. | \( \s* (?&compound_expression) \s* \)
  43518. )
  43519. (?<compound_expression>
  43520. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  43521. )
  43522. # license-expression: 1*1(simple-expression / compound-expression)
  43523. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  43524. ) # end of define
  43525. ^(NONE | NOASSERTION | (?&license_expression))$
  43526. }xi
  43527. REGEX;
  43528. $match = preg_match($regex, $license);
  43529. if (0 === $match) {
  43530. return false;
  43531. }
  43532. if (false === $match) {
  43533. throw new \RuntimeException('Regex failed to compile/run.');
  43534. }
  43535. return true;
  43536. }
  43537. }
  43538. MIT License
  43539. Copyright (c) 2017 Composer
  43540. Permission is hereby granted, free of charge, to any person obtaining a copy
  43541. of this software and associated documentation files (the "Software"), to deal
  43542. in the Software without restriction, including without limitation the rights
  43543. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  43544. copies of the Software, and to permit persons to whom the Software is
  43545. furnished to do so, subject to the following conditions:
  43546. The above copyright notice and this permission notice shall be included in all
  43547. copies or substantial portions of the Software.
  43548. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  43549. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  43550. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  43551. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  43552. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  43553. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  43554. SOFTWARE.
  43555. <?php
  43556. namespace Composer\XdebugHandler;
  43557. class PhpConfig
  43558. {
  43559. public function useOriginal()
  43560. {
  43561. $this->getDataAndReset();
  43562. return array();
  43563. }
  43564. public function useStandard()
  43565. {
  43566. if ($data = $this->getDataAndReset()) {
  43567. return array('-n', '-c', $data['tmpIni']);
  43568. }
  43569. return array();
  43570. }
  43571. public function usePersistent()
  43572. {
  43573. if ($data = $this->getDataAndReset()) {
  43574. Process::setEnv('PHPRC', $data['tmpIni']);
  43575. Process::setEnv('PHP_INI_SCAN_DIR', '');
  43576. }
  43577. return array();
  43578. }
  43579. private function getDataAndReset()
  43580. {
  43581. if ($data = XdebugHandler::getRestartSettings()) {
  43582. Process::setEnv('PHPRC', $data['phprc']);
  43583. Process::setEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  43584. }
  43585. return $data;
  43586. }
  43587. }
  43588. <?php
  43589. namespace Composer\XdebugHandler;
  43590. class Process
  43591. {
  43592. public static function addColorOption(array $args, $colorOption)
  43593. {
  43594. if (!$colorOption
  43595. || in_array($colorOption, $args)
  43596. || !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
  43597. return $args;
  43598. }
  43599. if (isset($matches[2])) {
  43600. if (false !== ($index = array_search($matches[2].'auto', $args))) {
  43601. $args[$index] = $colorOption;
  43602. return $args;
  43603. } elseif (preg_grep('/^'.$matches[2].'/', $args)) {
  43604. return $args;
  43605. }
  43606. } elseif (in_array('--no-'.$matches[1], $args)) {
  43607. return $args;
  43608. }
  43609. if (false !== getenv('NO_COLOR')) {
  43610. return $args;
  43611. }
  43612. if (false !== ($index = array_search('--', $args))) {
  43613. array_splice($args, $index, 0, $colorOption);
  43614. } else {
  43615. $args[] = $colorOption;
  43616. }
  43617. return $args;
  43618. }
  43619. public static function escape($arg, $meta = true, $module = false)
  43620. {
  43621. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  43622. return "'".str_replace("'", "'\\''", $arg)."'";
  43623. }
  43624. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  43625. $arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  43626. if ($meta) {
  43627. $meta = $dquotes || preg_match('/%[^%]+%/', $arg);
  43628. if (!$meta) {
  43629. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  43630. } elseif ($module && !$dquotes && $quote) {
  43631. $meta = false;
  43632. }
  43633. }
  43634. if ($quote) {
  43635. $arg = '"'.preg_replace('/(\\\\*)$/', '$1$1', $arg).'"';
  43636. }
  43637. if ($meta) {
  43638. $arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
  43639. }
  43640. return $arg;
  43641. }
  43642. public static function supportsColor($output)
  43643. {
  43644. if ('Hyper' === getenv('TERM_PROGRAM')) {
  43645. return true;
  43646. }
  43647. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  43648. return (function_exists('sapi_windows_vt100_support')
  43649. && sapi_windows_vt100_support($output))
  43650. || false !== getenv('ANSICON')
  43651. || 'ON' === getenv('ConEmuANSI')
  43652. || 'xterm' === getenv('TERM');
  43653. }
  43654. if (function_exists('stream_isatty')) {
  43655. return stream_isatty($output);
  43656. }
  43657. if (function_exists('posix_isatty')) {
  43658. return posix_isatty($output);
  43659. }
  43660. $stat = fstat($output);
  43661. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  43662. }
  43663. public static function setEnv($name, $value = false)
  43664. {
  43665. $unset = false === $value;
  43666. if (!putenv($unset ? $name : $name.'='.$value)) {
  43667. return false;
  43668. }
  43669. if ($unset) {
  43670. unset($_SERVER[$name]);
  43671. } else {
  43672. $_SERVER[$name] = $value;
  43673. }
  43674. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  43675. if ($unset) {
  43676. unset($_ENV[$name]);
  43677. } else {
  43678. $_ENV[$name] = $value;
  43679. }
  43680. }
  43681. return true;
  43682. }
  43683. }
  43684. <?php
  43685. namespace Composer\XdebugHandler;
  43686. use Psr\Log\LoggerInterface;
  43687. use Psr\Log\LogLevel;
  43688. class Status
  43689. {
  43690. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  43691. const CHECK = 'Check';
  43692. const ERROR = 'Error';
  43693. const INFO = 'Info';
  43694. const NORESTART = 'NoRestart';
  43695. const RESTART = 'Restart';
  43696. const RESTARTING = 'Restarting';
  43697. const RESTARTED = 'Restarted';
  43698. private $debug;
  43699. private $envAllowXdebug;
  43700. private $loaded;
  43701. private $logger;
  43702. private $time;
  43703. public function __construct($envAllowXdebug, $debug)
  43704. {
  43705. $start = getenv(self::ENV_RESTART);
  43706. Process::setEnv(self::ENV_RESTART);
  43707. $this->time = $start ? round((microtime(true) - $start) * 1000) : 0;
  43708. $this->envAllowXdebug = $envAllowXdebug;
  43709. $this->debug = $debug && defined('STDERR');
  43710. }
  43711. public function setLogger(LoggerInterface $logger)
  43712. {
  43713. $this->logger = $logger;
  43714. }
  43715. public function report($op, $data)
  43716. {
  43717. if ($this->logger || $this->debug) {
  43718. call_user_func(array($this, 'report'.$op), $data);
  43719. }
  43720. }
  43721. private function output($text, $level = null)
  43722. {
  43723. if ($this->logger) {
  43724. $this->logger->log($level ?: LogLevel::DEBUG, $text);
  43725. }
  43726. if ($this->debug) {
  43727. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  43728. }
  43729. }
  43730. private function reportCheck($loaded)
  43731. {
  43732. $this->loaded = $loaded;
  43733. $this->output('Checking '.$this->envAllowXdebug);
  43734. }
  43735. private function reportError($error)
  43736. {
  43737. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  43738. }
  43739. private function reportInfo($info)
  43740. {
  43741. $this->output($info);
  43742. }
  43743. private function reportNoRestart()
  43744. {
  43745. $this->output($this->getLoadedMessage());
  43746. if ($this->loaded) {
  43747. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  43748. if (!getenv($this->envAllowXdebug)) {
  43749. $text .= ' Allowed by application';
  43750. }
  43751. $this->output($text);
  43752. }
  43753. }
  43754. private function reportRestart()
  43755. {
  43756. $this->output($this->getLoadedMessage());
  43757. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  43758. }
  43759. private function reportRestarted()
  43760. {
  43761. $loaded = $this->getLoadedMessage();
  43762. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  43763. $level = $this->loaded ? LogLevel::WARNING : null;
  43764. $this->output($text, $level);
  43765. }
  43766. private function reportRestarting($command)
  43767. {
  43768. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  43769. $this->output($text);
  43770. $text = 'Running '.$command;
  43771. $this->output($text);
  43772. }
  43773. private function getEnvAllow()
  43774. {
  43775. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  43776. }
  43777. private function getLoadedMessage()
  43778. {
  43779. $loaded = $this->loaded ? sprintf('loaded (%s)', $this->loaded) : 'not loaded';
  43780. return 'The Xdebug extension is '.$loaded;
  43781. }
  43782. }
  43783. <?php
  43784. namespace Composer\XdebugHandler;
  43785. use Psr\Log\LoggerInterface;
  43786. class XdebugHandler
  43787. {
  43788. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  43789. const SUFFIX_INIS = '_ORIGINAL_INIS';
  43790. const RESTART_ID = 'internal';
  43791. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  43792. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  43793. protected $tmpIni;
  43794. private static $inRestart;
  43795. private static $name;
  43796. private static $skipped;
  43797. private $cli;
  43798. private $colorOption;
  43799. private $debug;
  43800. private $envAllowXdebug;
  43801. private $envOriginalInis;
  43802. private $loaded;
  43803. private $persistent;
  43804. private $script;
  43805. private $statusWriter;
  43806. public function __construct($envPrefix, $colorOption = '')
  43807. {
  43808. if (!is_string($envPrefix) || empty($envPrefix) || !is_string($colorOption)) {
  43809. throw new \RuntimeException('Invalid constructor parameter');
  43810. }
  43811. self::$name = strtoupper($envPrefix);
  43812. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  43813. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  43814. $this->colorOption = $colorOption;
  43815. if (extension_loaded('xdebug')) {
  43816. $ext = new \ReflectionExtension('xdebug');
  43817. $this->loaded = $ext->getVersion() ?: 'unknown';
  43818. }
  43819. if ($this->cli = PHP_SAPI === 'cli') {
  43820. $this->debug = getenv(self::DEBUG);
  43821. }
  43822. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  43823. }
  43824. public function setLogger(LoggerInterface $logger)
  43825. {
  43826. $this->statusWriter->setLogger($logger);
  43827. return $this;
  43828. }
  43829. public function setMainScript($script)
  43830. {
  43831. $this->script = $script;
  43832. return $this;
  43833. }
  43834. public function setPersistent()
  43835. {
  43836. $this->persistent = true;
  43837. return $this;
  43838. }
  43839. public function check()
  43840. {
  43841. $this->notify(Status::CHECK, $this->loaded);
  43842. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  43843. if (empty($envArgs[0]) && $this->requiresRestart((bool) $this->loaded)) {
  43844. $this->notify(Status::RESTART);
  43845. if ($this->prepareRestart()) {
  43846. $command = $this->getCommand();
  43847. $this->restart($command);
  43848. }
  43849. return;
  43850. }
  43851. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  43852. $this->notify(Status::RESTARTED);
  43853. Process::setEnv($this->envAllowXdebug);
  43854. self::$inRestart = true;
  43855. if (!$this->loaded) {
  43856. self::$skipped = $envArgs[1];
  43857. }
  43858. $this->tryEnableSignals();
  43859. $this->setEnvRestartSettings($envArgs);
  43860. return;
  43861. }
  43862. $this->notify(Status::NORESTART);
  43863. if ($settings = self::getRestartSettings()) {
  43864. $this->syncSettings($settings);
  43865. }
  43866. }
  43867. public static function getAllIniFiles()
  43868. {
  43869. if (!empty(self::$name)) {
  43870. $env = getenv(self::$name.self::SUFFIX_INIS);
  43871. if (false !== $env) {
  43872. return explode(PATH_SEPARATOR, $env);
  43873. }
  43874. }
  43875. $paths = array((string) php_ini_loaded_file());
  43876. if ($scanned = php_ini_scanned_files()) {
  43877. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  43878. }
  43879. return $paths;
  43880. }
  43881. public static function getRestartSettings()
  43882. {
  43883. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  43884. if (count($envArgs) !== 6
  43885. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  43886. return null;
  43887. }
  43888. return array(
  43889. 'tmpIni' => $envArgs[0],
  43890. 'scannedInis' => (bool) $envArgs[1],
  43891. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  43892. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  43893. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  43894. 'skipped' => $envArgs[5],
  43895. );
  43896. }
  43897. public static function getSkippedVersion()
  43898. {
  43899. return (string) self::$skipped;
  43900. }
  43901. protected function requiresRestart($isLoaded)
  43902. {
  43903. return $isLoaded;
  43904. }
  43905. protected function restart($command)
  43906. {
  43907. $this->doRestart($command);
  43908. }
  43909. private function doRestart($command)
  43910. {
  43911. $this->tryEnableSignals();
  43912. $this->notify(Status::RESTARTING, $command);
  43913. if (function_exists('proc_open')) {
  43914. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 80000) {
  43915. $command = '"'.$command.'"';
  43916. }
  43917. $process = proc_open($command, array(), $pipes);
  43918. if (is_resource($process)) {
  43919. $exitCode = proc_close($process);
  43920. }
  43921. } else {
  43922. passthru($command, $exitCode);
  43923. }
  43924. if (!isset($exitCode)) {
  43925. $this->notify(Status::ERROR, 'Unable to restart process');
  43926. $exitCode = -1;
  43927. } else {
  43928. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  43929. }
  43930. if ($this->debug === '2') {
  43931. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  43932. } else {
  43933. @unlink($this->tmpIni);
  43934. }
  43935. exit($exitCode);
  43936. }
  43937. private function prepareRestart()
  43938. {
  43939. $error = '';
  43940. $iniFiles = self::getAllIniFiles();
  43941. $scannedInis = count($iniFiles) > 1;
  43942. $tmpDir = sys_get_temp_dir();
  43943. if (!$this->cli) {
  43944. $error = 'Unsupported SAPI: '.PHP_SAPI;
  43945. } elseif (!defined('PHP_BINARY')) {
  43946. $error = 'PHP version is too old: '.PHP_VERSION;
  43947. } elseif (!$this->checkConfiguration($info)) {
  43948. $error = $info;
  43949. } elseif (!$this->checkScanDirConfig()) {
  43950. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  43951. } elseif (!$this->checkMainScript()) {
  43952. $error = 'Unable to access main script: '.$this->script;
  43953. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  43954. $error = $error ?: 'Unable to create temp ini file at: '.$tmpDir;
  43955. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  43956. $error = 'Unable to set environment variables';
  43957. }
  43958. if ($error) {
  43959. $this->notify(Status::ERROR, $error);
  43960. }
  43961. return empty($error);
  43962. }
  43963. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  43964. {
  43965. if (!$this->tmpIni = @tempnam($tmpDir, '')) {
  43966. return false;
  43967. }
  43968. if (empty($iniFiles[0])) {
  43969. array_shift($iniFiles);
  43970. }
  43971. $content = '';
  43972. $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  43973. foreach ($iniFiles as $file) {
  43974. if (($data = @file_get_contents($file)) === false) {
  43975. $error = 'Unable to read ini: '.$file;
  43976. return false;
  43977. }
  43978. $content .= preg_replace($regex, ';$1', $data).PHP_EOL;
  43979. }
  43980. if ($config = parse_ini_string($content)) {
  43981. $loaded = ini_get_all(null, false);
  43982. $content .= $this->mergeLoadedConfig($loaded, $config);
  43983. }
  43984. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  43985. return @file_put_contents($this->tmpIni, $content);
  43986. }
  43987. private function getCommand()
  43988. {
  43989. $php = array(PHP_BINARY);
  43990. $args = array_slice($_SERVER['argv'], 1);
  43991. if (!$this->persistent) {
  43992. array_push($php, '-n', '-c', $this->tmpIni);
  43993. }
  43994. if (defined('STDOUT') && Process::supportsColor(STDOUT)) {
  43995. $args = Process::addColorOption($args, $this->colorOption);
  43996. }
  43997. $args = array_merge($php, array($this->script), $args);
  43998. $cmd = Process::escape(array_shift($args), true, true);
  43999. foreach ($args as $arg) {
  44000. $cmd .= ' '.Process::escape($arg);
  44001. }
  44002. return $cmd;
  44003. }
  44004. private function setEnvironment($scannedInis, array $iniFiles)
  44005. {
  44006. $scanDir = getenv('PHP_INI_SCAN_DIR');
  44007. $phprc = getenv('PHPRC');
  44008. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  44009. return false;
  44010. }
  44011. if ($this->persistent) {
  44012. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  44013. return false;
  44014. }
  44015. }
  44016. $envArgs = array(
  44017. self::RESTART_ID,
  44018. $this->loaded,
  44019. (int) $scannedInis,
  44020. false === $scanDir ? '*' : $scanDir,
  44021. false === $phprc ? '*' : $phprc,
  44022. );
  44023. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  44024. }
  44025. private function notify($op, $data = null)
  44026. {
  44027. $this->statusWriter->report($op, $data);
  44028. }
  44029. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  44030. {
  44031. $content = '';
  44032. foreach ($loadedConfig as $name => $value) {
  44033. if (!is_string($value)
  44034. || strpos($name, 'xdebug') === 0
  44035. || $name === 'apc.mmap_file_mask') {
  44036. continue;
  44037. }
  44038. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  44039. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  44040. }
  44041. }
  44042. return $content;
  44043. }
  44044. private function checkMainScript()
  44045. {
  44046. if (null !== $this->script) {
  44047. return file_exists($this->script) || '--' === $this->script;
  44048. }
  44049. if (file_exists($this->script = $_SERVER['argv'][0])) {
  44050. return true;
  44051. }
  44052. $options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false;
  44053. $trace = debug_backtrace($options);
  44054. if (($main = end($trace)) && isset($main['file'])) {
  44055. return file_exists($this->script = $main['file']);
  44056. }
  44057. return false;
  44058. }
  44059. private function setEnvRestartSettings($envArgs)
  44060. {
  44061. $settings = array(
  44062. php_ini_loaded_file(),
  44063. $envArgs[2],
  44064. $envArgs[3],
  44065. $envArgs[4],
  44066. getenv($this->envOriginalInis),
  44067. self::$skipped,
  44068. );
  44069. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  44070. }
  44071. private function syncSettings(array $settings)
  44072. {
  44073. if (false === getenv($this->envOriginalInis)) {
  44074. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  44075. }
  44076. self::$skipped = $settings['skipped'];
  44077. $this->notify(Status::INFO, 'Process called with existing restart settings');
  44078. }
  44079. private function checkScanDirConfig()
  44080. {
  44081. return !(getenv('PHP_INI_SCAN_DIR')
  44082. && !PHP_CONFIG_FILE_SCAN_DIR
  44083. && (PHP_VERSION_ID < 70113
  44084. || PHP_VERSION_ID === 70200));
  44085. }
  44086. private function checkConfiguration(&$info)
  44087. {
  44088. if (!function_exists('proc_open') && !function_exists('passthru')) {
  44089. $info = 'execution functions have been disabled (proc_open or passthru required)';
  44090. return false;
  44091. }
  44092. if (extension_loaded('uopz') && !ini_get('uopz.disable')) {
  44093. if (function_exists('uopz_allow_exit')) {
  44094. @uopz_allow_exit(true);
  44095. } else {
  44096. $info = 'uopz extension is not compatible';
  44097. return false;
  44098. }
  44099. }
  44100. return true;
  44101. }
  44102. private function tryEnableSignals()
  44103. {
  44104. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  44105. pcntl_async_signals(true);
  44106. $message = 'Async signals enabled';
  44107. if (!self::$inRestart) {
  44108. pcntl_signal(SIGINT, SIG_IGN);
  44109. $message .= ' (SIGINT = SIG_IGN)';
  44110. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  44111. pcntl_signal(SIGINT, SIG_DFL);
  44112. $message .= ' (SIGINT = SIG_DFL)';
  44113. }
  44114. $this->notify(Status::INFO, $message);
  44115. }
  44116. if (!self::$inRestart && function_exists('sapi_windows_set_ctrl_handler')) {
  44117. sapi_windows_set_ctrl_handler(function ($evt) {});
  44118. $this->notify(Status::INFO, 'CTRL signals suppressed');
  44119. }
  44120. }
  44121. }
  44122. MIT License
  44123. Copyright (c) 2016
  44124. Permission is hereby granted, free of charge, to any person obtaining a copy
  44125. of this software and associated documentation files (the "Software"), to deal
  44126. in the Software without restriction, including without limitation the rights
  44127. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  44128. copies of the Software, and to permit persons to whom the Software is
  44129. furnished to do so, subject to the following conditions:
  44130. The above copyright notice and this permission notice shall be included in all
  44131. copies or substantial portions of the Software.
  44132. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  44133. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  44134. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  44135. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  44136. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  44137. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  44138. SOFTWARE.
  44139. <?php
  44140. namespace JsonSchema\Constraints;
  44141. use JsonSchema\Entity\JsonPointer;
  44142. use JsonSchema\Exception\InvalidArgumentException;
  44143. use JsonSchema\Exception\ValidationException;
  44144. use JsonSchema\Validator;
  44145. class BaseConstraint
  44146. {
  44147. protected $errors = array();
  44148. protected $errorMask = Validator::ERROR_NONE;
  44149. protected $factory;
  44150. public function __construct(Factory $factory = null)
  44151. {
  44152. $this->factory = $factory ?: new Factory();
  44153. }
  44154. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  44155. {
  44156. $error = array(
  44157. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  44158. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  44159. 'message' => $message,
  44160. 'constraint' => $constraint,
  44161. 'context' => $this->factory->getErrorContext(),
  44162. );
  44163. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  44164. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  44165. }
  44166. if (is_array($more) && count($more) > 0) {
  44167. $error += $more;
  44168. }
  44169. $this->errors[] = $error;
  44170. $this->errorMask |= $error['context'];
  44171. }
  44172. public function addErrors(array $errors)
  44173. {
  44174. if ($errors) {
  44175. $this->errors = array_merge($this->errors, $errors);
  44176. $errorMask = &$this->errorMask;
  44177. array_walk($errors, function ($error) use (&$errorMask) {
  44178. if (isset($error['context'])) {
  44179. $errorMask |= $error['context'];
  44180. }
  44181. });
  44182. }
  44183. }
  44184. public function getErrors($errorContext = Validator::ERROR_ALL)
  44185. {
  44186. if ($errorContext === Validator::ERROR_ALL) {
  44187. return $this->errors;
  44188. }
  44189. return array_filter($this->errors, function ($error) use ($errorContext) {
  44190. if ($errorContext & $error['context']) {
  44191. return true;
  44192. }
  44193. });
  44194. }
  44195. public function numErrors($errorContext = Validator::ERROR_ALL)
  44196. {
  44197. if ($errorContext === Validator::ERROR_ALL) {
  44198. return count($this->errors);
  44199. }
  44200. return count($this->getErrors($errorContext));
  44201. }
  44202. public function isValid()
  44203. {
  44204. return !$this->getErrors();
  44205. }
  44206. public function reset()
  44207. {
  44208. $this->errors = array();
  44209. $this->errorMask = Validator::ERROR_NONE;
  44210. }
  44211. public function getErrorMask()
  44212. {
  44213. return $this->errorMask;
  44214. }
  44215. public static function arrayToObjectRecursive($array)
  44216. {
  44217. $json = json_encode($array);
  44218. if (json_last_error() !== \JSON_ERROR_NONE) {
  44219. $message = 'Unable to encode schema array as JSON';
  44220. if (function_exists('json_last_error_msg')) {
  44221. $message .= ': ' . json_last_error_msg();
  44222. }
  44223. throw new InvalidArgumentException($message);
  44224. }
  44225. return (object) json_decode($json);
  44226. }
  44227. }
  44228. <?php
  44229. namespace JsonSchema\Constraints;
  44230. use JsonSchema\Entity\JsonPointer;
  44231. class CollectionConstraint extends Constraint
  44232. {
  44233. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44234. {
  44235. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  44236. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  44237. }
  44238. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  44239. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  44240. }
  44241. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  44242. $unique = $value;
  44243. if (is_array($value) && count($value)) {
  44244. $unique = array_map(function ($e) {
  44245. return var_export($e, true);
  44246. }, $value);
  44247. }
  44248. if (count(array_unique($unique)) != count($value)) {
  44249. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  44250. }
  44251. }
  44252. if (isset($schema->items)) {
  44253. $this->validateItems($value, $schema, $path, $i);
  44254. }
  44255. }
  44256. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44257. {
  44258. if (is_object($schema->items)) {
  44259. foreach ($value as $k => &$v) {
  44260. $initErrors = $this->getErrors();
  44261. $this->checkUndefined($v, $schema->items, $path, $k);
  44262. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  44263. $secondErrors = $this->getErrors();
  44264. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  44265. }
  44266. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  44267. $this->errors = $secondErrors;
  44268. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  44269. $this->errors = $initErrors;
  44270. }
  44271. }
  44272. unset($v);
  44273. } else {
  44274. foreach ($value as $k => &$v) {
  44275. if (array_key_exists($k, $schema->items)) {
  44276. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  44277. } else {
  44278. if (property_exists($schema, 'additionalItems')) {
  44279. if ($schema->additionalItems !== false) {
  44280. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  44281. } else {
  44282. $this->addError(
  44283. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  44284. }
  44285. } else {
  44286. $this->checkUndefined($v, new \stdClass(), $path, $k);
  44287. }
  44288. }
  44289. }
  44290. unset($v);
  44291. if (count($value) > 0) {
  44292. for ($k = count($value); $k < count($schema->items); $k++) {
  44293. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  44294. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  44295. }
  44296. }
  44297. }
  44298. }
  44299. }
  44300. <?php
  44301. namespace JsonSchema\Constraints;
  44302. use JsonSchema\Entity\JsonPointer;
  44303. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  44304. {
  44305. protected $inlineSchemaProperty = '$schema';
  44306. const CHECK_MODE_NONE = 0x00000000;
  44307. const CHECK_MODE_NORMAL = 0x00000001;
  44308. const CHECK_MODE_TYPE_CAST = 0x00000002;
  44309. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  44310. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  44311. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  44312. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  44313. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  44314. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  44315. protected function incrementPath(JsonPointer $path = null, $i)
  44316. {
  44317. $path = $path ?: new JsonPointer('');
  44318. $path = $path->withPropertyPaths(
  44319. array_merge(
  44320. $path->getPropertyPaths(),
  44321. array_filter(array($i), 'strlen')
  44322. )
  44323. );
  44324. return $path;
  44325. }
  44326. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44327. {
  44328. $validator = $this->factory->createInstanceFor('collection');
  44329. $validator->check($value, $schema, $path, $i);
  44330. $this->addErrors($validator->getErrors());
  44331. }
  44332. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  44333. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  44334. {
  44335. $validator = $this->factory->createInstanceFor('object');
  44336. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  44337. $this->addErrors($validator->getErrors());
  44338. }
  44339. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44340. {
  44341. $validator = $this->factory->createInstanceFor('type');
  44342. $validator->check($value, $schema, $path, $i);
  44343. $this->addErrors($validator->getErrors());
  44344. }
  44345. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  44346. {
  44347. $validator = $this->factory->createInstanceFor('undefined');
  44348. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  44349. $this->addErrors($validator->getErrors());
  44350. }
  44351. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  44352. {
  44353. $validator = $this->factory->createInstanceFor('string');
  44354. $validator->check($value, $schema, $path, $i);
  44355. $this->addErrors($validator->getErrors());
  44356. }
  44357. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  44358. {
  44359. $validator = $this->factory->createInstanceFor('number');
  44360. $validator->check($value, $schema, $path, $i);
  44361. $this->addErrors($validator->getErrors());
  44362. }
  44363. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  44364. {
  44365. $validator = $this->factory->createInstanceFor('enum');
  44366. $validator->check($value, $schema, $path, $i);
  44367. $this->addErrors($validator->getErrors());
  44368. }
  44369. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  44370. {
  44371. $validator = $this->factory->createInstanceFor('format');
  44372. $validator->check($value, $schema, $path, $i);
  44373. $this->addErrors($validator->getErrors());
  44374. }
  44375. protected function getTypeCheck()
  44376. {
  44377. return $this->factory->getTypeCheck();
  44378. }
  44379. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  44380. {
  44381. $result = array_map(
  44382. function ($path) {
  44383. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  44384. },
  44385. $pointer->getPropertyPaths()
  44386. );
  44387. return trim(implode('', $result), '.');
  44388. }
  44389. }
  44390. <?php
  44391. namespace JsonSchema\Constraints;
  44392. use JsonSchema\Entity\JsonPointer;
  44393. interface ConstraintInterface
  44394. {
  44395. public function getErrors();
  44396. public function addErrors(array $errors);
  44397. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  44398. public function isValid();
  44399. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  44400. }
  44401. <?php
  44402. namespace JsonSchema\Constraints;
  44403. use JsonSchema\Entity\JsonPointer;
  44404. class EnumConstraint extends Constraint
  44405. {
  44406. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44407. {
  44408. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  44409. return;
  44410. }
  44411. $type = gettype($element);
  44412. foreach ($schema->enum as $enum) {
  44413. $enumType = gettype($enum);
  44414. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  44415. if ((object) $element == $enum) {
  44416. return;
  44417. }
  44418. }
  44419. if ($type === gettype($enum)) {
  44420. if ($type == 'object') {
  44421. if ($element == $enum) {
  44422. return;
  44423. }
  44424. } elseif ($element === $enum) {
  44425. return;
  44426. }
  44427. }
  44428. }
  44429. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  44430. }
  44431. }
  44432. <?php
  44433. namespace JsonSchema\Constraints;
  44434. use JsonSchema\Exception\InvalidArgumentException;
  44435. use JsonSchema\SchemaStorage;
  44436. use JsonSchema\SchemaStorageInterface;
  44437. use JsonSchema\Uri\UriRetriever;
  44438. use JsonSchema\UriRetrieverInterface;
  44439. use JsonSchema\Validator;
  44440. class Factory
  44441. {
  44442. protected $schemaStorage;
  44443. protected $uriRetriever;
  44444. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  44445. private $typeCheck = array();
  44446. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  44447. protected $constraintMap = array(
  44448. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  44449. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  44450. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  44451. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  44452. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  44453. 'string' => 'JsonSchema\Constraints\StringConstraint',
  44454. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  44455. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  44456. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  44457. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  44458. 'validator' => 'JsonSchema\Validator'
  44459. );
  44460. private $instanceCache = array();
  44461. public function __construct(
  44462. SchemaStorageInterface $schemaStorage = null,
  44463. UriRetrieverInterface $uriRetriever = null,
  44464. $checkMode = Constraint::CHECK_MODE_NORMAL
  44465. ) {
  44466. $this->setConfig($checkMode);
  44467. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  44468. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  44469. }
  44470. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  44471. {
  44472. $this->checkMode = $checkMode;
  44473. }
  44474. public function addConfig($options)
  44475. {
  44476. $this->checkMode |= $options;
  44477. }
  44478. public function removeConfig($options)
  44479. {
  44480. $this->checkMode &= ~$options;
  44481. }
  44482. public function getConfig($options = null)
  44483. {
  44484. if ($options === null) {
  44485. return $this->checkMode;
  44486. }
  44487. return $this->checkMode & $options;
  44488. }
  44489. public function getUriRetriever()
  44490. {
  44491. return $this->uriRetriever;
  44492. }
  44493. public function getSchemaStorage()
  44494. {
  44495. return $this->schemaStorage;
  44496. }
  44497. public function getTypeCheck()
  44498. {
  44499. if (!isset($this->typeCheck[$this->checkMode])) {
  44500. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  44501. ? new TypeCheck\LooseTypeCheck()
  44502. : new TypeCheck\StrictTypeCheck();
  44503. }
  44504. return $this->typeCheck[$this->checkMode];
  44505. }
  44506. public function setConstraintClass($name, $class)
  44507. {
  44508. if (!class_exists($class)) {
  44509. throw new InvalidArgumentException('Unknown constraint ' . $name);
  44510. }
  44511. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  44512. throw new InvalidArgumentException('Invalid class ' . $name);
  44513. }
  44514. $this->constraintMap[$name] = $class;
  44515. return $this;
  44516. }
  44517. public function createInstanceFor($constraintName)
  44518. {
  44519. if (!isset($this->constraintMap[$constraintName])) {
  44520. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  44521. }
  44522. if (!isset($this->instanceCache[$constraintName])) {
  44523. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  44524. }
  44525. return clone $this->instanceCache[$constraintName];
  44526. }
  44527. public function getErrorContext()
  44528. {
  44529. return $this->errorContext;
  44530. }
  44531. public function setErrorContext($errorContext)
  44532. {
  44533. $this->errorContext = $errorContext;
  44534. }
  44535. }
  44536. <?php
  44537. namespace JsonSchema\Constraints;
  44538. use JsonSchema\Entity\JsonPointer;
  44539. use JsonSchema\Rfc3339;
  44540. class FormatConstraint extends Constraint
  44541. {
  44542. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44543. {
  44544. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  44545. return;
  44546. }
  44547. switch ($schema->format) {
  44548. case 'date':
  44549. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  44550. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  44551. }
  44552. break;
  44553. case 'time':
  44554. if (!$this->validateDateTime($element, 'H:i:s')) {
  44555. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  44556. }
  44557. break;
  44558. case 'date-time':
  44559. if (null === Rfc3339::createFromString($element)) {
  44560. $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));
  44561. }
  44562. break;
  44563. case 'utc-millisec':
  44564. if (!$this->validateDateTime($element, 'U')) {
  44565. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  44566. }
  44567. break;
  44568. case 'regex':
  44569. if (!$this->validateRegex($element)) {
  44570. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  44571. }
  44572. break;
  44573. case 'color':
  44574. if (!$this->validateColor($element)) {
  44575. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  44576. }
  44577. break;
  44578. case 'style':
  44579. if (!$this->validateStyle($element)) {
  44580. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  44581. }
  44582. break;
  44583. case 'phone':
  44584. if (!$this->validatePhone($element)) {
  44585. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  44586. }
  44587. break;
  44588. case 'uri':
  44589. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  44590. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  44591. }
  44592. break;
  44593. case 'uriref':
  44594. case 'uri-reference':
  44595. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  44596. if (substr($element, 0, 2) === '//') {
  44597. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44598. } elseif (substr($element, 0, 1) === '/') {
  44599. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44600. } elseif (strlen($element)) {
  44601. $pathParts = explode('/', $element, 2);
  44602. if (strpos($pathParts[0], ':') !== false) {
  44603. $validURL = null;
  44604. } else {
  44605. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44606. }
  44607. } else {
  44608. $validURL = null;
  44609. }
  44610. if ($validURL === null) {
  44611. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  44612. }
  44613. }
  44614. break;
  44615. case 'email':
  44616. $filterFlags = FILTER_NULL_ON_FAILURE;
  44617. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  44618. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  44619. }
  44620. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  44621. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  44622. }
  44623. break;
  44624. case 'ip-address':
  44625. case 'ipv4':
  44626. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  44627. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44628. }
  44629. break;
  44630. case 'ipv6':
  44631. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  44632. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44633. }
  44634. break;
  44635. case 'host-name':
  44636. case 'hostname':
  44637. if (!$this->validateHostname($element)) {
  44638. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  44639. }
  44640. break;
  44641. default:
  44642. break;
  44643. }
  44644. }
  44645. protected function validateDateTime($datetime, $format)
  44646. {
  44647. $dt = \DateTime::createFromFormat($format, $datetime);
  44648. if (!$dt) {
  44649. return false;
  44650. }
  44651. if ($datetime === $dt->format($format)) {
  44652. return true;
  44653. }
  44654. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  44655. return true;
  44656. }
  44657. return false;
  44658. }
  44659. protected function validateRegex($regex)
  44660. {
  44661. return false !== @preg_match('/' . $regex . '/u', '');
  44662. }
  44663. protected function validateColor($color)
  44664. {
  44665. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  44666. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  44667. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  44668. return true;
  44669. }
  44670. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  44671. }
  44672. protected function validateStyle($style)
  44673. {
  44674. $properties = explode(';', rtrim($style, ';'));
  44675. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  44676. return empty($invalidEntries);
  44677. }
  44678. protected function validatePhone($phone)
  44679. {
  44680. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  44681. }
  44682. protected function validateHostname($host)
  44683. {
  44684. $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';
  44685. return preg_match($hostnameRegex, $host);
  44686. }
  44687. }
  44688. <?php
  44689. namespace JsonSchema\Constraints;
  44690. use JsonSchema\Entity\JsonPointer;
  44691. class NumberConstraint extends Constraint
  44692. {
  44693. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44694. {
  44695. if (isset($schema->exclusiveMinimum)) {
  44696. if (isset($schema->minimum)) {
  44697. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  44698. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  44699. } elseif ($element < $schema->minimum) {
  44700. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44701. }
  44702. } else {
  44703. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  44704. }
  44705. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  44706. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44707. }
  44708. if (isset($schema->exclusiveMaximum)) {
  44709. if (isset($schema->maximum)) {
  44710. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  44711. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  44712. } elseif ($element > $schema->maximum) {
  44713. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44714. }
  44715. } else {
  44716. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  44717. }
  44718. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  44719. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44720. }
  44721. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  44722. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  44723. }
  44724. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  44725. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  44726. }
  44727. $this->checkFormat($element, $schema, $path, $i);
  44728. }
  44729. private function fmod($number1, $number2)
  44730. {
  44731. $modulus = ($number1 - round($number1 / $number2) * $number2);
  44732. $precision = 0.0000000001;
  44733. if (-$precision < $modulus && $modulus < $precision) {
  44734. return 0.0;
  44735. }
  44736. return $modulus;
  44737. }
  44738. }
  44739. <?php
  44740. namespace JsonSchema\Constraints;
  44741. use JsonSchema\Entity\JsonPointer;
  44742. class ObjectConstraint extends Constraint
  44743. {
  44744. protected $appliedDefaults = array();
  44745. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  44746. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  44747. {
  44748. if ($element instanceof UndefinedConstraint) {
  44749. return;
  44750. }
  44751. $this->appliedDefaults = $appliedDefaults;
  44752. $matches = array();
  44753. if ($patternProperties) {
  44754. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  44755. }
  44756. if ($properties) {
  44757. $this->validateProperties($element, $properties, $path);
  44758. }
  44759. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  44760. }
  44761. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  44762. {
  44763. $try = array('/', '#', '+', '~', '%');
  44764. $matches = array();
  44765. foreach ($patternProperties as $pregex => $schema) {
  44766. $delimiter = '/';
  44767. foreach ($try as $delimiter) {
  44768. if (strpos($pregex, $delimiter) === false) {
  44769. break;
  44770. }
  44771. }
  44772. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  44773. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  44774. continue;
  44775. }
  44776. foreach ($element as $i => $value) {
  44777. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  44778. $matches[] = $i;
  44779. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  44780. }
  44781. }
  44782. }
  44783. return $matches;
  44784. }
  44785. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  44786. $properties = null, $additionalProp = null)
  44787. {
  44788. $this->validateMinMaxConstraint($element, $schema, $path);
  44789. foreach ($element as $i => $value) {
  44790. $definition = $this->getProperty($properties, $i);
  44791. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  44792. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  44793. }
  44794. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  44795. if ($additionalProp === true) {
  44796. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  44797. } else {
  44798. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  44799. }
  44800. }
  44801. $require = $this->getProperty($definition, 'requires');
  44802. if ($require && !$this->getProperty($element, $require)) {
  44803. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  44804. }
  44805. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  44806. if (is_object($property)) {
  44807. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  44808. }
  44809. }
  44810. }
  44811. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  44812. {
  44813. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  44814. foreach ($properties as $i => $value) {
  44815. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  44816. $definition = $this->getProperty($properties, $i);
  44817. if (is_object($definition)) {
  44818. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  44819. }
  44820. }
  44821. }
  44822. protected function &getProperty(&$element, $property, $fallback = null)
  44823. {
  44824. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  44825. return $element[$property];
  44826. } elseif (is_object($element) && property_exists($element, $property)) {
  44827. return $element->$property;
  44828. }
  44829. return $fallback;
  44830. }
  44831. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  44832. {
  44833. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  44834. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  44835. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  44836. }
  44837. }
  44838. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  44839. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  44840. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  44841. }
  44842. }
  44843. }
  44844. }
  44845. <?php
  44846. namespace JsonSchema\Constraints;
  44847. use JsonSchema\Entity\JsonPointer;
  44848. use JsonSchema\Exception\InvalidArgumentException;
  44849. use JsonSchema\Exception\InvalidSchemaException;
  44850. use JsonSchema\Exception\RuntimeException;
  44851. use JsonSchema\Validator;
  44852. class SchemaConstraint extends Constraint
  44853. {
  44854. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  44855. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44856. {
  44857. if ($schema !== null) {
  44858. $validationSchema = $schema;
  44859. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  44860. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  44861. } else {
  44862. throw new InvalidArgumentException('no schema found to verify against');
  44863. }
  44864. if (is_array($validationSchema)) {
  44865. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  44866. }
  44867. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  44868. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  44869. throw new RuntimeException('Cannot validate the schema of a non-object');
  44870. }
  44871. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  44872. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  44873. } else {
  44874. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  44875. }
  44876. $schemaStorage = $this->factory->getSchemaStorage();
  44877. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  44878. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  44879. }
  44880. $initialErrorCount = $this->numErrors();
  44881. $initialConfig = $this->factory->getConfig();
  44882. $initialContext = $this->factory->getErrorContext();
  44883. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  44884. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  44885. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  44886. try {
  44887. $this->check($validationSchema, $schemaSpec);
  44888. } catch (\Exception $e) {
  44889. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  44890. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  44891. }
  44892. }
  44893. if ($this->numErrors() > $initialErrorCount) {
  44894. $this->addError($path, 'Schema is not valid', 'schema');
  44895. }
  44896. $this->factory->setConfig($initialConfig);
  44897. $this->factory->setErrorContext($initialContext);
  44898. }
  44899. $this->checkUndefined($element, $validationSchema, $path, $i);
  44900. }
  44901. }
  44902. <?php
  44903. namespace JsonSchema\Constraints;
  44904. use JsonSchema\Entity\JsonPointer;
  44905. class StringConstraint extends Constraint
  44906. {
  44907. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44908. {
  44909. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  44910. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  44911. 'maxLength' => $schema->maxLength,
  44912. ));
  44913. }
  44914. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  44915. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  44916. 'minLength' => $schema->minLength,
  44917. ));
  44918. }
  44919. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  44920. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  44921. 'pattern' => $schema->pattern,
  44922. ));
  44923. }
  44924. $this->checkFormat($element, $schema, $path, $i);
  44925. }
  44926. private function strlen($string)
  44927. {
  44928. if (extension_loaded('mbstring')) {
  44929. return mb_strlen($string, mb_detect_encoding($string));
  44930. }
  44931. return strlen($string);
  44932. }
  44933. }
  44934. <?php
  44935. namespace JsonSchema\Constraints\TypeCheck;
  44936. class LooseTypeCheck implements TypeCheckInterface
  44937. {
  44938. public static function isObject($value)
  44939. {
  44940. return
  44941. is_object($value) ||
  44942. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  44943. }
  44944. public static function isArray($value)
  44945. {
  44946. return
  44947. is_array($value) &&
  44948. (count($value) == 0 || !self::isAssociativeArray($value));
  44949. }
  44950. public static function propertyGet($value, $property)
  44951. {
  44952. if (is_object($value)) {
  44953. return $value->{$property};
  44954. }
  44955. return $value[$property];
  44956. }
  44957. public static function propertySet(&$value, $property, $data)
  44958. {
  44959. if (is_object($value)) {
  44960. $value->{$property} = $data;
  44961. } else {
  44962. $value[$property] = $data;
  44963. }
  44964. }
  44965. public static function propertyExists($value, $property)
  44966. {
  44967. if (is_object($value)) {
  44968. return property_exists($value, $property);
  44969. }
  44970. return array_key_exists($property, $value);
  44971. }
  44972. public static function propertyCount($value)
  44973. {
  44974. if (is_object($value)) {
  44975. return count(get_object_vars($value));
  44976. }
  44977. return count($value);
  44978. }
  44979. private static function isAssociativeArray($arr)
  44980. {
  44981. return array_keys($arr) !== range(0, count($arr) - 1);
  44982. }
  44983. }
  44984. <?php
  44985. namespace JsonSchema\Constraints\TypeCheck;
  44986. class StrictTypeCheck implements TypeCheckInterface
  44987. {
  44988. public static function isObject($value)
  44989. {
  44990. return is_object($value);
  44991. }
  44992. public static function isArray($value)
  44993. {
  44994. return is_array($value);
  44995. }
  44996. public static function propertyGet($value, $property)
  44997. {
  44998. return $value->{$property};
  44999. }
  45000. public static function propertySet(&$value, $property, $data)
  45001. {
  45002. $value->{$property} = $data;
  45003. }
  45004. public static function propertyExists($value, $property)
  45005. {
  45006. return property_exists($value, $property);
  45007. }
  45008. public static function propertyCount($value)
  45009. {
  45010. if (!is_object($value)) {
  45011. return 0;
  45012. }
  45013. return count(get_object_vars($value));
  45014. }
  45015. }
  45016. <?php
  45017. namespace JsonSchema\Constraints\TypeCheck;
  45018. interface TypeCheckInterface
  45019. {
  45020. public static function isObject($value);
  45021. public static function isArray($value);
  45022. public static function propertyGet($value, $property);
  45023. public static function propertySet(&$value, $property, $data);
  45024. public static function propertyExists($value, $property);
  45025. public static function propertyCount($value);
  45026. }
  45027. <?php
  45028. namespace JsonSchema\Constraints;
  45029. use JsonSchema\Entity\JsonPointer;
  45030. use JsonSchema\Exception\InvalidArgumentException;
  45031. use UnexpectedValueException as StandardUnexpectedValueException;
  45032. class TypeConstraint extends Constraint
  45033. {
  45034. public static $wording = array(
  45035. 'integer' => 'an integer',
  45036. 'number' => 'a number',
  45037. 'boolean' => 'a boolean',
  45038. 'object' => 'an object',
  45039. 'array' => 'an array',
  45040. 'string' => 'a string',
  45041. 'null' => 'a null',
  45042. 'any' => null,
  45043. 0 => null,
  45044. );
  45045. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  45046. {
  45047. $type = isset($schema->type) ? $schema->type : null;
  45048. $isValid = false;
  45049. $wording = array();
  45050. if (is_array($type)) {
  45051. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  45052. } elseif (is_object($type)) {
  45053. $this->checkUndefined($value, $type, $path);
  45054. return;
  45055. } else {
  45056. $isValid = $this->validateType($value, $type);
  45057. }
  45058. if ($isValid === false) {
  45059. if (!is_array($type)) {
  45060. $this->validateTypeNameWording($type);
  45061. $wording[] = self::$wording[$type];
  45062. }
  45063. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  45064. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  45065. }
  45066. }
  45067. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  45068. {
  45069. foreach ($type as $tp) {
  45070. if (is_object($tp)) {
  45071. if (!$isValid) {
  45072. $validator = $this->factory->createInstanceFor('type');
  45073. $subSchema = new \stdClass();
  45074. $subSchema->type = $tp;
  45075. $validator->check($value, $subSchema, $path, null);
  45076. $error = $validator->getErrors();
  45077. $isValid = !(bool) $error;
  45078. $validTypesWording[] = self::$wording['object'];
  45079. }
  45080. } else {
  45081. $this->validateTypeNameWording($tp);
  45082. $validTypesWording[] = self::$wording[$tp];
  45083. if (!$isValid) {
  45084. $isValid = $this->validateType($value, $tp);
  45085. }
  45086. }
  45087. }
  45088. }
  45089. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  45090. {
  45091. if ($listEnd === false || !isset($elements[1])) {
  45092. return implode($delimiter, $elements);
  45093. }
  45094. $lastElement = array_slice($elements, -1);
  45095. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  45096. $implodedElements = array_merge(array($firsElements), $lastElement);
  45097. return join(" $listEnd ", $implodedElements);
  45098. }
  45099. protected function validateTypeNameWording($type)
  45100. {
  45101. if (!isset(self::$wording[$type])) {
  45102. throw new StandardUnexpectedValueException(
  45103. sprintf(
  45104. 'No wording for %s available, expected wordings are: [%s]',
  45105. var_export($type, true),
  45106. implode(', ', array_filter(self::$wording)))
  45107. );
  45108. }
  45109. }
  45110. protected function validateType(&$value, $type)
  45111. {
  45112. if (!$type) {
  45113. return true;
  45114. }
  45115. if ('any' === $type) {
  45116. return true;
  45117. }
  45118. if ('object' === $type) {
  45119. return $this->getTypeCheck()->isObject($value);
  45120. }
  45121. if ('array' === $type) {
  45122. return $this->getTypeCheck()->isArray($value);
  45123. }
  45124. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  45125. if ('integer' === $type) {
  45126. if ($coerce) {
  45127. $value = $this->toInteger($value);
  45128. }
  45129. return is_int($value);
  45130. }
  45131. if ('number' === $type) {
  45132. if ($coerce) {
  45133. $value = $this->toNumber($value);
  45134. }
  45135. return is_numeric($value) && !is_string($value);
  45136. }
  45137. if ('boolean' === $type) {
  45138. if ($coerce) {
  45139. $value = $this->toBoolean($value);
  45140. }
  45141. return is_bool($value);
  45142. }
  45143. if ('string' === $type) {
  45144. return is_string($value);
  45145. }
  45146. if ('email' === $type) {
  45147. return is_string($value);
  45148. }
  45149. if ('null' === $type) {
  45150. return is_null($value);
  45151. }
  45152. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  45153. }
  45154. protected function toBoolean($value)
  45155. {
  45156. if ($value === 'true') {
  45157. return true;
  45158. }
  45159. if ($value === 'false') {
  45160. return false;
  45161. }
  45162. return $value;
  45163. }
  45164. protected function toNumber($value)
  45165. {
  45166. if (is_numeric($value)) {
  45167. return $value + 0;
  45168. }
  45169. return $value;
  45170. }
  45171. protected function toInteger($value)
  45172. {
  45173. if (is_numeric($value) && (int) $value == $value) {
  45174. return (int) $value;
  45175. }
  45176. return $value;
  45177. }
  45178. }
  45179. <?php
  45180. namespace JsonSchema\Constraints;
  45181. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  45182. use JsonSchema\Entity\JsonPointer;
  45183. use JsonSchema\Exception\ValidationException;
  45184. use JsonSchema\Uri\UriResolver;
  45185. class UndefinedConstraint extends Constraint
  45186. {
  45187. protected $appliedDefaults = array();
  45188. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  45189. {
  45190. if (is_null($schema) || !is_object($schema)) {
  45191. return;
  45192. }
  45193. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  45194. if ($fromDefault) {
  45195. $path->setFromDefault();
  45196. }
  45197. $this->validateCommonProperties($value, $schema, $path, $i);
  45198. $this->validateOfProperties($value, $schema, $path, '');
  45199. $this->validateTypes($value, $schema, $path, $i);
  45200. }
  45201. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  45202. {
  45203. if ($this->getTypeCheck()->isArray($value)) {
  45204. $this->checkArray($value, $schema, $path, $i);
  45205. }
  45206. if (LooseTypeCheck::isObject($value)) {
  45207. $this->checkObject(
  45208. $value,
  45209. $schema,
  45210. $path,
  45211. isset($schema->properties) ? $schema->properties : null,
  45212. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  45213. isset($schema->patternProperties) ? $schema->patternProperties : null,
  45214. $this->appliedDefaults
  45215. );
  45216. }
  45217. if (is_string($value)) {
  45218. $this->checkString($value, $schema, $path, $i);
  45219. }
  45220. if (is_numeric($value)) {
  45221. $this->checkNumber($value, $schema, $path, $i);
  45222. }
  45223. if (isset($schema->enum)) {
  45224. $this->checkEnum($value, $schema, $path, $i);
  45225. }
  45226. }
  45227. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  45228. {
  45229. if (isset($schema->extends)) {
  45230. if (is_string($schema->extends)) {
  45231. $schema->extends = $this->validateUri($schema, $schema->extends);
  45232. }
  45233. if (is_array($schema->extends)) {
  45234. foreach ($schema->extends as $extends) {
  45235. $this->checkUndefined($value, $extends, $path, $i);
  45236. }
  45237. } else {
  45238. $this->checkUndefined($value, $schema->extends, $path, $i);
  45239. }
  45240. }
  45241. if (!$path->fromDefault()) {
  45242. $this->applyDefaultValues($value, $schema, $path);
  45243. }
  45244. if ($this->getTypeCheck()->isObject($value)) {
  45245. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  45246. foreach ($schema->required as $required) {
  45247. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  45248. $this->addError(
  45249. $this->incrementPath($path ?: new JsonPointer(''), $required),
  45250. 'The property ' . $required . ' is required',
  45251. 'required'
  45252. );
  45253. }
  45254. }
  45255. } elseif (isset($schema->required) && !is_array($schema->required)) {
  45256. if ($schema->required && $value instanceof self) {
  45257. $propertyPaths = $path->getPropertyPaths();
  45258. $propertyName = end($propertyPaths);
  45259. $this->addError(
  45260. $path,
  45261. 'The property ' . $propertyName . ' is required',
  45262. 'required'
  45263. );
  45264. }
  45265. } else {
  45266. if ($value instanceof self) {
  45267. return;
  45268. }
  45269. }
  45270. }
  45271. if (!($value instanceof self)) {
  45272. $this->checkType($value, $schema, $path, $i);
  45273. }
  45274. if (isset($schema->disallow)) {
  45275. $initErrors = $this->getErrors();
  45276. $typeSchema = new \stdClass();
  45277. $typeSchema->type = $schema->disallow;
  45278. $this->checkType($value, $typeSchema, $path);
  45279. if (count($this->getErrors()) == count($initErrors)) {
  45280. $this->addError($path, 'Disallowed value was matched', 'disallow');
  45281. } else {
  45282. $this->errors = $initErrors;
  45283. }
  45284. }
  45285. if (isset($schema->not)) {
  45286. $initErrors = $this->getErrors();
  45287. $this->checkUndefined($value, $schema->not, $path, $i);
  45288. if (count($this->getErrors()) == count($initErrors)) {
  45289. $this->addError($path, 'Matched a schema which it should not', 'not');
  45290. } else {
  45291. $this->errors = $initErrors;
  45292. }
  45293. }
  45294. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  45295. $this->validateDependencies($value, $schema->dependencies, $path);
  45296. }
  45297. }
  45298. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  45299. {
  45300. if (!$requiredOnly) {
  45301. return true;
  45302. }
  45303. if (
  45304. $name !== null
  45305. && isset($parentSchema->required)
  45306. && is_array($parentSchema->required)
  45307. && in_array($name, $parentSchema->required)
  45308. ) {
  45309. return true;
  45310. }
  45311. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  45312. return true;
  45313. }
  45314. return false;
  45315. }
  45316. protected function applyDefaultValues(&$value, $schema, $path)
  45317. {
  45318. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  45319. return;
  45320. }
  45321. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  45322. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  45323. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  45324. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  45325. if (
  45326. !LooseTypeCheck::propertyExists($value, $currentProperty)
  45327. && property_exists($propertyDefinition, 'default')
  45328. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  45329. ) {
  45330. if (is_object($propertyDefinition->default)) {
  45331. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  45332. } else {
  45333. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  45334. }
  45335. $this->appliedDefaults[] = $currentProperty;
  45336. }
  45337. }
  45338. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  45339. $items = array();
  45340. if (LooseTypeCheck::isArray($schema->items)) {
  45341. $items = $schema->items;
  45342. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  45343. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  45344. }
  45345. foreach ($items as $currentItem => $itemDefinition) {
  45346. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  45347. if (
  45348. !array_key_exists($currentItem, $value)
  45349. && property_exists($itemDefinition, 'default')
  45350. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  45351. if (is_object($itemDefinition->default)) {
  45352. $value[$currentItem] = clone $itemDefinition->default;
  45353. } else {
  45354. $value[$currentItem] = $itemDefinition->default;
  45355. }
  45356. }
  45357. $path->setFromDefault();
  45358. }
  45359. } elseif (
  45360. $value instanceof self
  45361. && property_exists($schema, 'default')
  45362. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  45363. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  45364. $path->setFromDefault();
  45365. }
  45366. }
  45367. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  45368. {
  45369. if ($value instanceof self) {
  45370. return;
  45371. }
  45372. if (isset($schema->allOf)) {
  45373. $isValid = true;
  45374. foreach ($schema->allOf as $allOf) {
  45375. $initErrors = $this->getErrors();
  45376. $this->checkUndefined($value, $allOf, $path, $i);
  45377. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  45378. }
  45379. if (!$isValid) {
  45380. $this->addError($path, 'Failed to match all schemas', 'allOf');
  45381. }
  45382. }
  45383. if (isset($schema->anyOf)) {
  45384. $isValid = false;
  45385. $startErrors = $this->getErrors();
  45386. $caughtException = null;
  45387. foreach ($schema->anyOf as $anyOf) {
  45388. $initErrors = $this->getErrors();
  45389. try {
  45390. $this->checkUndefined($value, $anyOf, $path, $i);
  45391. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  45392. break;
  45393. }
  45394. } catch (ValidationException $e) {
  45395. $isValid = false;
  45396. }
  45397. }
  45398. if (!$isValid) {
  45399. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  45400. } else {
  45401. $this->errors = $startErrors;
  45402. }
  45403. }
  45404. if (isset($schema->oneOf)) {
  45405. $allErrors = array();
  45406. $matchedSchemas = 0;
  45407. $startErrors = $this->getErrors();
  45408. foreach ($schema->oneOf as $oneOf) {
  45409. try {
  45410. $this->errors = array();
  45411. $this->checkUndefined($value, $oneOf, $path, $i);
  45412. if (count($this->getErrors()) == 0) {
  45413. $matchedSchemas++;
  45414. }
  45415. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  45416. } catch (ValidationException $e) {
  45417. }
  45418. }
  45419. if ($matchedSchemas !== 1) {
  45420. $this->addErrors(array_merge($allErrors, $startErrors));
  45421. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  45422. } else {
  45423. $this->errors = $startErrors;
  45424. }
  45425. }
  45426. }
  45427. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  45428. {
  45429. foreach ($dependencies as $key => $dependency) {
  45430. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  45431. if (is_string($dependency)) {
  45432. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  45433. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  45434. }
  45435. } elseif (is_array($dependency)) {
  45436. foreach ($dependency as $d) {
  45437. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  45438. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  45439. }
  45440. }
  45441. } elseif (is_object($dependency)) {
  45442. $this->checkUndefined($value, $dependency, $path, $i);
  45443. }
  45444. }
  45445. }
  45446. }
  45447. protected function validateUri($schema, $schemaUri = null)
  45448. {
  45449. $resolver = new UriResolver();
  45450. $retriever = $this->factory->getUriRetriever();
  45451. $jsonSchema = null;
  45452. if ($resolver->isValid($schemaUri)) {
  45453. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  45454. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  45455. }
  45456. return $jsonSchema;
  45457. }
  45458. }
  45459. <?php
  45460. namespace JsonSchema\Entity;
  45461. use JsonSchema\Exception\InvalidArgumentException;
  45462. class JsonPointer
  45463. {
  45464. private $filename;
  45465. private $propertyPaths = array();
  45466. private $fromDefault = false;
  45467. public function __construct($value)
  45468. {
  45469. if (!is_string($value)) {
  45470. throw new InvalidArgumentException('Ref value must be a string');
  45471. }
  45472. $splitRef = explode('#', $value, 2);
  45473. $this->filename = $splitRef[0];
  45474. if (array_key_exists(1, $splitRef)) {
  45475. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  45476. }
  45477. }
  45478. private function decodePropertyPaths($propertyPathString)
  45479. {
  45480. $paths = array();
  45481. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  45482. $path = $this->decodePath($path);
  45483. if (is_string($path) && '' !== $path) {
  45484. $paths[] = $path;
  45485. }
  45486. }
  45487. return $paths;
  45488. }
  45489. private function encodePropertyPaths()
  45490. {
  45491. return array_map(
  45492. array($this, 'encodePath'),
  45493. $this->getPropertyPaths()
  45494. );
  45495. }
  45496. private function decodePath($path)
  45497. {
  45498. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  45499. }
  45500. private function encodePath($path)
  45501. {
  45502. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  45503. }
  45504. public function getFilename()
  45505. {
  45506. return $this->filename;
  45507. }
  45508. public function getPropertyPaths()
  45509. {
  45510. return $this->propertyPaths;
  45511. }
  45512. public function withPropertyPaths(array $propertyPaths)
  45513. {
  45514. $new = clone $this;
  45515. $new->propertyPaths = $propertyPaths;
  45516. return $new;
  45517. }
  45518. public function getPropertyPathAsString()
  45519. {
  45520. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  45521. }
  45522. public function __toString()
  45523. {
  45524. return $this->getFilename() . $this->getPropertyPathAsString();
  45525. }
  45526. public function setFromDefault()
  45527. {
  45528. $this->fromDefault = true;
  45529. }
  45530. public function fromDefault()
  45531. {
  45532. return $this->fromDefault;
  45533. }
  45534. }
  45535. <?php
  45536. namespace JsonSchema\Exception;
  45537. interface ExceptionInterface
  45538. {
  45539. }
  45540. <?php
  45541. namespace JsonSchema\Exception;
  45542. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  45543. {
  45544. }
  45545. <?php
  45546. namespace JsonSchema\Exception;
  45547. class InvalidConfigException extends RuntimeException
  45548. {
  45549. }
  45550. <?php
  45551. namespace JsonSchema\Exception;
  45552. class InvalidSchemaException extends RuntimeException
  45553. {
  45554. }
  45555. <?php
  45556. namespace JsonSchema\Exception;
  45557. class InvalidSchemaMediaTypeException extends RuntimeException
  45558. {
  45559. }
  45560. <?php
  45561. namespace JsonSchema\Exception;
  45562. class InvalidSourceUriException extends InvalidArgumentException
  45563. {
  45564. }
  45565. <?php
  45566. namespace JsonSchema\Exception;
  45567. class JsonDecodingException extends RuntimeException
  45568. {
  45569. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  45570. {
  45571. switch ($code) {
  45572. case JSON_ERROR_DEPTH:
  45573. $message = 'The maximum stack depth has been exceeded';
  45574. break;
  45575. case JSON_ERROR_STATE_MISMATCH:
  45576. $message = 'Invalid or malformed JSON';
  45577. break;
  45578. case JSON_ERROR_CTRL_CHAR:
  45579. $message = 'Control character error, possibly incorrectly encoded';
  45580. break;
  45581. case JSON_ERROR_UTF8:
  45582. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  45583. break;
  45584. case JSON_ERROR_SYNTAX:
  45585. $message = 'JSON syntax is malformed';
  45586. break;
  45587. default:
  45588. $message = 'Syntax error';
  45589. }
  45590. parent::__construct($message, $code, $previous);
  45591. }
  45592. }
  45593. <?php
  45594. namespace JsonSchema\Exception;
  45595. class ResourceNotFoundException extends RuntimeException
  45596. {
  45597. }
  45598. <?php
  45599. namespace JsonSchema\Exception;
  45600. class RuntimeException extends \RuntimeException implements ExceptionInterface
  45601. {
  45602. }
  45603. <?php
  45604. namespace JsonSchema\Exception;
  45605. class UnresolvableJsonPointerException extends InvalidArgumentException
  45606. {
  45607. }
  45608. <?php
  45609. namespace JsonSchema\Exception;
  45610. class UriResolverException extends RuntimeException
  45611. {
  45612. }
  45613. <?php
  45614. namespace JsonSchema\Exception;
  45615. class ValidationException extends RuntimeException
  45616. {
  45617. }
  45618. <?php
  45619. namespace JsonSchema\Iterator;
  45620. class ObjectIterator implements \Iterator, \Countable
  45621. {
  45622. private $object;
  45623. private $position = 0;
  45624. private $data = array();
  45625. private $initialized = false;
  45626. public function __construct($object)
  45627. {
  45628. $this->object = $object;
  45629. }
  45630. public function current()
  45631. {
  45632. $this->initialize();
  45633. return $this->data[$this->position];
  45634. }
  45635. public function next()
  45636. {
  45637. $this->initialize();
  45638. $this->position++;
  45639. }
  45640. public function key()
  45641. {
  45642. $this->initialize();
  45643. return $this->position;
  45644. }
  45645. public function valid()
  45646. {
  45647. $this->initialize();
  45648. return isset($this->data[$this->position]);
  45649. }
  45650. public function rewind()
  45651. {
  45652. $this->initialize();
  45653. $this->position = 0;
  45654. }
  45655. public function count()
  45656. {
  45657. $this->initialize();
  45658. return count($this->data);
  45659. }
  45660. private function initialize()
  45661. {
  45662. if (!$this->initialized) {
  45663. $this->data = $this->buildDataFromObject($this->object);
  45664. $this->initialized = true;
  45665. }
  45666. }
  45667. private function buildDataFromObject($object)
  45668. {
  45669. $result = array();
  45670. $stack = new \SplStack();
  45671. $stack->push($object);
  45672. while (!$stack->isEmpty()) {
  45673. $current = $stack->pop();
  45674. if (is_object($current)) {
  45675. array_push($result, $current);
  45676. }
  45677. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  45678. if (is_object($propertyValue) || is_array($propertyValue)) {
  45679. $stack->push($propertyValue);
  45680. }
  45681. }
  45682. }
  45683. return $result;
  45684. }
  45685. private function getDataFromItem($item)
  45686. {
  45687. if (!is_object($item) && !is_array($item)) {
  45688. return array();
  45689. }
  45690. return is_object($item) ? get_object_vars($item) : $item;
  45691. }
  45692. }
  45693. <?php
  45694. namespace JsonSchema;
  45695. class Rfc3339
  45696. {
  45697. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  45698. public static function createFromString($string)
  45699. {
  45700. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  45701. return null;
  45702. }
  45703. $dateAndTime = $matches[1];
  45704. $microseconds = $matches[2] ?: '.000000';
  45705. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  45706. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  45707. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  45708. return $dateTime ?: null;
  45709. }
  45710. }
  45711. <?php
  45712. namespace JsonSchema;
  45713. use JsonSchema\Constraints\BaseConstraint;
  45714. use JsonSchema\Entity\JsonPointer;
  45715. use JsonSchema\Exception\UnresolvableJsonPointerException;
  45716. use JsonSchema\Uri\UriResolver;
  45717. use JsonSchema\Uri\UriRetriever;
  45718. class SchemaStorage implements SchemaStorageInterface
  45719. {
  45720. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  45721. protected $uriRetriever;
  45722. protected $uriResolver;
  45723. protected $schemas = array();
  45724. public function __construct(
  45725. UriRetrieverInterface $uriRetriever = null,
  45726. UriResolverInterface $uriResolver = null
  45727. ) {
  45728. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  45729. $this->uriResolver = $uriResolver ?: new UriResolver();
  45730. }
  45731. public function getUriRetriever()
  45732. {
  45733. return $this->uriRetriever;
  45734. }
  45735. public function getUriResolver()
  45736. {
  45737. return $this->uriResolver;
  45738. }
  45739. public function addSchema($id, $schema = null)
  45740. {
  45741. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  45742. $schema = $this->uriRetriever->retrieve($id);
  45743. }
  45744. if (is_array($schema)) {
  45745. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  45746. }
  45747. if (is_object($schema) && property_exists($schema, 'id')) {
  45748. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  45749. $schema->properties->id->format = 'uri-reference';
  45750. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  45751. $schema->properties->id->format = 'uri-reference';
  45752. $schema->properties->{'$ref'}->format = 'uri-reference';
  45753. }
  45754. }
  45755. $this->expandRefs($schema, $id);
  45756. $this->schemas[$id] = $schema;
  45757. }
  45758. private function expandRefs(&$schema, $base = null)
  45759. {
  45760. if (!is_object($schema)) {
  45761. if (is_array($schema)) {
  45762. foreach ($schema as &$member) {
  45763. $this->expandRefs($member, $base);
  45764. }
  45765. }
  45766. return;
  45767. }
  45768. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  45769. $base = $this->uriResolver->resolve($schema->id, $base);
  45770. }
  45771. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  45772. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  45773. $schema->{'$ref'} = (string) $refPointer;
  45774. }
  45775. foreach ($schema as &$member) {
  45776. $this->expandRefs($member, $base);
  45777. }
  45778. }
  45779. public function getSchema($id)
  45780. {
  45781. if (!array_key_exists($id, $this->schemas)) {
  45782. $this->addSchema($id);
  45783. }
  45784. return $this->schemas[$id];
  45785. }
  45786. public function resolveRef($ref)
  45787. {
  45788. $jsonPointer = new JsonPointer($ref);
  45789. $fileName = $jsonPointer->getFilename();
  45790. if (!strlen($fileName)) {
  45791. throw new UnresolvableJsonPointerException(sprintf(
  45792. "Could not resolve fragment '%s': no file is defined",
  45793. $jsonPointer->getPropertyPathAsString()
  45794. ));
  45795. }
  45796. $refSchema = $this->getSchema($fileName);
  45797. foreach ($jsonPointer->getPropertyPaths() as $path) {
  45798. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  45799. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  45800. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  45801. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  45802. } else {
  45803. throw new UnresolvableJsonPointerException(sprintf(
  45804. 'File: %s is found, but could not resolve fragment: %s',
  45805. $jsonPointer->getFilename(),
  45806. $jsonPointer->getPropertyPathAsString()
  45807. ));
  45808. }
  45809. }
  45810. return $refSchema;
  45811. }
  45812. public function resolveRefSchema($refSchema)
  45813. {
  45814. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  45815. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  45816. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  45817. unset($refSchema->{'$ref'});
  45818. }
  45819. return $refSchema;
  45820. }
  45821. }
  45822. <?php
  45823. namespace JsonSchema;
  45824. interface SchemaStorageInterface
  45825. {
  45826. public function addSchema($id, $schema = null);
  45827. public function getSchema($id);
  45828. public function resolveRef($ref);
  45829. public function resolveRefSchema($refSchema);
  45830. }
  45831. <?php
  45832. namespace JsonSchema\Uri\Retrievers;
  45833. abstract class AbstractRetriever implements UriRetrieverInterface
  45834. {
  45835. protected $contentType;
  45836. public function getContentType()
  45837. {
  45838. return $this->contentType;
  45839. }
  45840. }
  45841. <?php
  45842. namespace JsonSchema\Uri\Retrievers;
  45843. use JsonSchema\Exception\RuntimeException;
  45844. use JsonSchema\Validator;
  45845. class Curl extends AbstractRetriever
  45846. {
  45847. protected $messageBody;
  45848. public function __construct()
  45849. {
  45850. if (!function_exists('curl_init')) {
  45851. throw new RuntimeException('cURL not installed');
  45852. }
  45853. }
  45854. public function retrieve($uri)
  45855. {
  45856. $ch = curl_init();
  45857. curl_setopt($ch, CURLOPT_URL, $uri);
  45858. curl_setopt($ch, CURLOPT_HEADER, true);
  45859. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  45860. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  45861. $response = curl_exec($ch);
  45862. if (false === $response) {
  45863. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  45864. }
  45865. $this->fetchMessageBody($response);
  45866. $this->fetchContentType($response);
  45867. curl_close($ch);
  45868. return $this->messageBody;
  45869. }
  45870. private function fetchMessageBody($response)
  45871. {
  45872. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  45873. $this->messageBody = $match[1];
  45874. }
  45875. protected function fetchContentType($response)
  45876. {
  45877. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  45878. $this->contentType = trim($match[1]);
  45879. return true;
  45880. }
  45881. return false;
  45882. }
  45883. }
  45884. <?php
  45885. namespace JsonSchema\Uri\Retrievers;
  45886. use JsonSchema\Exception\ResourceNotFoundException;
  45887. class FileGetContents extends AbstractRetriever
  45888. {
  45889. protected $messageBody;
  45890. public function retrieve($uri)
  45891. {
  45892. $errorMessage = null;
  45893. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  45894. $errorMessage = $errstr;
  45895. });
  45896. $response = file_get_contents($uri);
  45897. restore_error_handler();
  45898. if ($errorMessage) {
  45899. throw new ResourceNotFoundException($errorMessage);
  45900. }
  45901. if (false === $response) {
  45902. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45903. }
  45904. if ($response == ''
  45905. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  45906. ) {
  45907. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45908. }
  45909. $this->messageBody = $response;
  45910. if (!empty($http_response_header)) {
  45911. $this->fetchContentType($http_response_header);
  45912. } else {
  45913. $this->contentType = null;
  45914. }
  45915. return $this->messageBody;
  45916. }
  45917. private function fetchContentType(array $headers)
  45918. {
  45919. foreach ($headers as $header) {
  45920. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  45921. return true;
  45922. }
  45923. }
  45924. return false;
  45925. }
  45926. protected static function getContentTypeMatchInHeader($header)
  45927. {
  45928. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  45929. return trim($match[1]);
  45930. }
  45931. return null;
  45932. }
  45933. }
  45934. <?php
  45935. namespace JsonSchema\Uri\Retrievers;
  45936. use JsonSchema\Validator;
  45937. class PredefinedArray extends AbstractRetriever
  45938. {
  45939. private $schemas;
  45940. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  45941. {
  45942. $this->schemas = $schemas;
  45943. $this->contentType = $contentType;
  45944. }
  45945. public function retrieve($uri)
  45946. {
  45947. if (!array_key_exists($uri, $this->schemas)) {
  45948. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  45949. 'The JSON schema "%s" was not found.',
  45950. $uri
  45951. ));
  45952. }
  45953. return $this->schemas[$uri];
  45954. }
  45955. }
  45956. <?php
  45957. namespace JsonSchema\Uri\Retrievers;
  45958. interface UriRetrieverInterface
  45959. {
  45960. public function retrieve($uri);
  45961. public function getContentType();
  45962. }
  45963. <?php
  45964. namespace JsonSchema\Uri;
  45965. use JsonSchema\Exception\UriResolverException;
  45966. use JsonSchema\UriResolverInterface;
  45967. class UriResolver implements UriResolverInterface
  45968. {
  45969. public function parse($uri)
  45970. {
  45971. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  45972. $components = array();
  45973. if (5 < count($match)) {
  45974. $components = array(
  45975. 'scheme' => $match[2],
  45976. 'authority' => $match[4],
  45977. 'path' => $match[5]
  45978. );
  45979. }
  45980. if (7 < count($match)) {
  45981. $components['query'] = $match[7];
  45982. }
  45983. if (9 < count($match)) {
  45984. $components['fragment'] = $match[9];
  45985. }
  45986. return $components;
  45987. }
  45988. public function generate(array $components)
  45989. {
  45990. $uri = $components['scheme'] . '://'
  45991. . $components['authority']
  45992. . $components['path'];
  45993. if (array_key_exists('query', $components) && strlen($components['query'])) {
  45994. $uri .= '?' . $components['query'];
  45995. }
  45996. if (array_key_exists('fragment', $components)) {
  45997. $uri .= '#' . $components['fragment'];
  45998. }
  45999. return $uri;
  46000. }
  46001. public function resolve($uri, $baseUri = null)
  46002. {
  46003. if (
  46004. !is_null($baseUri) &&
  46005. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  46006. !preg_match('|^[^/]+://|u', $baseUri)
  46007. ) {
  46008. if (is_file($baseUri)) {
  46009. $baseUri = 'file://' . realpath($baseUri);
  46010. } elseif (is_dir($baseUri)) {
  46011. $baseUri = 'file://' . realpath($baseUri) . '/';
  46012. } else {
  46013. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  46014. }
  46015. }
  46016. if ($uri == '') {
  46017. return $baseUri;
  46018. }
  46019. $components = $this->parse($uri);
  46020. $path = $components['path'];
  46021. if (!empty($components['scheme'])) {
  46022. return $uri;
  46023. }
  46024. $baseComponents = $this->parse($baseUri);
  46025. $basePath = $baseComponents['path'];
  46026. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  46027. if (isset($components['fragment'])) {
  46028. $baseComponents['fragment'] = $components['fragment'];
  46029. }
  46030. return $this->generate($baseComponents);
  46031. }
  46032. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  46033. {
  46034. $relativePath = self::normalizePath($relativePath);
  46035. if ($relativePath == '') {
  46036. return $basePath;
  46037. }
  46038. if ($relativePath[0] == '/') {
  46039. return $relativePath;
  46040. }
  46041. $basePathSegments = explode('/', $basePath);
  46042. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  46043. $numLevelUp = strlen($match[0]) /3 + 1;
  46044. if ($numLevelUp >= count($basePathSegments)) {
  46045. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  46046. }
  46047. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  46048. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  46049. return implode('/', $basePathSegments) . '/' . $path;
  46050. }
  46051. private static function normalizePath($path)
  46052. {
  46053. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  46054. $path = preg_replace('|//|', '/', $path);
  46055. return $path;
  46056. }
  46057. public function isValid($uri)
  46058. {
  46059. $components = $this->parse($uri);
  46060. return !empty($components);
  46061. }
  46062. }
  46063. <?php
  46064. namespace JsonSchema\Uri;
  46065. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  46066. use JsonSchema\Exception\JsonDecodingException;
  46067. use JsonSchema\Exception\ResourceNotFoundException;
  46068. use JsonSchema\Uri\Retrievers\FileGetContents;
  46069. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  46070. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  46071. use JsonSchema\Validator;
  46072. class UriRetriever implements BaseUriRetrieverInterface
  46073. {
  46074. protected $translationMap = array(
  46075. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  46076. );
  46077. protected $allowedInvalidContentTypeEndpoints = array(
  46078. 'http://json-schema.org/',
  46079. 'https://json-schema.org/'
  46080. );
  46081. protected $uriRetriever = null;
  46082. private $schemaCache = array();
  46083. public function addInvalidContentTypeEndpoint($endpoint)
  46084. {
  46085. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  46086. }
  46087. public function confirmMediaType($uriRetriever, $uri)
  46088. {
  46089. $contentType = $uriRetriever->getContentType();
  46090. if (is_null($contentType)) {
  46091. return;
  46092. }
  46093. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  46094. return;
  46095. }
  46096. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  46097. if (strpos($uri, $endpoint) === 0) {
  46098. return true;
  46099. }
  46100. }
  46101. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  46102. }
  46103. public function getUriRetriever()
  46104. {
  46105. if (is_null($this->uriRetriever)) {
  46106. $this->setUriRetriever(new FileGetContents());
  46107. }
  46108. return $this->uriRetriever;
  46109. }
  46110. public function resolvePointer($jsonSchema, $uri)
  46111. {
  46112. $resolver = new UriResolver();
  46113. $parsed = $resolver->parse($uri);
  46114. if (empty($parsed['fragment'])) {
  46115. return $jsonSchema;
  46116. }
  46117. $path = explode('/', $parsed['fragment']);
  46118. while ($path) {
  46119. $pathElement = array_shift($path);
  46120. if (!empty($pathElement)) {
  46121. $pathElement = str_replace('~1', '/', $pathElement);
  46122. $pathElement = str_replace('~0', '~', $pathElement);
  46123. if (!empty($jsonSchema->$pathElement)) {
  46124. $jsonSchema = $jsonSchema->$pathElement;
  46125. } else {
  46126. throw new ResourceNotFoundException(
  46127. 'Fragment "' . $parsed['fragment'] . '" not found'
  46128. . ' in ' . $uri
  46129. );
  46130. }
  46131. if (!is_object($jsonSchema)) {
  46132. throw new ResourceNotFoundException(
  46133. 'Fragment part "' . $pathElement . '" is no object '
  46134. . ' in ' . $uri
  46135. );
  46136. }
  46137. }
  46138. }
  46139. return $jsonSchema;
  46140. }
  46141. public function retrieve($uri, $baseUri = null, $translate = true)
  46142. {
  46143. $resolver = new UriResolver();
  46144. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  46145. $arParts = $resolver->parse($resolvedUri);
  46146. if (isset($arParts['fragment'])) {
  46147. unset($arParts['fragment']);
  46148. $fetchUri = $resolver->generate($arParts);
  46149. }
  46150. if ($translate) {
  46151. $fetchUri = $this->translate($fetchUri);
  46152. }
  46153. $jsonSchema = $this->loadSchema($fetchUri);
  46154. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  46155. if ($jsonSchema instanceof \stdClass) {
  46156. $jsonSchema->id = $resolvedUri;
  46157. }
  46158. return $jsonSchema;
  46159. }
  46160. protected function loadSchema($fetchUri)
  46161. {
  46162. if (isset($this->schemaCache[$fetchUri])) {
  46163. return $this->schemaCache[$fetchUri];
  46164. }
  46165. $uriRetriever = $this->getUriRetriever();
  46166. $contents = $this->uriRetriever->retrieve($fetchUri);
  46167. $this->confirmMediaType($uriRetriever, $fetchUri);
  46168. $jsonSchema = json_decode($contents);
  46169. if (JSON_ERROR_NONE < $error = json_last_error()) {
  46170. throw new JsonDecodingException($error);
  46171. }
  46172. $this->schemaCache[$fetchUri] = $jsonSchema;
  46173. return $jsonSchema;
  46174. }
  46175. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  46176. {
  46177. $this->uriRetriever = $uriRetriever;
  46178. return $this;
  46179. }
  46180. public function parse($uri)
  46181. {
  46182. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  46183. $components = array();
  46184. if (5 < count($match)) {
  46185. $components = array(
  46186. 'scheme' => $match[2],
  46187. 'authority' => $match[4],
  46188. 'path' => $match[5]
  46189. );
  46190. }
  46191. if (7 < count($match)) {
  46192. $components['query'] = $match[7];
  46193. }
  46194. if (9 < count($match)) {
  46195. $components['fragment'] = $match[9];
  46196. }
  46197. return $components;
  46198. }
  46199. public function generate(array $components)
  46200. {
  46201. $uri = $components['scheme'] . '://'
  46202. . $components['authority']
  46203. . $components['path'];
  46204. if (array_key_exists('query', $components)) {
  46205. $uri .= $components['query'];
  46206. }
  46207. if (array_key_exists('fragment', $components)) {
  46208. $uri .= $components['fragment'];
  46209. }
  46210. return $uri;
  46211. }
  46212. public function resolve($uri, $baseUri = null)
  46213. {
  46214. $components = $this->parse($uri);
  46215. $path = $components['path'];
  46216. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  46217. return $uri;
  46218. }
  46219. $baseComponents = $this->parse($baseUri);
  46220. $basePath = $baseComponents['path'];
  46221. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  46222. return $this->generate($baseComponents);
  46223. }
  46224. public function isValid($uri)
  46225. {
  46226. $components = $this->parse($uri);
  46227. return !empty($components);
  46228. }
  46229. public function setTranslation($from, $to)
  46230. {
  46231. $this->translationMap[$from] = $to;
  46232. }
  46233. public function translate($uri)
  46234. {
  46235. foreach ($this->translationMap as $from => $to) {
  46236. $uri = preg_replace($from, $to, $uri);
  46237. }
  46238. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  46239. return $uri;
  46240. }
  46241. }
  46242. <?php
  46243. namespace JsonSchema;
  46244. interface UriResolverInterface
  46245. {
  46246. public function resolve($uri, $baseUri = null);
  46247. }
  46248. <?php
  46249. namespace JsonSchema;
  46250. interface UriRetrieverInterface
  46251. {
  46252. public function retrieve($uri, $baseUri = null);
  46253. }
  46254. <?php
  46255. namespace JsonSchema;
  46256. use JsonSchema\Constraints\BaseConstraint;
  46257. use JsonSchema\Constraints\Constraint;
  46258. class Validator extends BaseConstraint
  46259. {
  46260. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  46261. const ERROR_NONE = 0x00000000;
  46262. const ERROR_ALL = 0xFFFFFFFF;
  46263. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  46264. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  46265. public function validate(&$value, $schema = null, $checkMode = null)
  46266. {
  46267. if (is_array($schema)) {
  46268. $schema = self::arrayToObjectRecursive($schema);
  46269. }
  46270. $initialCheckMode = $this->factory->getConfig();
  46271. if ($checkMode !== null) {
  46272. $this->factory->setConfig($checkMode);
  46273. }
  46274. if (is_object($schema) && property_exists($schema, 'id')) {
  46275. $schemaURI = $schema->id;
  46276. } else {
  46277. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  46278. }
  46279. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  46280. $validator = $this->factory->createInstanceFor('schema');
  46281. $validator->check(
  46282. $value,
  46283. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  46284. );
  46285. $this->factory->setConfig($initialCheckMode);
  46286. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  46287. return $validator->getErrorMask();
  46288. }
  46289. public function check($value, $schema)
  46290. {
  46291. return $this->validate($value, $schema);
  46292. }
  46293. public function coerce(&$value, $schema)
  46294. {
  46295. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  46296. }
  46297. }
  46298. Copyright (c) 2012 PHP Framework Interoperability Group
  46299. Permission is hereby granted, free of charge, to any person obtaining a copy
  46300. of this software and associated documentation files (the "Software"), to deal
  46301. in the Software without restriction, including without limitation the rights
  46302. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46303. copies of the Software, and to permit persons to whom the Software is
  46304. furnished to do so, subject to the following conditions:
  46305. The above copyright notice and this permission notice shall be included in
  46306. all copies or substantial portions of the Software.
  46307. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46308. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46309. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46310. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46311. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46312. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  46313. THE SOFTWARE.
  46314. <?php
  46315. namespace Psr\Log;
  46316. abstract class AbstractLogger implements LoggerInterface
  46317. {
  46318. public function emergency($message, array $context = array())
  46319. {
  46320. $this->log(LogLevel::EMERGENCY, $message, $context);
  46321. }
  46322. public function alert($message, array $context = array())
  46323. {
  46324. $this->log(LogLevel::ALERT, $message, $context);
  46325. }
  46326. public function critical($message, array $context = array())
  46327. {
  46328. $this->log(LogLevel::CRITICAL, $message, $context);
  46329. }
  46330. public function error($message, array $context = array())
  46331. {
  46332. $this->log(LogLevel::ERROR, $message, $context);
  46333. }
  46334. public function warning($message, array $context = array())
  46335. {
  46336. $this->log(LogLevel::WARNING, $message, $context);
  46337. }
  46338. public function notice($message, array $context = array())
  46339. {
  46340. $this->log(LogLevel::NOTICE, $message, $context);
  46341. }
  46342. public function info($message, array $context = array())
  46343. {
  46344. $this->log(LogLevel::INFO, $message, $context);
  46345. }
  46346. public function debug($message, array $context = array())
  46347. {
  46348. $this->log(LogLevel::DEBUG, $message, $context);
  46349. }
  46350. }
  46351. <?php
  46352. namespace Psr\Log;
  46353. class InvalidArgumentException extends \InvalidArgumentException
  46354. {
  46355. }
  46356. <?php
  46357. namespace Psr\Log;
  46358. class LogLevel
  46359. {
  46360. const EMERGENCY = 'emergency';
  46361. const ALERT = 'alert';
  46362. const CRITICAL = 'critical';
  46363. const ERROR = 'error';
  46364. const WARNING = 'warning';
  46365. const NOTICE = 'notice';
  46366. const INFO = 'info';
  46367. const DEBUG = 'debug';
  46368. }
  46369. <?php
  46370. namespace Psr\Log;
  46371. interface LoggerAwareInterface
  46372. {
  46373. public function setLogger(LoggerInterface $logger);
  46374. }
  46375. <?php
  46376. namespace Psr\Log;
  46377. trait LoggerAwareTrait
  46378. {
  46379. protected $logger;
  46380. public function setLogger(LoggerInterface $logger)
  46381. {
  46382. $this->logger = $logger;
  46383. }
  46384. }
  46385. <?php
  46386. namespace Psr\Log;
  46387. interface LoggerInterface
  46388. {
  46389. public function emergency($message, array $context = array());
  46390. public function alert($message, array $context = array());
  46391. public function critical($message, array $context = array());
  46392. public function error($message, array $context = array());
  46393. public function warning($message, array $context = array());
  46394. public function notice($message, array $context = array());
  46395. public function info($message, array $context = array());
  46396. public function debug($message, array $context = array());
  46397. public function log($level, $message, array $context = array());
  46398. }
  46399. <?php
  46400. namespace Psr\Log;
  46401. trait LoggerTrait
  46402. {
  46403. public function emergency($message, array $context = array())
  46404. {
  46405. $this->log(LogLevel::EMERGENCY, $message, $context);
  46406. }
  46407. public function alert($message, array $context = array())
  46408. {
  46409. $this->log(LogLevel::ALERT, $message, $context);
  46410. }
  46411. public function critical($message, array $context = array())
  46412. {
  46413. $this->log(LogLevel::CRITICAL, $message, $context);
  46414. }
  46415. public function error($message, array $context = array())
  46416. {
  46417. $this->log(LogLevel::ERROR, $message, $context);
  46418. }
  46419. public function warning($message, array $context = array())
  46420. {
  46421. $this->log(LogLevel::WARNING, $message, $context);
  46422. }
  46423. public function notice($message, array $context = array())
  46424. {
  46425. $this->log(LogLevel::NOTICE, $message, $context);
  46426. }
  46427. public function info($message, array $context = array())
  46428. {
  46429. $this->log(LogLevel::INFO, $message, $context);
  46430. }
  46431. public function debug($message, array $context = array())
  46432. {
  46433. $this->log(LogLevel::DEBUG, $message, $context);
  46434. }
  46435. abstract public function log($level, $message, array $context = array());
  46436. }
  46437. <?php
  46438. namespace Psr\Log;
  46439. class NullLogger extends AbstractLogger
  46440. {
  46441. public function log($level, $message, array $context = array())
  46442. {
  46443. }
  46444. }
  46445. <?php
  46446. namespace Psr\Log\Test;
  46447. class DummyTest
  46448. {
  46449. public function __toString()
  46450. {
  46451. return 'DummyTest';
  46452. }
  46453. }
  46454. <?php
  46455. namespace Psr\Log\Test;
  46456. use Psr\Log\LoggerInterface;
  46457. use Psr\Log\LogLevel;
  46458. use PHPUnit\Framework\TestCase;
  46459. abstract class LoggerInterfaceTest extends TestCase
  46460. {
  46461. abstract public function getLogger();
  46462. abstract public function getLogs();
  46463. public function testImplements()
  46464. {
  46465. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  46466. }
  46467. public function testLogsAtAllLevels($level, $message)
  46468. {
  46469. $logger = $this->getLogger();
  46470. $logger->{$level}($message, array('user' => 'Bob'));
  46471. $logger->log($level, $message, array('user' => 'Bob'));
  46472. $expected = array(
  46473. $level.' message of level '.$level.' with context: Bob',
  46474. $level.' message of level '.$level.' with context: Bob',
  46475. );
  46476. $this->assertEquals($expected, $this->getLogs());
  46477. }
  46478. public function provideLevelsAndMessages()
  46479. {
  46480. return array(
  46481. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  46482. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  46483. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  46484. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  46485. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  46486. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  46487. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  46488. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  46489. );
  46490. }
  46491. public function testThrowsOnInvalidLevel()
  46492. {
  46493. $logger = $this->getLogger();
  46494. $logger->log('invalid level', 'Foo');
  46495. }
  46496. public function testContextReplacement()
  46497. {
  46498. $logger = $this->getLogger();
  46499. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  46500. $expected = array('info {Message {nothing} Bob Bar a}');
  46501. $this->assertEquals($expected, $this->getLogs());
  46502. }
  46503. public function testObjectCastToString()
  46504. {
  46505. if (method_exists($this, 'createPartialMock')) {
  46506. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  46507. } else {
  46508. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  46509. }
  46510. $dummy->expects($this->once())
  46511. ->method('__toString')
  46512. ->will($this->returnValue('DUMMY'));
  46513. $this->getLogger()->warning($dummy);
  46514. $expected = array('warning DUMMY');
  46515. $this->assertEquals($expected, $this->getLogs());
  46516. }
  46517. public function testContextCanContainAnything()
  46518. {
  46519. $closed = fopen('php://memory', 'r');
  46520. fclose($closed);
  46521. $context = array(
  46522. 'bool' => true,
  46523. 'null' => null,
  46524. 'string' => 'Foo',
  46525. 'int' => 0,
  46526. 'float' => 0.5,
  46527. 'nested' => array('with object' => new DummyTest),
  46528. 'object' => new \DateTime,
  46529. 'resource' => fopen('php://memory', 'r'),
  46530. 'closed' => $closed,
  46531. );
  46532. $this->getLogger()->warning('Crazy context data', $context);
  46533. $expected = array('warning Crazy context data');
  46534. $this->assertEquals($expected, $this->getLogs());
  46535. }
  46536. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  46537. {
  46538. $logger = $this->getLogger();
  46539. $logger->warning('Random message', array('exception' => 'oops'));
  46540. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  46541. $expected = array(
  46542. 'warning Random message',
  46543. 'critical Uncaught Exception!'
  46544. );
  46545. $this->assertEquals($expected, $this->getLogs());
  46546. }
  46547. }
  46548. <?php
  46549. namespace Psr\Log\Test;
  46550. use Psr\Log\AbstractLogger;
  46551. class TestLogger extends AbstractLogger
  46552. {
  46553. public $records = [];
  46554. public $recordsByLevel = [];
  46555. public function log($level, $message, array $context = [])
  46556. {
  46557. $record = [
  46558. 'level' => $level,
  46559. 'message' => $message,
  46560. 'context' => $context,
  46561. ];
  46562. $this->recordsByLevel[$record['level']][] = $record;
  46563. $this->records[] = $record;
  46564. }
  46565. public function hasRecords($level)
  46566. {
  46567. return isset($this->recordsByLevel[$level]);
  46568. }
  46569. public function hasRecord($record, $level)
  46570. {
  46571. if (is_string($record)) {
  46572. $record = ['message' => $record];
  46573. }
  46574. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  46575. if ($rec['message'] !== $record['message']) {
  46576. return false;
  46577. }
  46578. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  46579. return false;
  46580. }
  46581. return true;
  46582. }, $level);
  46583. }
  46584. public function hasRecordThatContains($message, $level)
  46585. {
  46586. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  46587. return strpos($rec['message'], $message) !== false;
  46588. }, $level);
  46589. }
  46590. public function hasRecordThatMatches($regex, $level)
  46591. {
  46592. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  46593. return preg_match($regex, $rec['message']) > 0;
  46594. }, $level);
  46595. }
  46596. public function hasRecordThatPasses(callable $predicate, $level)
  46597. {
  46598. if (!isset($this->recordsByLevel[$level])) {
  46599. return false;
  46600. }
  46601. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  46602. if (call_user_func($predicate, $rec, $i)) {
  46603. return true;
  46604. }
  46605. }
  46606. return false;
  46607. }
  46608. public function __call($method, $args)
  46609. {
  46610. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  46611. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  46612. $level = strtolower($matches[2]);
  46613. if (method_exists($this, $genericMethod)) {
  46614. $args[] = $level;
  46615. return call_user_func_array([$this, $genericMethod], $args);
  46616. }
  46617. }
  46618. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  46619. }
  46620. public function reset()
  46621. {
  46622. $this->records = [];
  46623. $this->recordsByLevel = [];
  46624. }
  46625. }
  46626. Copyright (c) 2012-2016 Jan Sorgalla
  46627. Permission is hereby granted, free of charge, to any person
  46628. obtaining a copy of this software and associated documentation
  46629. files (the "Software"), to deal in the Software without
  46630. restriction, including without limitation the rights to use,
  46631. copy, modify, merge, publish, distribute, sublicense, and/or sell
  46632. copies of the Software, and to permit persons to whom the
  46633. Software is furnished to do so, subject to the following
  46634. conditions:
  46635. The above copyright notice and this permission notice shall be
  46636. included in all copies or substantial portions of the Software.
  46637. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  46638. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  46639. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  46640. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  46641. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  46642. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  46643. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  46644. OTHER DEALINGS IN THE SOFTWARE.
  46645. <?php
  46646. namespace React\Promise;
  46647. interface CancellablePromiseInterface extends PromiseInterface
  46648. {
  46649. public function cancel();
  46650. }
  46651. <?php
  46652. namespace React\Promise;
  46653. class Deferred implements PromiseInterface, ResolverInterface, PromisorInterface, CancellablePromiseInterface
  46654. {
  46655. private $completed;
  46656. private $promise;
  46657. private $resolver;
  46658. private $handlers = array();
  46659. private $progressHandlers = array();
  46660. private $canceller;
  46661. private $requiredCancelRequests = 0;
  46662. private $cancelRequests = 0;
  46663. public function __construct($canceller = null)
  46664. {
  46665. if ($canceller !== null && !is_callable($canceller)) {
  46666. throw new \InvalidArgumentException(
  46667. sprintf(
  46668. 'The canceller argument must be null or of type callable, %s given.',
  46669. gettype($canceller)
  46670. )
  46671. );
  46672. }
  46673. $this->canceller = $canceller;
  46674. }
  46675. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46676. {
  46677. if (null !== $this->completed) {
  46678. return $this->completed->then($fulfilledHandler, $errorHandler, $progressHandler);
  46679. }
  46680. $canceller = null;
  46681. if ($this->canceller !== null) {
  46682. $this->requiredCancelRequests++;
  46683. $that = $this;
  46684. $current =& $this->cancelRequests;
  46685. $required =& $this->requiredCancelRequests;
  46686. $canceller = function () use ($that, &$current, &$required) {
  46687. if (++$current < $required) {
  46688. return;
  46689. }
  46690. $that->cancel();
  46691. };
  46692. }
  46693. $deferred = new static($canceller);
  46694. if (is_callable($progressHandler)) {
  46695. $progHandler = function ($update) use ($deferred, $progressHandler) {
  46696. try {
  46697. $deferred->progress(call_user_func($progressHandler, $update));
  46698. } catch (\Exception $e) {
  46699. $deferred->progress($e);
  46700. }
  46701. };
  46702. } else {
  46703. if (null !== $progressHandler) {
  46704. trigger_error('Invalid $progressHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46705. }
  46706. $progHandler = array($deferred, 'progress');
  46707. }
  46708. $this->handlers[] = function ($promise) use ($fulfilledHandler, $errorHandler, $deferred, $progHandler) {
  46709. $promise
  46710. ->then($fulfilledHandler, $errorHandler)
  46711. ->then(
  46712. array($deferred, 'resolve'),
  46713. array($deferred, 'reject'),
  46714. $progHandler
  46715. );
  46716. };
  46717. $this->progressHandlers[] = $progHandler;
  46718. return $deferred->promise();
  46719. }
  46720. public function resolve($result = null)
  46721. {
  46722. if (null !== $this->completed) {
  46723. return resolve($result);
  46724. }
  46725. $this->completed = resolve($result);
  46726. $this->processQueue($this->handlers, $this->completed);
  46727. $this->progressHandlers = $this->handlers = array();
  46728. return $this->completed;
  46729. }
  46730. public function reject($reason = null)
  46731. {
  46732. return $this->resolve(reject($reason));
  46733. }
  46734. public function progress($update = null)
  46735. {
  46736. if (null !== $this->completed) {
  46737. return;
  46738. }
  46739. $this->processQueue($this->progressHandlers, $update);
  46740. }
  46741. public function promise()
  46742. {
  46743. if (null === $this->promise) {
  46744. $this->promise = new DeferredPromise($this);
  46745. }
  46746. return $this->promise;
  46747. }
  46748. public function resolver()
  46749. {
  46750. if (null === $this->resolver) {
  46751. $this->resolver = new DeferredResolver($this);
  46752. }
  46753. return $this->resolver;
  46754. }
  46755. public function cancel()
  46756. {
  46757. if (null === $this->canceller || null !== $this->completed) {
  46758. return;
  46759. }
  46760. $canceller = $this->canceller;
  46761. $this->canceller = null;
  46762. try {
  46763. $that = $this;
  46764. call_user_func(
  46765. $canceller,
  46766. function ($value = null) use ($that) {
  46767. $that->resolve($value);
  46768. },
  46769. function ($reason = null) use ($that) {
  46770. $that->reject($reason);
  46771. },
  46772. function ($update = null) use ($that) {
  46773. $that->progress($update);
  46774. }
  46775. );
  46776. } catch (\Exception $e) {
  46777. $this->reject($e);
  46778. }
  46779. }
  46780. protected function processQueue($queue, $value)
  46781. {
  46782. foreach ($queue as $handler) {
  46783. call_user_func($handler, $value);
  46784. }
  46785. }
  46786. }
  46787. <?php
  46788. namespace React\Promise;
  46789. class DeferredPromise implements PromiseInterface, CancellablePromiseInterface
  46790. {
  46791. private $deferred;
  46792. public function __construct(Deferred $deferred)
  46793. {
  46794. $this->deferred = $deferred;
  46795. }
  46796. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46797. {
  46798. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46799. }
  46800. public function cancel()
  46801. {
  46802. $this->deferred->cancel();
  46803. }
  46804. }
  46805. <?php
  46806. namespace React\Promise;
  46807. class DeferredResolver implements ResolverInterface
  46808. {
  46809. private $deferred;
  46810. public function __construct(Deferred $deferred)
  46811. {
  46812. $this->deferred = $deferred;
  46813. }
  46814. public function resolve($result = null)
  46815. {
  46816. return $this->deferred->resolve($result);
  46817. }
  46818. public function reject($reason = null)
  46819. {
  46820. return $this->deferred->reject($reason);
  46821. }
  46822. public function progress($update = null)
  46823. {
  46824. return $this->deferred->progress($update);
  46825. }
  46826. }
  46827. <?php
  46828. namespace React\Promise;
  46829. class FulfilledPromise implements PromiseInterface, CancellablePromiseInterface
  46830. {
  46831. private $result;
  46832. public function __construct($result = null)
  46833. {
  46834. $this->result = $result;
  46835. }
  46836. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46837. {
  46838. try {
  46839. $result = $this->result;
  46840. if (is_callable($fulfilledHandler)) {
  46841. $result = call_user_func($fulfilledHandler, $result);
  46842. } elseif (null !== $fulfilledHandler) {
  46843. trigger_error('Invalid $fulfilledHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46844. }
  46845. return resolve($result);
  46846. } catch (\Exception $exception) {
  46847. return new RejectedPromise($exception);
  46848. }
  46849. }
  46850. public function cancel()
  46851. {
  46852. }
  46853. }
  46854. <?php
  46855. namespace React\Promise;
  46856. class LazyPromise implements PromiseInterface, CancellablePromiseInterface
  46857. {
  46858. private $factory;
  46859. private $promise;
  46860. public function __construct($factory)
  46861. {
  46862. $this->factory = $factory;
  46863. }
  46864. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46865. {
  46866. return $this->promise()->then($fulfilledHandler, $errorHandler, $progressHandler);
  46867. }
  46868. public function cancel()
  46869. {
  46870. $promise = $this->promise();
  46871. if ($promise instanceof CancellablePromiseInterface) {
  46872. $promise->cancel();
  46873. }
  46874. }
  46875. private function promise()
  46876. {
  46877. if (null === $this->promise) {
  46878. try {
  46879. $this->promise = resolve(call_user_func($this->factory));
  46880. } catch (\Exception $exception) {
  46881. $this->promise = new RejectedPromise($exception);
  46882. }
  46883. }
  46884. return $this->promise;
  46885. }
  46886. }
  46887. <?php
  46888. namespace React\Promise;
  46889. class Promise implements PromiseInterface, CancellablePromiseInterface
  46890. {
  46891. private $deferred;
  46892. public function __construct($resolver, $canceller = null)
  46893. {
  46894. if (!is_callable($resolver)) {
  46895. throw new \InvalidArgumentException(
  46896. sprintf(
  46897. 'The resolver argument must be of type callable, %s given.',
  46898. gettype($resolver)
  46899. )
  46900. );
  46901. }
  46902. $this->deferred = new Deferred($canceller);
  46903. $this->call($resolver);
  46904. }
  46905. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46906. {
  46907. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46908. }
  46909. public function cancel()
  46910. {
  46911. $this->deferred->cancel();
  46912. }
  46913. private function call($callback)
  46914. {
  46915. $deferred = $this->deferred;
  46916. try {
  46917. call_user_func(
  46918. $callback,
  46919. function ($result = null) use ($deferred) {
  46920. $deferred->resolve($result);
  46921. },
  46922. function ($reason = null) use ($deferred) {
  46923. $deferred->reject($reason);
  46924. },
  46925. function ($update = null) use ($deferred) {
  46926. $deferred->progress($update);
  46927. }
  46928. );
  46929. } catch (\Exception $e) {
  46930. $this->deferred->reject($e);
  46931. }
  46932. }
  46933. }
  46934. <?php
  46935. namespace React\Promise;
  46936. interface PromiseInterface
  46937. {
  46938. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
  46939. }
  46940. <?php
  46941. namespace React\Promise;
  46942. interface PromisorInterface
  46943. {
  46944. public function promise();
  46945. }
  46946. <?php
  46947. namespace React\Promise;
  46948. class RejectedPromise implements PromiseInterface, CancellablePromiseInterface
  46949. {
  46950. private $reason;
  46951. public function __construct($reason = null)
  46952. {
  46953. $this->reason = $reason;
  46954. }
  46955. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46956. {
  46957. try {
  46958. if (!is_callable($errorHandler)) {
  46959. if (null !== $errorHandler) {
  46960. trigger_error('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46961. }
  46962. return new RejectedPromise($this->reason);
  46963. }
  46964. return resolve(call_user_func($errorHandler, $this->reason));
  46965. } catch (\Exception $exception) {
  46966. return new RejectedPromise($exception);
  46967. }
  46968. }
  46969. public function cancel()
  46970. {
  46971. }
  46972. }
  46973. <?php
  46974. namespace React\Promise;
  46975. interface ResolverInterface
  46976. {
  46977. public function resolve($result = null);
  46978. public function reject($reason = null);
  46979. public function progress($update = null);
  46980. }
  46981. <?php
  46982. namespace React\Promise;
  46983. class Util
  46984. {
  46985. public static function promiseFor($promiseOrValue)
  46986. {
  46987. return resolve($promiseOrValue);
  46988. }
  46989. public static function rejectedPromiseFor($promiseOrValue)
  46990. {
  46991. return reject($promiseOrValue);
  46992. }
  46993. }
  46994. <?php
  46995. namespace React\Promise;
  46996. class When
  46997. {
  46998. public static function resolve($promiseOrValue = null)
  46999. {
  47000. return resolve($promiseOrValue);
  47001. }
  47002. public static function reject($promiseOrValue = null)
  47003. {
  47004. return reject($promiseOrValue);
  47005. }
  47006. public static function lazy($factory)
  47007. {
  47008. return new LazyPromise($factory);
  47009. }
  47010. public static function all($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  47011. {
  47012. return all($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  47013. }
  47014. public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  47015. {
  47016. return any($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  47017. }
  47018. public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  47019. {
  47020. return some($promisesOrValues, $howMany)->then($fulfilledHandler, $errorHandler, $progressHandler);
  47021. }
  47022. public static function map($promisesOrValues, $mapFunc)
  47023. {
  47024. return map($promisesOrValues, $mapFunc);
  47025. }
  47026. public static function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  47027. {
  47028. return reduce($promisesOrValues, $reduceFunc, $initialValue);
  47029. }
  47030. }
  47031. <?php
  47032. namespace React\Promise;
  47033. function resolve($promiseOrValue = null)
  47034. {
  47035. if ($promiseOrValue instanceof PromiseInterface) {
  47036. return $promiseOrValue;
  47037. }
  47038. return new FulfilledPromise($promiseOrValue);
  47039. }
  47040. function reject($promiseOrValue = null)
  47041. {
  47042. if ($promiseOrValue instanceof PromiseInterface) {
  47043. return $promiseOrValue->then(function ($value) {
  47044. return new RejectedPromise($value);
  47045. });
  47046. }
  47047. return new RejectedPromise($promiseOrValue);
  47048. }
  47049. function all($promisesOrValues)
  47050. {
  47051. return map($promisesOrValues, function ($val) {
  47052. return $val;
  47053. });
  47054. }
  47055. function any($promisesOrValues)
  47056. {
  47057. return some($promisesOrValues, 1)->then(function($val) {
  47058. return array_shift($val);
  47059. });
  47060. }
  47061. function some($promisesOrValues, $howMany)
  47062. {
  47063. return resolve($promisesOrValues)->then(function ($array) use ($howMany) {
  47064. if (!is_array($array)) {
  47065. $array = array();
  47066. }
  47067. $len = count($array);
  47068. $toResolve = max(0, min($howMany, $len));
  47069. $values = array();
  47070. $deferred = new Deferred();
  47071. if (!$toResolve) {
  47072. $deferred->resolve($values);
  47073. } else {
  47074. $toReject = ($len - $toResolve) + 1;
  47075. $reasons = array();
  47076. $progress = array($deferred, 'progress');
  47077. $fulfillOne = function ($val, $i) use (&$values, &$toResolve, $deferred) {
  47078. $values[$i] = $val;
  47079. if (0 === --$toResolve) {
  47080. $deferred->resolve($values);
  47081. return true;
  47082. }
  47083. };
  47084. $rejectOne = function ($reason, $i) use (&$reasons, &$toReject, $deferred) {
  47085. $reasons[$i] = $reason;
  47086. if (0 === --$toReject) {
  47087. $deferred->reject($reasons);
  47088. return true;
  47089. }
  47090. };
  47091. foreach ($array as $i => $promiseOrValue) {
  47092. $fulfiller = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  47093. $reset = $fulfillOne($val, $i);
  47094. if (true === $reset) {
  47095. $fulfillOne = $rejectOne = function () {};
  47096. }
  47097. };
  47098. $rejecter = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  47099. $reset = $rejectOne($val, $i);
  47100. if (true === $reset) {
  47101. $fulfillOne = $rejectOne = function () {};
  47102. }
  47103. };
  47104. resolve($promiseOrValue)->then($fulfiller, $rejecter, $progress);
  47105. }
  47106. }
  47107. return $deferred->promise();
  47108. });
  47109. }
  47110. function map($promisesOrValues, $mapFunc)
  47111. {
  47112. return resolve($promisesOrValues)->then(function ($array) use ($mapFunc) {
  47113. if (!is_array($array)) {
  47114. $array = array();
  47115. }
  47116. $toResolve = count($array);
  47117. $results = array();
  47118. $deferred = new Deferred();
  47119. if (!$toResolve) {
  47120. $deferred->resolve($results);
  47121. } else {
  47122. $resolve = function ($item, $i) use ($mapFunc, &$results, &$toResolve, $deferred) {
  47123. resolve($item)
  47124. ->then($mapFunc)
  47125. ->then(
  47126. function ($mapped) use (&$results, $i, &$toResolve, $deferred) {
  47127. $results[$i] = $mapped;
  47128. if (0 === --$toResolve) {
  47129. $deferred->resolve($results);
  47130. }
  47131. },
  47132. array($deferred, 'reject')
  47133. );
  47134. };
  47135. foreach ($array as $i => $item) {
  47136. $resolve($item, $i);
  47137. }
  47138. }
  47139. return $deferred->promise();
  47140. });
  47141. }
  47142. function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  47143. {
  47144. return resolve($promisesOrValues)->then(function ($array) use ($reduceFunc, $initialValue) {
  47145. if (!is_array($array)) {
  47146. $array = array();
  47147. }
  47148. $total = count($array);
  47149. $i = 0;
  47150. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $total, &$i) {
  47151. return resolve($current)->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  47152. return resolve($val)->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  47153. return call_user_func($reduceFunc, $c, $value, $i++, $total);
  47154. });
  47155. });
  47156. };
  47157. return array_reduce($array, $wrappedReduceFunc, $initialValue);
  47158. });
  47159. }
  47160. <?php
  47161. if (!function_exists('React\Promise\resolve')) {
  47162. require __DIR__.'/functions.php';
  47163. }
  47164. Copyright (c) 2011 Jordi Boggiano
  47165. Permission is hereby granted, free of charge, to any person obtaining a copy
  47166. of this software and associated documentation files (the "Software"), to deal
  47167. in the Software without restriction, including without limitation the rights
  47168. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47169. copies of the Software, and to permit persons to whom the Software is furnished
  47170. to do so, subject to the following conditions:
  47171. The above copyright notice and this permission notice shall be included in all
  47172. copies or substantial portions of the Software.
  47173. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47174. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47175. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47176. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47177. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47178. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47179. THE SOFTWARE.
  47180. <?php
  47181. namespace Seld\JsonLint;
  47182. class DuplicateKeyException extends ParsingException
  47183. {
  47184. public function __construct($message, $key, array $details = array())
  47185. {
  47186. $details['key'] = $key;
  47187. parent::__construct($message, $details);
  47188. }
  47189. public function getKey()
  47190. {
  47191. return $this->details['key'];
  47192. }
  47193. public function getDetails()
  47194. {
  47195. return $this->details;
  47196. }
  47197. }
  47198. <?php
  47199. namespace Seld\JsonLint;
  47200. use stdClass;
  47201. class JsonParser
  47202. {
  47203. const DETECT_KEY_CONFLICTS = 1;
  47204. const ALLOW_DUPLICATE_KEYS = 2;
  47205. const PARSE_TO_ASSOC = 4;
  47206. private $lexer;
  47207. private $flags;
  47208. private $stack;
  47209. private $vstack;
  47210. private $lstack;
  47211. private $symbols = array(
  47212. 'error' => 2,
  47213. 'JSONString' => 3,
  47214. 'STRING' => 4,
  47215. 'JSONNumber' => 5,
  47216. 'NUMBER' => 6,
  47217. 'JSONNullLiteral' => 7,
  47218. 'NULL' => 8,
  47219. 'JSONBooleanLiteral' => 9,
  47220. 'TRUE' => 10,
  47221. 'FALSE' => 11,
  47222. 'JSONText' => 12,
  47223. 'JSONValue' => 13,
  47224. 'EOF' => 14,
  47225. 'JSONObject' => 15,
  47226. 'JSONArray' => 16,
  47227. '{' => 17,
  47228. '}' => 18,
  47229. 'JSONMemberList' => 19,
  47230. 'JSONMember' => 20,
  47231. ':' => 21,
  47232. ',' => 22,
  47233. '[' => 23,
  47234. ']' => 24,
  47235. 'JSONElementList' => 25,
  47236. '$accept' => 0,
  47237. '$end' => 1,
  47238. );
  47239. private $terminals_ = array(
  47240. 2 => "error",
  47241. 4 => "STRING",
  47242. 6 => "NUMBER",
  47243. 8 => "NULL",
  47244. 10 => "TRUE",
  47245. 11 => "FALSE",
  47246. 14 => "EOF",
  47247. 17 => "{",
  47248. 18 => "}",
  47249. 21 => ":",
  47250. 22 => ",",
  47251. 23 => "[",
  47252. 24 => "]",
  47253. );
  47254. private $productions_ = array(
  47255. 0,
  47256. array(3, 1),
  47257. array(5, 1),
  47258. array(7, 1),
  47259. array(9, 1),
  47260. array(9, 1),
  47261. array(12, 2),
  47262. array(13, 1),
  47263. array(13, 1),
  47264. array(13, 1),
  47265. array(13, 1),
  47266. array(13, 1),
  47267. array(13, 1),
  47268. array(15, 2),
  47269. array(15, 3),
  47270. array(20, 3),
  47271. array(19, 1),
  47272. array(19, 3),
  47273. array(16, 2),
  47274. array(16, 3),
  47275. array(25, 1),
  47276. array(25, 3)
  47277. );
  47278. 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)),
  47279. );
  47280. private $defaultActions = array(
  47281. 16 => array(2, 6)
  47282. );
  47283. public function lint($input, $flags = 0)
  47284. {
  47285. try {
  47286. $this->parse($input, $flags);
  47287. } catch (ParsingException $e) {
  47288. return $e;
  47289. }
  47290. return null;
  47291. }
  47292. public function parse($input, $flags = 0)
  47293. {
  47294. $this->failOnBOM($input);
  47295. $this->flags = $flags;
  47296. $this->stack = array(0);
  47297. $this->vstack = array(null);
  47298. $this->lstack = array();
  47299. $yytext = '';
  47300. $yylineno = 0;
  47301. $yyleng = 0;
  47302. $recovering = 0;
  47303. $TERROR = 2;
  47304. $EOF = 1;
  47305. $this->lexer = new Lexer();
  47306. $this->lexer->setInput($input);
  47307. $yyloc = $this->lexer->yylloc;
  47308. $this->lstack[] = $yyloc;
  47309. $symbol = null;
  47310. $preErrorSymbol = null;
  47311. $state = null;
  47312. $action = null;
  47313. $a = null;
  47314. $r = null;
  47315. $yyval = new stdClass;
  47316. $p = null;
  47317. $len = null;
  47318. $newState = null;
  47319. $expected = null;
  47320. $errStr = null;
  47321. while (true) {
  47322. $state = $this->stack[\count($this->stack)-1];
  47323. if (isset($this->defaultActions[$state])) {
  47324. $action = $this->defaultActions[$state];
  47325. } else {
  47326. if ($symbol == null) {
  47327. $symbol = $this->lex();
  47328. }
  47329. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  47330. }
  47331. if (!$action || !$action[0]) {
  47332. if (!$recovering) {
  47333. $expected = array();
  47334. foreach ($this->table[$state] as $p => $ignore) {
  47335. if (isset($this->terminals_[$p]) && $p > 2) {
  47336. $expected[] = "'" . $this->terminals_[$p] . "'";
  47337. }
  47338. }
  47339. $message = null;
  47340. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  47341. $message = "Invalid string";
  47342. if ("'" === substr($this->lexer->match, 0, 1)) {
  47343. $message .= ", it appears you used single quotes instead of double quotes";
  47344. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  47345. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  47346. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  47347. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  47348. }
  47349. }
  47350. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47351. $errStr .= $this->lexer->showPosition() . "\n";
  47352. if ($message) {
  47353. $errStr .= $message;
  47354. } else {
  47355. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  47356. $errStr .= implode(', ', $expected);
  47357. }
  47358. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  47359. $errStr .= " - It appears you have an extra trailing comma";
  47360. }
  47361. $this->parseError($errStr, array(
  47362. 'text' => $this->lexer->match,
  47363. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  47364. 'line' => $this->lexer->yylineno,
  47365. 'loc' => $yyloc,
  47366. 'expected' => $expected,
  47367. ));
  47368. }
  47369. if ($recovering == 3) {
  47370. if ($symbol == $EOF) {
  47371. throw new ParsingException($errStr ?: 'Parsing halted.');
  47372. }
  47373. $yyleng = $this->lexer->yyleng;
  47374. $yytext = $this->lexer->yytext;
  47375. $yylineno = $this->lexer->yylineno;
  47376. $yyloc = $this->lexer->yylloc;
  47377. $symbol = $this->lex();
  47378. }
  47379. while (true) {
  47380. if (\array_key_exists($TERROR, $this->table[$state])) {
  47381. break;
  47382. }
  47383. if ($state == 0) {
  47384. throw new ParsingException($errStr ?: 'Parsing halted.');
  47385. }
  47386. $this->popStack(1);
  47387. $state = $this->stack[\count($this->stack)-1];
  47388. }
  47389. $preErrorSymbol = $symbol;
  47390. $symbol = $TERROR;
  47391. $state = $this->stack[\count($this->stack)-1];
  47392. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  47393. $recovering = 3;
  47394. }
  47395. if (\is_array($action[0]) && \count($action) > 1) {
  47396. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  47397. }
  47398. switch ($action[0]) {
  47399. case 1:
  47400. $this->stack[] = $symbol;
  47401. $this->vstack[] = $this->lexer->yytext;
  47402. $this->lstack[] = $this->lexer->yylloc;
  47403. $this->stack[] = $action[1];
  47404. $symbol = null;
  47405. if (!$preErrorSymbol) {
  47406. $yyleng = $this->lexer->yyleng;
  47407. $yytext = $this->lexer->yytext;
  47408. $yylineno = $this->lexer->yylineno;
  47409. $yyloc = $this->lexer->yylloc;
  47410. if ($recovering > 0) {
  47411. $recovering--;
  47412. }
  47413. } else {
  47414. $symbol = $preErrorSymbol;
  47415. $preErrorSymbol = null;
  47416. }
  47417. break;
  47418. case 2:
  47419. $len = $this->productions_[$action[1]][1];
  47420. $yyval->token = $this->vstack[\count($this->vstack) - $len];
  47421. $yyval->store = array(
  47422. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  47423. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  47424. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  47425. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  47426. );
  47427. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
  47428. if (!$r instanceof Undefined) {
  47429. return $r;
  47430. }
  47431. if ($len) {
  47432. $this->popStack($len);
  47433. }
  47434. $this->stack[] = $this->productions_[$action[1]][0];
  47435. $this->vstack[] = $yyval->token;
  47436. $this->lstack[] = $yyval->store;
  47437. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  47438. $this->stack[] = $newState;
  47439. break;
  47440. case 3:
  47441. return true;
  47442. }
  47443. }
  47444. }
  47445. protected function parseError($str, $hash)
  47446. {
  47447. throw new ParsingException($str, $hash);
  47448. }
  47449. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  47450. {
  47451. $len = \count($tokens) - 1;
  47452. switch ($yystate) {
  47453. case 1:
  47454. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  47455. $yyval->token = $yytext;
  47456. break;
  47457. case 2:
  47458. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  47459. $yyval->token = \floatval($yytext);
  47460. } else {
  47461. $yyval->token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  47462. }
  47463. break;
  47464. case 3:
  47465. $yyval->token = null;
  47466. break;
  47467. case 4:
  47468. $yyval->token = true;
  47469. break;
  47470. case 5:
  47471. $yyval->token = false;
  47472. break;
  47473. case 6:
  47474. return $yyval->token = $tokens[$len-1];
  47475. case 13:
  47476. if ($this->flags & self::PARSE_TO_ASSOC) {
  47477. $yyval->token = array();
  47478. } else {
  47479. $yyval->token = new stdClass;
  47480. }
  47481. break;
  47482. case 14:
  47483. $yyval->token = $tokens[$len-1];
  47484. break;
  47485. case 15:
  47486. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  47487. break;
  47488. case 16:
  47489. if (PHP_VERSION_ID < 70100) {
  47490. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  47491. } else {
  47492. $property = $tokens[$len][0];
  47493. }
  47494. if ($this->flags & self::PARSE_TO_ASSOC) {
  47495. $yyval->token = array();
  47496. $yyval->token[$property] = $tokens[$len][1];
  47497. } else {
  47498. $yyval->token = new stdClass;
  47499. $yyval->token->$property = $tokens[$len][1];
  47500. }
  47501. break;
  47502. case 17:
  47503. if ($this->flags & self::PARSE_TO_ASSOC) {
  47504. $yyval->token =& $tokens[$len-2];
  47505. $key = $tokens[$len][0];
  47506. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  47507. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47508. $errStr .= $this->lexer->showPosition() . "\n";
  47509. $errStr .= "Duplicate key: ".$tokens[$len][0];
  47510. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  47511. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  47512. $duplicateCount = 1;
  47513. do {
  47514. $duplicateKey = $key . '.' . $duplicateCount++;
  47515. } while (isset($tokens[$len-2][$duplicateKey]));
  47516. $key = $duplicateKey;
  47517. }
  47518. $tokens[$len-2][$key] = $tokens[$len][1];
  47519. } else {
  47520. $yyval->token = $tokens[$len-2];
  47521. if (PHP_VERSION_ID < 70100) {
  47522. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  47523. } else {
  47524. $key = $tokens[$len][0];
  47525. }
  47526. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  47527. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47528. $errStr .= $this->lexer->showPosition() . "\n";
  47529. $errStr .= "Duplicate key: ".$tokens[$len][0];
  47530. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  47531. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  47532. $duplicateCount = 1;
  47533. do {
  47534. $duplicateKey = $key . '.' . $duplicateCount++;
  47535. } while (isset($tokens[$len-2]->$duplicateKey));
  47536. $key = $duplicateKey;
  47537. }
  47538. $tokens[$len-2]->$key = $tokens[$len][1];
  47539. }
  47540. break;
  47541. case 18:
  47542. $yyval->token = array();
  47543. break;
  47544. case 19:
  47545. $yyval->token = $tokens[$len-1];
  47546. break;
  47547. case 20:
  47548. $yyval->token = array($tokens[$len]);
  47549. break;
  47550. case 21:
  47551. $tokens[$len-2][] = $tokens[$len];
  47552. $yyval->token = $tokens[$len-2];
  47553. break;
  47554. }
  47555. return new Undefined();
  47556. }
  47557. private function stringInterpolation($match)
  47558. {
  47559. switch ($match[0]) {
  47560. case '\\\\':
  47561. return '\\';
  47562. case '\"':
  47563. return '"';
  47564. case '\b':
  47565. return \chr(8);
  47566. case '\f':
  47567. return \chr(12);
  47568. case '\n':
  47569. return "\n";
  47570. case '\r':
  47571. return "\r";
  47572. case '\t':
  47573. return "\t";
  47574. case '\/':
  47575. return "/";
  47576. default:
  47577. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  47578. }
  47579. }
  47580. private function popStack($n)
  47581. {
  47582. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  47583. $this->vstack = \array_slice($this->vstack, 0, - $n);
  47584. $this->lstack = \array_slice($this->lstack, 0, - $n);
  47585. }
  47586. private function lex()
  47587. {
  47588. $token = $this->lexer->lex() ?: 1;
  47589. if (!is_numeric($token)) {
  47590. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  47591. }
  47592. return $token;
  47593. }
  47594. private function failOnBOM($input)
  47595. {
  47596. $bom = "\xEF\xBB\xBF";
  47597. if (substr($input, 0, 3) === $bom) {
  47598. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  47599. }
  47600. }
  47601. }
  47602. <?php
  47603. namespace Seld\JsonLint;
  47604. class Lexer
  47605. {
  47606. private $EOF = 1;
  47607. private $rules = array(
  47608. 0 => '/\G\s+/',
  47609. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  47610. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  47611. 3 => '/\G\{/',
  47612. 4 => '/\G\}/',
  47613. 5 => '/\G\[/',
  47614. 6 => '/\G\]/',
  47615. 7 => '/\G,/',
  47616. 8 => '/\G:/',
  47617. 9 => '/\Gtrue\b/',
  47618. 10 => '/\Gfalse\b/',
  47619. 11 => '/\Gnull\b/',
  47620. 12 => '/\G$/',
  47621. 13 => '/\G./',
  47622. );
  47623. private $conditions = array(
  47624. "INITIAL" => array(
  47625. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  47626. "inclusive" => true,
  47627. ),
  47628. );
  47629. private $conditionStack;
  47630. private $input;
  47631. private $more;
  47632. private $done;
  47633. private $offset;
  47634. public $match;
  47635. public $yylineno;
  47636. public $yyleng;
  47637. public $yytext;
  47638. public $yylloc;
  47639. public function lex()
  47640. {
  47641. $r = $this->next();
  47642. if (!$r instanceof Undefined) {
  47643. return $r;
  47644. }
  47645. return $this->lex();
  47646. }
  47647. public function setInput($input)
  47648. {
  47649. $this->input = $input;
  47650. $this->more = false;
  47651. $this->done = false;
  47652. $this->offset = 0;
  47653. $this->yylineno = $this->yyleng = 0;
  47654. $this->yytext = $this->match = '';
  47655. $this->conditionStack = array('INITIAL');
  47656. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  47657. return $this;
  47658. }
  47659. public function showPosition()
  47660. {
  47661. $pre = str_replace("\n", '', $this->getPastInput());
  47662. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  47663. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  47664. }
  47665. public function getPastInput()
  47666. {
  47667. $pastLength = $this->offset - \strlen($this->match);
  47668. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  47669. }
  47670. public function getUpcomingInput()
  47671. {
  47672. $next = $this->match;
  47673. if (\strlen($next) < 20) {
  47674. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47675. }
  47676. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  47677. }
  47678. public function getFullUpcomingInput()
  47679. {
  47680. $next = $this->match;
  47681. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  47682. $len = \strlen($this->input);
  47683. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  47684. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  47685. } elseif (\strlen($next) < 20) {
  47686. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47687. }
  47688. return $next;
  47689. }
  47690. protected function parseError($str, $hash)
  47691. {
  47692. throw new \Exception($str);
  47693. }
  47694. private function next()
  47695. {
  47696. if ($this->done) {
  47697. return $this->EOF;
  47698. }
  47699. if ($this->offset === \strlen($this->input)) {
  47700. $this->done = true;
  47701. }
  47702. $token = null;
  47703. $match = null;
  47704. $col = null;
  47705. $lines = null;
  47706. if (!$this->more) {
  47707. $this->yytext = '';
  47708. $this->match = '';
  47709. }
  47710. $rules = $this->getCurrentRules();
  47711. $rulesLen = \count($rules);
  47712. for ($i=0; $i < $rulesLen; $i++) {
  47713. if (preg_match($this->rules[$rules[$i]], $this->input, $match, 0, $this->offset)) {
  47714. preg_match_all('/\n.*/', $match[0], $lines);
  47715. $lines = $lines[0];
  47716. if ($lines) {
  47717. $this->yylineno += \count($lines);
  47718. }
  47719. $this->yylloc = array(
  47720. 'first_line' => $this->yylloc['last_line'],
  47721. 'last_line' => $this->yylineno+1,
  47722. 'first_column' => $this->yylloc['last_column'],
  47723. 'last_column' => $lines ? \strlen($lines[\count($lines) - 1]) - 1 : $this->yylloc['last_column'] + \strlen($match[0]),
  47724. );
  47725. $this->yytext .= $match[0];
  47726. $this->match .= $match[0];
  47727. $this->yyleng = \strlen($this->yytext);
  47728. $this->more = false;
  47729. $this->offset += \strlen($match[0]);
  47730. $token = $this->performAction($rules[$i], $this->conditionStack[\count($this->conditionStack)-1]);
  47731. if ($token) {
  47732. return $token;
  47733. }
  47734. return new Undefined();
  47735. }
  47736. }
  47737. if ($this->offset === \strlen($this->input)) {
  47738. return $this->EOF;
  47739. }
  47740. $this->parseError(
  47741. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  47742. array(
  47743. 'text' => "",
  47744. 'token' => null,
  47745. 'line' => $this->yylineno,
  47746. )
  47747. );
  47748. }
  47749. private function getCurrentRules()
  47750. {
  47751. return $this->conditions[$this->conditionStack[\count($this->conditionStack)-1]]['rules'];
  47752. }
  47753. private function performAction($avoiding_name_collisions, $YY_START)
  47754. {
  47755. switch ($avoiding_name_collisions) {
  47756. case 0:
  47757. break;
  47758. case 1:
  47759. return 6;
  47760. case 2:
  47761. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  47762. return 4;
  47763. case 3:
  47764. return 17;
  47765. case 4:
  47766. return 18;
  47767. case 5:
  47768. return 23;
  47769. case 6:
  47770. return 24;
  47771. case 7:
  47772. return 22;
  47773. case 8:
  47774. return 21;
  47775. case 9:
  47776. return 10;
  47777. case 10:
  47778. return 11;
  47779. case 11:
  47780. return 8;
  47781. case 12:
  47782. return 14;
  47783. case 13:
  47784. return 'INVALID';
  47785. }
  47786. }
  47787. }
  47788. <?php
  47789. namespace Seld\JsonLint;
  47790. class ParsingException extends \Exception
  47791. {
  47792. protected $details;
  47793. public function __construct($message, $details = array())
  47794. {
  47795. $this->details = $details;
  47796. parent::__construct($message);
  47797. }
  47798. public function getDetails()
  47799. {
  47800. return $this->details;
  47801. }
  47802. }
  47803. <?php
  47804. namespace Seld\JsonLint;
  47805. class Undefined
  47806. {
  47807. }
  47808. Copyright (c) 2015 Jordi Boggiano
  47809. Permission is hereby granted, free of charge, to any person obtaining a copy
  47810. of this software and associated documentation files (the "Software"), to deal
  47811. in the Software without restriction, including without limitation the rights
  47812. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47813. copies of the Software, and to permit persons to whom the Software is furnished
  47814. to do so, subject to the following conditions:
  47815. The above copyright notice and this permission notice shall be included in all
  47816. copies or substantial portions of the Software.
  47817. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47818. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47819. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47820. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47821. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47822. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47823. THE SOFTWARE.
  47824. <?php
  47825. namespace Seld\PharUtils;
  47826. class Linter
  47827. {
  47828. public static function lint($path)
  47829. {
  47830. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  47831. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  47832. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  47833. if (!$tmpFile || !is_writable($tmpFile)) {
  47834. throw new \RuntimeException('Unable to create temp file');
  47835. }
  47836. $php = self::escapeWindowsPath($php);
  47837. $tmpFile = self::escapeWindowsPath($tmpFile);
  47838. if (PHP_VERSION_ID >= 80000) {
  47839. $format = '%s -l %s';
  47840. } else {
  47841. $format = '"%s -l %s"';
  47842. }
  47843. $command = sprintf($format, $php, $tmpFile);
  47844. } else {
  47845. $command = "'".$php."' -l";
  47846. }
  47847. $descriptorspec = array(
  47848. 0 => array('pipe', 'r'),
  47849. 1 => array('pipe', 'w'),
  47850. 2 => array('pipe', 'w')
  47851. );
  47852. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  47853. if ($file->isDir()) {
  47854. continue;
  47855. }
  47856. if (substr($file, -4) === '.php') {
  47857. $filename = (string) $file;
  47858. if ($isWindows) {
  47859. file_put_contents($tmpFile, file_get_contents($filename));
  47860. }
  47861. $process = proc_open($command, $descriptorspec, $pipes);
  47862. if (is_resource($process)) {
  47863. if (!$isWindows) {
  47864. fwrite($pipes[0], file_get_contents($filename));
  47865. }
  47866. fclose($pipes[0]);
  47867. $stdout = stream_get_contents($pipes[1]);
  47868. fclose($pipes[1]);
  47869. $stderr = stream_get_contents($pipes[2]);
  47870. fclose($pipes[2]);
  47871. $exitCode = proc_close($process);
  47872. if ($exitCode !== 0) {
  47873. if ($isWindows) {
  47874. $stderr = str_replace($tmpFile, $filename, $stderr);
  47875. }
  47876. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  47877. }
  47878. } else {
  47879. throw new \RuntimeException('Could not start linter process');
  47880. }
  47881. }
  47882. }
  47883. if ($isWindows) {
  47884. @unlink($tmpFile);
  47885. }
  47886. }
  47887. private static function escapeWindowsPath($path)
  47888. {
  47889. if (strpbrk($path, " ()") !== false) {
  47890. $path = '"'.$path.'"';
  47891. }
  47892. return $path;
  47893. }
  47894. }
  47895. <?php
  47896. namespace Seld\PharUtils;
  47897. class Timestamps
  47898. {
  47899. private $contents;
  47900. public function __construct($file)
  47901. {
  47902. $this->contents = file_get_contents($file);
  47903. }
  47904. public function updateTimestamps($timestamp = null)
  47905. {
  47906. if ($timestamp instanceof \DateTime) {
  47907. $timestamp = $timestamp->getTimestamp();
  47908. } elseif (is_string($timestamp)) {
  47909. $timestamp = strtotime($timestamp);
  47910. } elseif (!is_int($timestamp)) {
  47911. $timestamp = strtotime('1984-12-24T00:00:00Z');
  47912. }
  47913. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47914. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47915. }
  47916. $pos = $match[0][1] + strlen($match[0][0]);
  47917. $stubEnd = $pos + $this->readUint($pos, 4);
  47918. $pos += 4;
  47919. $numFiles = $this->readUint($pos, 4);
  47920. $pos += 4;
  47921. $pos += 2;
  47922. $pos += 4;
  47923. $aliasLength = $this->readUint($pos, 4);
  47924. $pos += 4 + $aliasLength;
  47925. $metadataLength = $this->readUint($pos, 4);
  47926. $pos += 4 + $metadataLength;
  47927. while ($pos < $stubEnd) {
  47928. $filenameLength = $this->readUint($pos, 4);
  47929. $pos += 4 + $filenameLength;
  47930. $pos += 4;
  47931. $this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
  47932. $pos += 4*4;
  47933. $metadataLength = $this->readUint($pos, 4);
  47934. $pos += 4 + $metadataLength;
  47935. $numFiles--;
  47936. }
  47937. if ($numFiles !== 0) {
  47938. throw new \LogicException('All files were not processed, something must have gone wrong');
  47939. }
  47940. }
  47941. public function save($path, $signatureAlgo)
  47942. {
  47943. $pos = $this->determineSignatureBegin();
  47944. $algos = array(
  47945. \Phar::MD5 => 'md5',
  47946. \Phar::SHA1 => 'sha1',
  47947. \Phar::SHA256 => 'sha256',
  47948. \Phar::SHA512 => 'sha512',
  47949. );
  47950. if (!isset($algos[$signatureAlgo])) {
  47951. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  47952. }
  47953. $algo = $algos[$signatureAlgo];
  47954. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  47955. . pack('L', $signatureAlgo)
  47956. . 'GBMB';
  47957. $this->contents = substr($this->contents, 0, $pos) . $signature;
  47958. return file_put_contents($path, $this->contents);
  47959. }
  47960. private function readUint($pos, $bytes)
  47961. {
  47962. $res = unpack('V', substr($this->contents, $pos, $bytes));
  47963. return $res[1];
  47964. }
  47965. private function determineSignatureBegin()
  47966. {
  47967. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47968. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47969. }
  47970. $pos = $match[0][1] + strlen($match[0][0]);
  47971. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  47972. $pos += 4;
  47973. $numFiles = $this->readUint($pos, 4);
  47974. $pos += 4;
  47975. $pos += 2;
  47976. $pos += 4;
  47977. $aliasLength = $this->readUint($pos, 4);
  47978. $pos += 4 + $aliasLength;
  47979. $metadataLength = $this->readUint($pos, 4);
  47980. $pos += 4 + $metadataLength;
  47981. $compressedSizes = 0;
  47982. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  47983. $filenameLength = $this->readUint($pos, 4);
  47984. $pos += 4 + $filenameLength;
  47985. $pos += 2*4;
  47986. $compressedSizes += $this->readUint($pos, 4);
  47987. $pos += 3*4;
  47988. $metadataLength = $this->readUint($pos, 4);
  47989. $pos += 4 + $metadataLength;
  47990. $numFiles--;
  47991. }
  47992. if ($numFiles !== 0) {
  47993. throw new \LogicException('All files were not processed, something must have gone wrong');
  47994. }
  47995. return $manifestEnd + $compressedSizes;
  47996. }
  47997. }
  47998. <?php
  47999. namespace Symfony\Component\Console;
  48000. use Symfony\Component\Console\Command\Command;
  48001. use Symfony\Component\Console\Command\HelpCommand;
  48002. use Symfony\Component\Console\Command\ListCommand;
  48003. use Symfony\Component\Console\Descriptor\TextDescriptor;
  48004. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  48005. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  48006. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  48007. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  48008. use Symfony\Component\Console\Exception\CommandNotFoundException;
  48009. use Symfony\Component\Console\Exception\ExceptionInterface;
  48010. use Symfony\Component\Console\Exception\LogicException;
  48011. use Symfony\Component\Console\Formatter\OutputFormatter;
  48012. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  48013. use Symfony\Component\Console\Helper\DialogHelper;
  48014. use Symfony\Component\Console\Helper\FormatterHelper;
  48015. use Symfony\Component\Console\Helper\Helper;
  48016. use Symfony\Component\Console\Helper\HelperSet;
  48017. use Symfony\Component\Console\Helper\ProcessHelper;
  48018. use Symfony\Component\Console\Helper\ProgressHelper;
  48019. use Symfony\Component\Console\Helper\QuestionHelper;
  48020. use Symfony\Component\Console\Helper\TableHelper;
  48021. use Symfony\Component\Console\Input\ArgvInput;
  48022. use Symfony\Component\Console\Input\ArrayInput;
  48023. use Symfony\Component\Console\Input\InputArgument;
  48024. use Symfony\Component\Console\Input\InputAwareInterface;
  48025. use Symfony\Component\Console\Input\InputDefinition;
  48026. use Symfony\Component\Console\Input\InputInterface;
  48027. use Symfony\Component\Console\Input\InputOption;
  48028. use Symfony\Component\Console\Output\BufferedOutput;
  48029. use Symfony\Component\Console\Output\ConsoleOutput;
  48030. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  48031. use Symfony\Component\Console\Output\OutputInterface;
  48032. use Symfony\Component\Debug\Exception\FatalThrowableError;
  48033. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  48034. class Application
  48035. {
  48036. private $commands = array();
  48037. private $wantHelps = false;
  48038. private $runningCommand;
  48039. private $name;
  48040. private $version;
  48041. private $catchExceptions = true;
  48042. private $autoExit = true;
  48043. private $definition;
  48044. private $helperSet;
  48045. private $dispatcher;
  48046. private $terminalDimensions;
  48047. private $defaultCommand;
  48048. private $initialized;
  48049. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  48050. {
  48051. $this->name = $name;
  48052. $this->version = $version;
  48053. $this->defaultCommand = 'list';
  48054. }
  48055. public function setDispatcher(EventDispatcherInterface $dispatcher)
  48056. {
  48057. $this->dispatcher = $dispatcher;
  48058. }
  48059. public function run(InputInterface $input = null, OutputInterface $output = null)
  48060. {
  48061. if (null === $input) {
  48062. $input = new ArgvInput();
  48063. }
  48064. if (null === $output) {
  48065. $output = new ConsoleOutput();
  48066. }
  48067. $this->configureIO($input, $output);
  48068. try {
  48069. $e = null;
  48070. $exitCode = $this->doRun($input, $output);
  48071. } catch (\Exception $e) {
  48072. }
  48073. if (null !== $e) {
  48074. if (!$this->catchExceptions) {
  48075. throw $e;
  48076. }
  48077. if ($output instanceof ConsoleOutputInterface) {
  48078. $this->renderException($e, $output->getErrorOutput());
  48079. } else {
  48080. $this->renderException($e, $output);
  48081. }
  48082. $exitCode = $this->getExitCodeForThrowable($e);
  48083. }
  48084. if ($this->autoExit) {
  48085. if ($exitCode > 255) {
  48086. $exitCode = 255;
  48087. }
  48088. exit($exitCode);
  48089. }
  48090. return $exitCode;
  48091. }
  48092. public function doRun(InputInterface $input, OutputInterface $output)
  48093. {
  48094. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  48095. $output->writeln($this->getLongVersion());
  48096. return 0;
  48097. }
  48098. $name = $this->getCommandName($input);
  48099. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  48100. if (!$name) {
  48101. $name = 'help';
  48102. $input = new ArrayInput(array('command' => 'help'));
  48103. } else {
  48104. $this->wantHelps = true;
  48105. }
  48106. }
  48107. if (!$name) {
  48108. $name = $this->defaultCommand;
  48109. $definition = $this->getDefinition();
  48110. $definition->setArguments(array_merge(
  48111. $definition->getArguments(),
  48112. array(
  48113. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  48114. )
  48115. ));
  48116. }
  48117. $this->runningCommand = null;
  48118. $command = $this->find($name);
  48119. $this->runningCommand = $command;
  48120. $exitCode = $this->doRunCommand($command, $input, $output);
  48121. $this->runningCommand = null;
  48122. return $exitCode;
  48123. }
  48124. public function setHelperSet(HelperSet $helperSet)
  48125. {
  48126. $this->helperSet = $helperSet;
  48127. }
  48128. public function getHelperSet()
  48129. {
  48130. if (!$this->helperSet) {
  48131. $this->helperSet = $this->getDefaultHelperSet();
  48132. }
  48133. return $this->helperSet;
  48134. }
  48135. public function setDefinition(InputDefinition $definition)
  48136. {
  48137. $this->definition = $definition;
  48138. }
  48139. public function getDefinition()
  48140. {
  48141. if (!$this->definition) {
  48142. $this->definition = $this->getDefaultInputDefinition();
  48143. }
  48144. return $this->definition;
  48145. }
  48146. public function getHelp()
  48147. {
  48148. return $this->getLongVersion();
  48149. }
  48150. public function setCatchExceptions($boolean)
  48151. {
  48152. $this->catchExceptions = (bool) $boolean;
  48153. }
  48154. public function setAutoExit($boolean)
  48155. {
  48156. $this->autoExit = (bool) $boolean;
  48157. }
  48158. public function getName()
  48159. {
  48160. return $this->name;
  48161. }
  48162. public function setName($name)
  48163. {
  48164. $this->name = $name;
  48165. }
  48166. public function getVersion()
  48167. {
  48168. return $this->version;
  48169. }
  48170. public function setVersion($version)
  48171. {
  48172. $this->version = $version;
  48173. }
  48174. public function getLongVersion()
  48175. {
  48176. if ('UNKNOWN' !== $this->getName()) {
  48177. if ('UNKNOWN' !== $this->getVersion()) {
  48178. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  48179. }
  48180. return sprintf('<info>%s</info>', $this->getName());
  48181. }
  48182. return '<info>Console Tool</info>';
  48183. }
  48184. public function register($name)
  48185. {
  48186. return $this->add(new Command($name));
  48187. }
  48188. public function addCommands(array $commands)
  48189. {
  48190. foreach ($commands as $command) {
  48191. $this->add($command);
  48192. }
  48193. }
  48194. public function add(Command $command)
  48195. {
  48196. $this->init();
  48197. $command->setApplication($this);
  48198. if (!$command->isEnabled()) {
  48199. $command->setApplication(null);
  48200. return;
  48201. }
  48202. if (null === $command->getDefinition()) {
  48203. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  48204. }
  48205. $this->commands[$command->getName()] = $command;
  48206. foreach ($command->getAliases() as $alias) {
  48207. $this->commands[$alias] = $command;
  48208. }
  48209. return $command;
  48210. }
  48211. public function get($name)
  48212. {
  48213. $this->init();
  48214. if (!isset($this->commands[$name])) {
  48215. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  48216. }
  48217. $command = $this->commands[$name];
  48218. if ($this->wantHelps) {
  48219. $this->wantHelps = false;
  48220. $helpCommand = $this->get('help');
  48221. $helpCommand->setCommand($command);
  48222. return $helpCommand;
  48223. }
  48224. return $command;
  48225. }
  48226. public function has($name)
  48227. {
  48228. $this->init();
  48229. return isset($this->commands[$name]);
  48230. }
  48231. public function getNamespaces()
  48232. {
  48233. $namespaces = array();
  48234. foreach ($this->all() as $command) {
  48235. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  48236. foreach ($command->getAliases() as $alias) {
  48237. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  48238. }
  48239. }
  48240. return array_values(array_unique(array_filter($namespaces)));
  48241. }
  48242. public function findNamespace($namespace)
  48243. {
  48244. $allNamespaces = $this->getNamespaces();
  48245. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  48246. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  48247. if (empty($namespaces)) {
  48248. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  48249. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  48250. if (1 == \count($alternatives)) {
  48251. $message .= "\n\nDid you mean this?\n ";
  48252. } else {
  48253. $message .= "\n\nDid you mean one of these?\n ";
  48254. }
  48255. $message .= implode("\n ", $alternatives);
  48256. }
  48257. throw new CommandNotFoundException($message, $alternatives);
  48258. }
  48259. $exact = \in_array($namespace, $namespaces, true);
  48260. if (\count($namespaces) > 1 && !$exact) {
  48261. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  48262. }
  48263. return $exact ? $namespace : reset($namespaces);
  48264. }
  48265. public function find($name)
  48266. {
  48267. $this->init();
  48268. $aliases = array();
  48269. $allCommands = array_keys($this->commands);
  48270. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  48271. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  48272. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  48273. if (false !== $pos = strrpos($name, ':')) {
  48274. $this->findNamespace(substr($name, 0, $pos));
  48275. }
  48276. $message = sprintf('Command "%s" is not defined.', $name);
  48277. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  48278. if (1 == \count($alternatives)) {
  48279. $message .= "\n\nDid you mean this?\n ";
  48280. } else {
  48281. $message .= "\n\nDid you mean one of these?\n ";
  48282. }
  48283. $message .= implode("\n ", $alternatives);
  48284. }
  48285. throw new CommandNotFoundException($message, $alternatives);
  48286. }
  48287. if (\count($commands) > 1) {
  48288. $commandList = $this->commands;
  48289. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  48290. $commandName = $commandList[$nameOrAlias]->getName();
  48291. $aliases[$nameOrAlias] = $commandName;
  48292. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  48293. });
  48294. }
  48295. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  48296. if (!$exact && \count($commands) > 1) {
  48297. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  48298. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  48299. }
  48300. return $this->get($exact ? $name : reset($commands));
  48301. }
  48302. public function all($namespace = null)
  48303. {
  48304. $this->init();
  48305. if (null === $namespace) {
  48306. return $this->commands;
  48307. }
  48308. $commands = array();
  48309. foreach ($this->commands as $name => $command) {
  48310. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  48311. $commands[$name] = $command;
  48312. }
  48313. }
  48314. return $commands;
  48315. }
  48316. public static function getAbbreviations($names)
  48317. {
  48318. $abbrevs = array();
  48319. foreach ($names as $name) {
  48320. for ($len = \strlen($name); $len > 0; --$len) {
  48321. $abbrev = substr($name, 0, $len);
  48322. $abbrevs[$abbrev][] = $name;
  48323. }
  48324. }
  48325. return $abbrevs;
  48326. }
  48327. public function asText($namespace = null, $raw = false)
  48328. {
  48329. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48330. $descriptor = new TextDescriptor();
  48331. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  48332. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  48333. return $output->fetch();
  48334. }
  48335. public function asXml($namespace = null, $asDom = false)
  48336. {
  48337. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48338. $descriptor = new XmlDescriptor();
  48339. if ($asDom) {
  48340. return $descriptor->getApplicationDocument($this, $namespace);
  48341. }
  48342. $output = new BufferedOutput();
  48343. $descriptor->describe($output, $this, array('namespace' => $namespace));
  48344. return $output->fetch();
  48345. }
  48346. public function renderException($e, $output)
  48347. {
  48348. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48349. do {
  48350. $title = sprintf(' [%s] ', \get_class($e));
  48351. $len = Helper::strlen($title);
  48352. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  48353. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  48354. $width = 1 << 31;
  48355. }
  48356. $lines = array();
  48357. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  48358. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  48359. $lineLength = Helper::strlen($line) + 4;
  48360. $lines[] = array($line, $lineLength);
  48361. $len = max($lineLength, $len);
  48362. }
  48363. }
  48364. $messages = array();
  48365. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  48366. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  48367. foreach ($lines as $line) {
  48368. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  48369. }
  48370. $messages[] = $emptyLine;
  48371. $messages[] = '';
  48372. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  48373. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  48374. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  48375. $trace = $e->getTrace();
  48376. array_unshift($trace, array(
  48377. 'function' => '',
  48378. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  48379. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  48380. 'args' => array(),
  48381. ));
  48382. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  48383. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  48384. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  48385. $function = $trace[$i]['function'];
  48386. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  48387. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  48388. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  48389. }
  48390. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48391. }
  48392. } while ($e = $e->getPrevious());
  48393. if (null !== $this->runningCommand) {
  48394. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  48395. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48396. }
  48397. }
  48398. protected function getTerminalWidth()
  48399. {
  48400. $dimensions = $this->getTerminalDimensions();
  48401. return $dimensions[0];
  48402. }
  48403. protected function getTerminalHeight()
  48404. {
  48405. $dimensions = $this->getTerminalDimensions();
  48406. return $dimensions[1];
  48407. }
  48408. public function getTerminalDimensions()
  48409. {
  48410. if ($this->terminalDimensions) {
  48411. return $this->terminalDimensions;
  48412. }
  48413. if ('\\' === \DIRECTORY_SEPARATOR) {
  48414. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  48415. return array((int) $matches[1], (int) $matches[2]);
  48416. }
  48417. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  48418. return array((int) $matches[1], (int) $matches[2]);
  48419. }
  48420. }
  48421. if ($sttyString = $this->getSttyColumns()) {
  48422. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  48423. return array((int) $matches[2], (int) $matches[1]);
  48424. }
  48425. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  48426. return array((int) $matches[2], (int) $matches[1]);
  48427. }
  48428. }
  48429. return array(null, null);
  48430. }
  48431. public function setTerminalDimensions($width, $height)
  48432. {
  48433. $this->terminalDimensions = array($width, $height);
  48434. return $this;
  48435. }
  48436. protected function configureIO(InputInterface $input, OutputInterface $output)
  48437. {
  48438. if (true === $input->hasParameterOption(array('--ansi'))) {
  48439. $output->setDecorated(true);
  48440. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  48441. $output->setDecorated(false);
  48442. }
  48443. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  48444. $input->setInteractive(false);
  48445. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  48446. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  48447. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  48448. $input->setInteractive(false);
  48449. }
  48450. }
  48451. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  48452. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  48453. $input->setInteractive(false);
  48454. } else {
  48455. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  48456. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  48457. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  48458. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  48459. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  48460. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  48461. }
  48462. }
  48463. }
  48464. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  48465. {
  48466. foreach ($command->getHelperSet() as $helper) {
  48467. if ($helper instanceof InputAwareInterface) {
  48468. $helper->setInput($input);
  48469. }
  48470. }
  48471. if (null === $this->dispatcher) {
  48472. return $command->run($input, $output);
  48473. }
  48474. try {
  48475. $command->mergeApplicationDefinition();
  48476. $input->bind($command->getDefinition());
  48477. } catch (ExceptionInterface $e) {
  48478. }
  48479. $event = new ConsoleCommandEvent($command, $input, $output);
  48480. $e = null;
  48481. try {
  48482. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  48483. if ($event->commandShouldRun()) {
  48484. $exitCode = $command->run($input, $output);
  48485. } else {
  48486. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  48487. }
  48488. } catch (\Exception $e) {
  48489. } catch (\Throwable $e) {
  48490. }
  48491. if (null !== $e) {
  48492. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  48493. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  48494. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  48495. if ($x !== $event->getException()) {
  48496. $e = $event->getException();
  48497. }
  48498. $exitCode = $this->getExitCodeForThrowable($e);
  48499. }
  48500. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  48501. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  48502. if (null !== $e) {
  48503. throw $e;
  48504. }
  48505. return $event->getExitCode();
  48506. }
  48507. protected function getCommandName(InputInterface $input)
  48508. {
  48509. return $input->getFirstArgument();
  48510. }
  48511. protected function getDefaultInputDefinition()
  48512. {
  48513. return new InputDefinition(array(
  48514. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  48515. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  48516. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  48517. 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'),
  48518. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  48519. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  48520. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  48521. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  48522. ));
  48523. }
  48524. protected function getDefaultCommands()
  48525. {
  48526. return array(new HelpCommand(), new ListCommand());
  48527. }
  48528. protected function getDefaultHelperSet()
  48529. {
  48530. return new HelperSet(array(
  48531. new FormatterHelper(),
  48532. new DialogHelper(false),
  48533. new ProgressHelper(false),
  48534. new TableHelper(false),
  48535. new DebugFormatterHelper(),
  48536. new ProcessHelper(),
  48537. new QuestionHelper(),
  48538. ));
  48539. }
  48540. private function getSttyColumns()
  48541. {
  48542. if (!\function_exists('proc_open')) {
  48543. return;
  48544. }
  48545. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  48546. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  48547. if (\is_resource($process)) {
  48548. $info = stream_get_contents($pipes[1]);
  48549. fclose($pipes[1]);
  48550. fclose($pipes[2]);
  48551. proc_close($process);
  48552. return $info;
  48553. }
  48554. }
  48555. private function getConsoleMode()
  48556. {
  48557. if (!\function_exists('proc_open')) {
  48558. return;
  48559. }
  48560. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  48561. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  48562. if (\is_resource($process)) {
  48563. $info = stream_get_contents($pipes[1]);
  48564. fclose($pipes[1]);
  48565. fclose($pipes[2]);
  48566. proc_close($process);
  48567. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  48568. return $matches[2].'x'.$matches[1];
  48569. }
  48570. }
  48571. }
  48572. private function getAbbreviationSuggestions($abbrevs)
  48573. {
  48574. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  48575. }
  48576. public function extractNamespace($name, $limit = null)
  48577. {
  48578. $parts = explode(':', $name);
  48579. array_pop($parts);
  48580. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  48581. }
  48582. private function findAlternatives($name, $collection)
  48583. {
  48584. $threshold = 1e3;
  48585. $alternatives = array();
  48586. $collectionParts = array();
  48587. foreach ($collection as $item) {
  48588. $collectionParts[$item] = explode(':', $item);
  48589. }
  48590. foreach (explode(':', $name) as $i => $subname) {
  48591. foreach ($collectionParts as $collectionName => $parts) {
  48592. $exists = isset($alternatives[$collectionName]);
  48593. if (!isset($parts[$i]) && $exists) {
  48594. $alternatives[$collectionName] += $threshold;
  48595. continue;
  48596. } elseif (!isset($parts[$i])) {
  48597. continue;
  48598. }
  48599. $lev = levenshtein($subname, $parts[$i]);
  48600. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  48601. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  48602. } elseif ($exists) {
  48603. $alternatives[$collectionName] += $threshold;
  48604. }
  48605. }
  48606. }
  48607. foreach ($collection as $item) {
  48608. $lev = levenshtein($name, $item);
  48609. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  48610. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  48611. }
  48612. }
  48613. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  48614. asort($alternatives);
  48615. return array_keys($alternatives);
  48616. }
  48617. public function setDefaultCommand($commandName)
  48618. {
  48619. $this->defaultCommand = $commandName;
  48620. }
  48621. private function splitStringByWidth($string, $width)
  48622. {
  48623. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  48624. return str_split($string, $width);
  48625. }
  48626. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  48627. $lines = array();
  48628. $line = '';
  48629. foreach (preg_split('//u', $utf8String) as $char) {
  48630. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  48631. $line .= $char;
  48632. continue;
  48633. }
  48634. $lines[] = str_pad($line, $width);
  48635. $line = $char;
  48636. }
  48637. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  48638. mb_convert_variables($encoding, 'utf8', $lines);
  48639. return $lines;
  48640. }
  48641. private function extractAllNamespaces($name)
  48642. {
  48643. $parts = explode(':', $name, -1);
  48644. $namespaces = array();
  48645. foreach ($parts as $part) {
  48646. if (\count($namespaces)) {
  48647. $namespaces[] = end($namespaces).':'.$part;
  48648. } else {
  48649. $namespaces[] = $part;
  48650. }
  48651. }
  48652. return $namespaces;
  48653. }
  48654. private function init()
  48655. {
  48656. if ($this->initialized) {
  48657. return;
  48658. }
  48659. $this->initialized = true;
  48660. foreach ($this->getDefaultCommands() as $command) {
  48661. $this->add($command);
  48662. }
  48663. }
  48664. private function getExitCodeForThrowable($throwable)
  48665. {
  48666. $exitCode = $throwable->getCode();
  48667. if (is_numeric($exitCode)) {
  48668. $exitCode = (int) $exitCode;
  48669. if (0 === $exitCode) {
  48670. $exitCode = 1;
  48671. }
  48672. } else {
  48673. $exitCode = 1;
  48674. }
  48675. return $exitCode;
  48676. }
  48677. }
  48678. <?php
  48679. namespace Symfony\Component\Console\Command;
  48680. use Symfony\Component\Console\Application;
  48681. use Symfony\Component\Console\Descriptor\TextDescriptor;
  48682. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  48683. use Symfony\Component\Console\Exception\ExceptionInterface;
  48684. use Symfony\Component\Console\Exception\InvalidArgumentException;
  48685. use Symfony\Component\Console\Exception\LogicException;
  48686. use Symfony\Component\Console\Helper\HelperSet;
  48687. use Symfony\Component\Console\Input\InputArgument;
  48688. use Symfony\Component\Console\Input\InputDefinition;
  48689. use Symfony\Component\Console\Input\InputInterface;
  48690. use Symfony\Component\Console\Input\InputOption;
  48691. use Symfony\Component\Console\Output\BufferedOutput;
  48692. use Symfony\Component\Console\Output\OutputInterface;
  48693. class Command
  48694. {
  48695. private $application;
  48696. private $name;
  48697. private $processTitle;
  48698. private $aliases = array();
  48699. private $definition;
  48700. private $help;
  48701. private $description;
  48702. private $ignoreValidationErrors = false;
  48703. private $applicationDefinitionMerged = false;
  48704. private $applicationDefinitionMergedWithArgs = false;
  48705. private $code;
  48706. private $synopsis = array();
  48707. private $usages = array();
  48708. private $helperSet;
  48709. public function __construct($name = null)
  48710. {
  48711. $this->definition = new InputDefinition();
  48712. if (null !== $name) {
  48713. $this->setName($name);
  48714. }
  48715. $this->configure();
  48716. if (!$this->name) {
  48717. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  48718. }
  48719. }
  48720. public function ignoreValidationErrors()
  48721. {
  48722. $this->ignoreValidationErrors = true;
  48723. }
  48724. public function setApplication(Application $application = null)
  48725. {
  48726. $this->application = $application;
  48727. if ($application) {
  48728. $this->setHelperSet($application->getHelperSet());
  48729. } else {
  48730. $this->helperSet = null;
  48731. }
  48732. }
  48733. public function setHelperSet(HelperSet $helperSet)
  48734. {
  48735. $this->helperSet = $helperSet;
  48736. }
  48737. public function getHelperSet()
  48738. {
  48739. return $this->helperSet;
  48740. }
  48741. public function getApplication()
  48742. {
  48743. return $this->application;
  48744. }
  48745. public function isEnabled()
  48746. {
  48747. return true;
  48748. }
  48749. protected function configure()
  48750. {
  48751. }
  48752. protected function execute(InputInterface $input, OutputInterface $output)
  48753. {
  48754. throw new LogicException('You must override the execute() method in the concrete command class.');
  48755. }
  48756. protected function interact(InputInterface $input, OutputInterface $output)
  48757. {
  48758. }
  48759. protected function initialize(InputInterface $input, OutputInterface $output)
  48760. {
  48761. }
  48762. public function run(InputInterface $input, OutputInterface $output)
  48763. {
  48764. $this->getSynopsis(true);
  48765. $this->getSynopsis(false);
  48766. $this->mergeApplicationDefinition();
  48767. try {
  48768. $input->bind($this->definition);
  48769. } catch (ExceptionInterface $e) {
  48770. if (!$this->ignoreValidationErrors) {
  48771. throw $e;
  48772. }
  48773. }
  48774. $this->initialize($input, $output);
  48775. if (null !== $this->processTitle) {
  48776. if (\function_exists('cli_set_process_title')) {
  48777. if (!@cli_set_process_title($this->processTitle)) {
  48778. if ('Darwin' === PHP_OS) {
  48779. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  48780. } else {
  48781. cli_set_process_title($this->processTitle);
  48782. }
  48783. }
  48784. } elseif (\function_exists('setproctitle')) {
  48785. setproctitle($this->processTitle);
  48786. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  48787. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  48788. }
  48789. }
  48790. if ($input->isInteractive()) {
  48791. $this->interact($input, $output);
  48792. }
  48793. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  48794. $input->setArgument('command', $this->getName());
  48795. }
  48796. $input->validate();
  48797. if ($this->code) {
  48798. $statusCode = \call_user_func($this->code, $input, $output);
  48799. } else {
  48800. $statusCode = $this->execute($input, $output);
  48801. }
  48802. return is_numeric($statusCode) ? (int) $statusCode : 0;
  48803. }
  48804. public function setCode($code)
  48805. {
  48806. if (!\is_callable($code)) {
  48807. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  48808. }
  48809. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  48810. $r = new \ReflectionFunction($code);
  48811. if (null === $r->getClosureThis()) {
  48812. if (\PHP_VERSION_ID < 70000) {
  48813. $code = @\Closure::bind($code, $this);
  48814. } else {
  48815. $code = \Closure::bind($code, $this);
  48816. }
  48817. }
  48818. }
  48819. $this->code = $code;
  48820. return $this;
  48821. }
  48822. public function mergeApplicationDefinition($mergeArgs = true)
  48823. {
  48824. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  48825. return;
  48826. }
  48827. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  48828. $this->applicationDefinitionMerged = true;
  48829. if ($mergeArgs) {
  48830. $currentArguments = $this->definition->getArguments();
  48831. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  48832. $this->definition->addArguments($currentArguments);
  48833. $this->applicationDefinitionMergedWithArgs = true;
  48834. }
  48835. }
  48836. public function setDefinition($definition)
  48837. {
  48838. if ($definition instanceof InputDefinition) {
  48839. $this->definition = $definition;
  48840. } else {
  48841. $this->definition->setDefinition($definition);
  48842. }
  48843. $this->applicationDefinitionMerged = false;
  48844. return $this;
  48845. }
  48846. public function getDefinition()
  48847. {
  48848. return $this->definition;
  48849. }
  48850. public function getNativeDefinition()
  48851. {
  48852. return $this->getDefinition();
  48853. }
  48854. public function addArgument($name, $mode = null, $description = '', $default = null)
  48855. {
  48856. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  48857. return $this;
  48858. }
  48859. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  48860. {
  48861. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  48862. return $this;
  48863. }
  48864. public function setName($name)
  48865. {
  48866. $this->validateName($name);
  48867. $this->name = $name;
  48868. return $this;
  48869. }
  48870. public function setProcessTitle($title)
  48871. {
  48872. $this->processTitle = $title;
  48873. return $this;
  48874. }
  48875. public function getName()
  48876. {
  48877. return $this->name;
  48878. }
  48879. public function setDescription($description)
  48880. {
  48881. $this->description = $description;
  48882. return $this;
  48883. }
  48884. public function getDescription()
  48885. {
  48886. return $this->description;
  48887. }
  48888. public function setHelp($help)
  48889. {
  48890. $this->help = $help;
  48891. return $this;
  48892. }
  48893. public function getHelp()
  48894. {
  48895. return $this->help;
  48896. }
  48897. public function getProcessedHelp()
  48898. {
  48899. $name = $this->name;
  48900. $placeholders = array(
  48901. '%command.name%',
  48902. '%command.full_name%',
  48903. );
  48904. $replacements = array(
  48905. $name,
  48906. $_SERVER['PHP_SELF'].' '.$name,
  48907. );
  48908. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  48909. }
  48910. public function setAliases($aliases)
  48911. {
  48912. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  48913. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  48914. }
  48915. foreach ($aliases as $alias) {
  48916. $this->validateName($alias);
  48917. }
  48918. $this->aliases = $aliases;
  48919. return $this;
  48920. }
  48921. public function getAliases()
  48922. {
  48923. return $this->aliases;
  48924. }
  48925. public function getSynopsis($short = false)
  48926. {
  48927. $key = $short ? 'short' : 'long';
  48928. if (!isset($this->synopsis[$key])) {
  48929. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  48930. }
  48931. return $this->synopsis[$key];
  48932. }
  48933. public function addUsage($usage)
  48934. {
  48935. if (0 !== strpos($usage, $this->name)) {
  48936. $usage = sprintf('%s %s', $this->name, $usage);
  48937. }
  48938. $this->usages[] = $usage;
  48939. return $this;
  48940. }
  48941. public function getUsages()
  48942. {
  48943. return $this->usages;
  48944. }
  48945. public function getHelper($name)
  48946. {
  48947. if (null === $this->helperSet) {
  48948. 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));
  48949. }
  48950. return $this->helperSet->get($name);
  48951. }
  48952. public function asText()
  48953. {
  48954. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48955. $descriptor = new TextDescriptor();
  48956. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  48957. $descriptor->describe($output, $this, array('raw_output' => true));
  48958. return $output->fetch();
  48959. }
  48960. public function asXml($asDom = false)
  48961. {
  48962. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48963. $descriptor = new XmlDescriptor();
  48964. if ($asDom) {
  48965. return $descriptor->getCommandDocument($this);
  48966. }
  48967. $output = new BufferedOutput();
  48968. $descriptor->describe($output, $this);
  48969. return $output->fetch();
  48970. }
  48971. private function validateName($name)
  48972. {
  48973. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  48974. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  48975. }
  48976. }
  48977. }
  48978. <?php
  48979. namespace Symfony\Component\Console\Command;
  48980. use Symfony\Component\Console\Helper\DescriptorHelper;
  48981. use Symfony\Component\Console\Input\InputArgument;
  48982. use Symfony\Component\Console\Input\InputInterface;
  48983. use Symfony\Component\Console\Input\InputOption;
  48984. use Symfony\Component\Console\Output\OutputInterface;
  48985. class HelpCommand extends Command
  48986. {
  48987. private $command;
  48988. protected function configure()
  48989. {
  48990. $this->ignoreValidationErrors();
  48991. $this
  48992. ->setName('help')
  48993. ->setDefinition(array(
  48994. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  48995. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  48996. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  48997. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  48998. ))
  48999. ->setDescription('Displays help for a command')
  49000. ->setHelp(<<<'EOF'
  49001. The <info>%command.name%</info> command displays help for a given command:
  49002. <info>php %command.full_name% list</info>
  49003. You can also output the help in other formats by using the <comment>--format</comment> option:
  49004. <info>php %command.full_name% --format=xml list</info>
  49005. To display the list of available commands, please use the <info>list</info> command.
  49006. EOF
  49007. )
  49008. ;
  49009. }
  49010. public function setCommand(Command $command)
  49011. {
  49012. $this->command = $command;
  49013. }
  49014. protected function execute(InputInterface $input, OutputInterface $output)
  49015. {
  49016. if (null === $this->command) {
  49017. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  49018. }
  49019. if ($input->getOption('xml')) {
  49020. @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);
  49021. $input->setOption('format', 'xml');
  49022. }
  49023. $helper = new DescriptorHelper();
  49024. $helper->describe($output, $this->command, array(
  49025. 'format' => $input->getOption('format'),
  49026. 'raw_text' => $input->getOption('raw'),
  49027. ));
  49028. $this->command = null;
  49029. }
  49030. }
  49031. <?php
  49032. namespace Symfony\Component\Console\Command;
  49033. use Symfony\Component\Console\Helper\DescriptorHelper;
  49034. use Symfony\Component\Console\Input\InputArgument;
  49035. use Symfony\Component\Console\Input\InputDefinition;
  49036. use Symfony\Component\Console\Input\InputInterface;
  49037. use Symfony\Component\Console\Input\InputOption;
  49038. use Symfony\Component\Console\Output\OutputInterface;
  49039. class ListCommand extends Command
  49040. {
  49041. protected function configure()
  49042. {
  49043. $this
  49044. ->setName('list')
  49045. ->setDefinition($this->createDefinition())
  49046. ->setDescription('Lists commands')
  49047. ->setHelp(<<<'EOF'
  49048. The <info>%command.name%</info> command lists all commands:
  49049. <info>php %command.full_name%</info>
  49050. You can also display the commands for a specific namespace:
  49051. <info>php %command.full_name% test</info>
  49052. You can also output the information in other formats by using the <comment>--format</comment> option:
  49053. <info>php %command.full_name% --format=xml</info>
  49054. It's also possible to get raw list of commands (useful for embedding command runner):
  49055. <info>php %command.full_name% --raw</info>
  49056. EOF
  49057. )
  49058. ;
  49059. }
  49060. public function getNativeDefinition()
  49061. {
  49062. return $this->createDefinition();
  49063. }
  49064. protected function execute(InputInterface $input, OutputInterface $output)
  49065. {
  49066. if ($input->getOption('xml')) {
  49067. @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);
  49068. $input->setOption('format', 'xml');
  49069. }
  49070. $helper = new DescriptorHelper();
  49071. $helper->describe($output, $this->getApplication(), array(
  49072. 'format' => $input->getOption('format'),
  49073. 'raw_text' => $input->getOption('raw'),
  49074. 'namespace' => $input->getArgument('namespace'),
  49075. ));
  49076. }
  49077. private function createDefinition()
  49078. {
  49079. return new InputDefinition(array(
  49080. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  49081. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  49082. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  49083. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  49084. ));
  49085. }
  49086. }
  49087. <?php
  49088. namespace Symfony\Component\Console;
  49089. final class ConsoleEvents
  49090. {
  49091. const COMMAND = 'console.command';
  49092. const TERMINATE = 'console.terminate';
  49093. const EXCEPTION = 'console.exception';
  49094. }
  49095. <?php
  49096. namespace Symfony\Component\Console\Descriptor;
  49097. use Symfony\Component\Console\Application;
  49098. use Symfony\Component\Console\Command\Command;
  49099. use Symfony\Component\Console\Exception\CommandNotFoundException;
  49100. class ApplicationDescription
  49101. {
  49102. const GLOBAL_NAMESPACE = '_global';
  49103. private $application;
  49104. private $namespace;
  49105. private $namespaces;
  49106. private $commands;
  49107. private $aliases;
  49108. public function __construct(Application $application, $namespace = null)
  49109. {
  49110. $this->application = $application;
  49111. $this->namespace = $namespace;
  49112. }
  49113. public function getNamespaces()
  49114. {
  49115. if (null === $this->namespaces) {
  49116. $this->inspectApplication();
  49117. }
  49118. return $this->namespaces;
  49119. }
  49120. public function getCommands()
  49121. {
  49122. if (null === $this->commands) {
  49123. $this->inspectApplication();
  49124. }
  49125. return $this->commands;
  49126. }
  49127. public function getCommand($name)
  49128. {
  49129. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  49130. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  49131. }
  49132. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  49133. }
  49134. private function inspectApplication()
  49135. {
  49136. $this->commands = array();
  49137. $this->namespaces = array();
  49138. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  49139. foreach ($this->sortCommands($all) as $namespace => $commands) {
  49140. $names = array();
  49141. foreach ($commands as $name => $command) {
  49142. if (!$command->getName()) {
  49143. continue;
  49144. }
  49145. if ($command->getName() === $name) {
  49146. $this->commands[$name] = $command;
  49147. } else {
  49148. $this->aliases[$name] = $command;
  49149. }
  49150. $names[] = $name;
  49151. }
  49152. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  49153. }
  49154. }
  49155. private function sortCommands(array $commands)
  49156. {
  49157. $namespacedCommands = array();
  49158. $globalCommands = array();
  49159. foreach ($commands as $name => $command) {
  49160. $key = $this->application->extractNamespace($name, 1);
  49161. if (!$key) {
  49162. $globalCommands['_global'][$name] = $command;
  49163. } else {
  49164. $namespacedCommands[$key][$name] = $command;
  49165. }
  49166. }
  49167. ksort($namespacedCommands);
  49168. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  49169. foreach ($namespacedCommands as &$commandsSet) {
  49170. ksort($commandsSet);
  49171. }
  49172. unset($commandsSet);
  49173. return $namespacedCommands;
  49174. }
  49175. }
  49176. <?php
  49177. namespace Symfony\Component\Console\Descriptor;
  49178. use Symfony\Component\Console\Application;
  49179. use Symfony\Component\Console\Command\Command;
  49180. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49181. use Symfony\Component\Console\Input\InputArgument;
  49182. use Symfony\Component\Console\Input\InputDefinition;
  49183. use Symfony\Component\Console\Input\InputOption;
  49184. use Symfony\Component\Console\Output\OutputInterface;
  49185. abstract class Descriptor implements DescriptorInterface
  49186. {
  49187. private $output;
  49188. public function describe(OutputInterface $output, $object, array $options = array())
  49189. {
  49190. $this->output = $output;
  49191. switch (true) {
  49192. case $object instanceof InputArgument:
  49193. $this->describeInputArgument($object, $options);
  49194. break;
  49195. case $object instanceof InputOption:
  49196. $this->describeInputOption($object, $options);
  49197. break;
  49198. case $object instanceof InputDefinition:
  49199. $this->describeInputDefinition($object, $options);
  49200. break;
  49201. case $object instanceof Command:
  49202. $this->describeCommand($object, $options);
  49203. break;
  49204. case $object instanceof Application:
  49205. $this->describeApplication($object, $options);
  49206. break;
  49207. default:
  49208. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  49209. }
  49210. }
  49211. protected function write($content, $decorated = false)
  49212. {
  49213. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  49214. }
  49215. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  49216. abstract protected function describeInputOption(InputOption $option, array $options = array());
  49217. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  49218. abstract protected function describeCommand(Command $command, array $options = array());
  49219. abstract protected function describeApplication(Application $application, array $options = array());
  49220. }
  49221. <?php
  49222. namespace Symfony\Component\Console\Descriptor;
  49223. use Symfony\Component\Console\Output\OutputInterface;
  49224. interface DescriptorInterface
  49225. {
  49226. public function describe(OutputInterface $output, $object, array $options = array());
  49227. }
  49228. <?php
  49229. namespace Symfony\Component\Console\Descriptor;
  49230. use Symfony\Component\Console\Application;
  49231. use Symfony\Component\Console\Command\Command;
  49232. use Symfony\Component\Console\Input\InputArgument;
  49233. use Symfony\Component\Console\Input\InputDefinition;
  49234. use Symfony\Component\Console\Input\InputOption;
  49235. class JsonDescriptor extends Descriptor
  49236. {
  49237. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49238. {
  49239. $this->writeData($this->getInputArgumentData($argument), $options);
  49240. }
  49241. protected function describeInputOption(InputOption $option, array $options = array())
  49242. {
  49243. $this->writeData($this->getInputOptionData($option), $options);
  49244. }
  49245. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49246. {
  49247. $this->writeData($this->getInputDefinitionData($definition), $options);
  49248. }
  49249. protected function describeCommand(Command $command, array $options = array())
  49250. {
  49251. $this->writeData($this->getCommandData($command), $options);
  49252. }
  49253. protected function describeApplication(Application $application, array $options = array())
  49254. {
  49255. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49256. $description = new ApplicationDescription($application, $describedNamespace);
  49257. $commands = array();
  49258. foreach ($description->getCommands() as $command) {
  49259. $commands[] = $this->getCommandData($command);
  49260. }
  49261. $data = $describedNamespace
  49262. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  49263. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  49264. $this->writeData($data, $options);
  49265. }
  49266. private function writeData(array $data, array $options)
  49267. {
  49268. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  49269. }
  49270. private function getInputArgumentData(InputArgument $argument)
  49271. {
  49272. return array(
  49273. 'name' => $argument->getName(),
  49274. 'is_required' => $argument->isRequired(),
  49275. 'is_array' => $argument->isArray(),
  49276. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  49277. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  49278. );
  49279. }
  49280. private function getInputOptionData(InputOption $option)
  49281. {
  49282. return array(
  49283. 'name' => '--'.$option->getName(),
  49284. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  49285. 'accept_value' => $option->acceptValue(),
  49286. 'is_value_required' => $option->isValueRequired(),
  49287. 'is_multiple' => $option->isArray(),
  49288. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  49289. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  49290. );
  49291. }
  49292. private function getInputDefinitionData(InputDefinition $definition)
  49293. {
  49294. $inputArguments = array();
  49295. foreach ($definition->getArguments() as $name => $argument) {
  49296. $inputArguments[$name] = $this->getInputArgumentData($argument);
  49297. }
  49298. $inputOptions = array();
  49299. foreach ($definition->getOptions() as $name => $option) {
  49300. $inputOptions[$name] = $this->getInputOptionData($option);
  49301. }
  49302. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  49303. }
  49304. private function getCommandData(Command $command)
  49305. {
  49306. $command->getSynopsis();
  49307. $command->mergeApplicationDefinition(false);
  49308. return array(
  49309. 'name' => $command->getName(),
  49310. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  49311. 'description' => $command->getDescription(),
  49312. 'help' => $command->getProcessedHelp(),
  49313. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  49314. );
  49315. }
  49316. }
  49317. <?php
  49318. namespace Symfony\Component\Console\Descriptor;
  49319. use Symfony\Component\Console\Application;
  49320. use Symfony\Component\Console\Command\Command;
  49321. use Symfony\Component\Console\Helper\Helper;
  49322. use Symfony\Component\Console\Input\InputArgument;
  49323. use Symfony\Component\Console\Input\InputDefinition;
  49324. use Symfony\Component\Console\Input\InputOption;
  49325. class MarkdownDescriptor extends Descriptor
  49326. {
  49327. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49328. {
  49329. $this->write(
  49330. '**'.$argument->getName().':**'."\n\n"
  49331. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  49332. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  49333. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  49334. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  49335. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  49336. );
  49337. }
  49338. protected function describeInputOption(InputOption $option, array $options = array())
  49339. {
  49340. $this->write(
  49341. '**'.$option->getName().':**'."\n\n"
  49342. .'* Name: `--'.$option->getName().'`'."\n"
  49343. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  49344. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  49345. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  49346. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  49347. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  49348. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  49349. );
  49350. }
  49351. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49352. {
  49353. if ($showArguments = \count($definition->getArguments()) > 0) {
  49354. $this->write('### Arguments:');
  49355. foreach ($definition->getArguments() as $argument) {
  49356. $this->write("\n\n");
  49357. $this->write($this->describeInputArgument($argument));
  49358. }
  49359. }
  49360. if (\count($definition->getOptions()) > 0) {
  49361. if ($showArguments) {
  49362. $this->write("\n\n");
  49363. }
  49364. $this->write('### Options:');
  49365. foreach ($definition->getOptions() as $option) {
  49366. $this->write("\n\n");
  49367. $this->write($this->describeInputOption($option));
  49368. }
  49369. }
  49370. }
  49371. protected function describeCommand(Command $command, array $options = array())
  49372. {
  49373. $command->getSynopsis();
  49374. $command->mergeApplicationDefinition(false);
  49375. $this->write(
  49376. $command->getName()."\n"
  49377. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  49378. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  49379. .'* Usage:'."\n\n"
  49380. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  49381. return $carry.' * `'.$usage.'`'."\n";
  49382. })
  49383. );
  49384. if ($help = $command->getProcessedHelp()) {
  49385. $this->write("\n");
  49386. $this->write($help);
  49387. }
  49388. if ($command->getNativeDefinition()) {
  49389. $this->write("\n\n");
  49390. $this->describeInputDefinition($command->getNativeDefinition());
  49391. }
  49392. }
  49393. protected function describeApplication(Application $application, array $options = array())
  49394. {
  49395. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49396. $description = new ApplicationDescription($application, $describedNamespace);
  49397. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  49398. foreach ($description->getNamespaces() as $namespace) {
  49399. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  49400. $this->write("\n\n");
  49401. $this->write('**'.$namespace['id'].':**');
  49402. }
  49403. $this->write("\n\n");
  49404. $this->write(implode("\n", array_map(function ($commandName) {
  49405. return '* '.$commandName;
  49406. }, $namespace['commands'])));
  49407. }
  49408. foreach ($description->getCommands() as $command) {
  49409. $this->write("\n\n");
  49410. $this->write($this->describeCommand($command));
  49411. }
  49412. }
  49413. }
  49414. <?php
  49415. namespace Symfony\Component\Console\Descriptor;
  49416. use Symfony\Component\Console\Application;
  49417. use Symfony\Component\Console\Command\Command;
  49418. use Symfony\Component\Console\Formatter\OutputFormatter;
  49419. use Symfony\Component\Console\Helper\Helper;
  49420. use Symfony\Component\Console\Input\InputArgument;
  49421. use Symfony\Component\Console\Input\InputDefinition;
  49422. use Symfony\Component\Console\Input\InputOption;
  49423. class TextDescriptor extends Descriptor
  49424. {
  49425. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49426. {
  49427. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  49428. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  49429. } else {
  49430. $default = '';
  49431. }
  49432. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  49433. $spacingWidth = $totalWidth - \strlen($argument->getName());
  49434. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  49435. $argument->getName(),
  49436. str_repeat(' ', $spacingWidth),
  49437. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  49438. $default
  49439. ), $options);
  49440. }
  49441. protected function describeInputOption(InputOption $option, array $options = array())
  49442. {
  49443. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  49444. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  49445. } else {
  49446. $default = '';
  49447. }
  49448. $value = '';
  49449. if ($option->acceptValue()) {
  49450. $value = '='.strtoupper($option->getName());
  49451. if ($option->isValueOptional()) {
  49452. $value = '['.$value.']';
  49453. }
  49454. }
  49455. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  49456. $synopsis = sprintf('%s%s',
  49457. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  49458. sprintf('--%s%s', $option->getName(), $value)
  49459. );
  49460. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  49461. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  49462. $synopsis,
  49463. str_repeat(' ', $spacingWidth),
  49464. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  49465. $default,
  49466. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  49467. ), $options);
  49468. }
  49469. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49470. {
  49471. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  49472. foreach ($definition->getArguments() as $argument) {
  49473. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  49474. }
  49475. if ($definition->getArguments()) {
  49476. $this->writeText('<comment>Arguments:</comment>', $options);
  49477. $this->writeText("\n");
  49478. foreach ($definition->getArguments() as $argument) {
  49479. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  49480. $this->writeText("\n");
  49481. }
  49482. }
  49483. if ($definition->getArguments() && $definition->getOptions()) {
  49484. $this->writeText("\n");
  49485. }
  49486. if ($definition->getOptions()) {
  49487. $laterOptions = array();
  49488. $this->writeText('<comment>Options:</comment>', $options);
  49489. foreach ($definition->getOptions() as $option) {
  49490. if (\strlen($option->getShortcut()) > 1) {
  49491. $laterOptions[] = $option;
  49492. continue;
  49493. }
  49494. $this->writeText("\n");
  49495. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  49496. }
  49497. foreach ($laterOptions as $option) {
  49498. $this->writeText("\n");
  49499. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  49500. }
  49501. }
  49502. }
  49503. protected function describeCommand(Command $command, array $options = array())
  49504. {
  49505. $command->getSynopsis(true);
  49506. $command->getSynopsis(false);
  49507. $command->mergeApplicationDefinition(false);
  49508. $this->writeText('<comment>Usage:</comment>', $options);
  49509. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  49510. $this->writeText("\n");
  49511. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  49512. }
  49513. $this->writeText("\n");
  49514. $definition = $command->getNativeDefinition();
  49515. if ($definition->getOptions() || $definition->getArguments()) {
  49516. $this->writeText("\n");
  49517. $this->describeInputDefinition($definition, $options);
  49518. $this->writeText("\n");
  49519. }
  49520. if ($help = $command->getProcessedHelp()) {
  49521. $this->writeText("\n");
  49522. $this->writeText('<comment>Help:</comment>', $options);
  49523. $this->writeText("\n");
  49524. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  49525. $this->writeText("\n");
  49526. }
  49527. }
  49528. protected function describeApplication(Application $application, array $options = array())
  49529. {
  49530. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49531. $description = new ApplicationDescription($application, $describedNamespace);
  49532. if (isset($options['raw_text']) && $options['raw_text']) {
  49533. $width = $this->getColumnWidth($description->getCommands());
  49534. foreach ($description->getCommands() as $command) {
  49535. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  49536. $this->writeText("\n");
  49537. }
  49538. } else {
  49539. if ('' != $help = $application->getHelp()) {
  49540. $this->writeText("$help\n\n", $options);
  49541. }
  49542. $this->writeText("<comment>Usage:</comment>\n", $options);
  49543. $this->writeText(" command [options] [arguments]\n\n", $options);
  49544. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  49545. $this->writeText("\n");
  49546. $this->writeText("\n");
  49547. $width = $this->getColumnWidth($description->getCommands());
  49548. if ($describedNamespace) {
  49549. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  49550. } else {
  49551. $this->writeText('<comment>Available commands:</comment>', $options);
  49552. }
  49553. foreach ($description->getNamespaces() as $namespace) {
  49554. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  49555. $this->writeText("\n");
  49556. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  49557. }
  49558. foreach ($namespace['commands'] as $name) {
  49559. $this->writeText("\n");
  49560. $spacingWidth = $width - Helper::strlen($name);
  49561. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  49562. }
  49563. }
  49564. $this->writeText("\n");
  49565. }
  49566. }
  49567. private function writeText($content, array $options = array())
  49568. {
  49569. $this->write(
  49570. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  49571. isset($options['raw_output']) ? !$options['raw_output'] : true
  49572. );
  49573. }
  49574. private function formatDefaultValue($default)
  49575. {
  49576. if (INF === $default) {
  49577. return 'INF';
  49578. }
  49579. if (\is_string($default)) {
  49580. $default = OutputFormatter::escape($default);
  49581. } elseif (\is_array($default)) {
  49582. foreach ($default as $key => $value) {
  49583. if (\is_string($value)) {
  49584. $default[$key] = OutputFormatter::escape($value);
  49585. }
  49586. }
  49587. }
  49588. if (\PHP_VERSION_ID < 50400) {
  49589. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  49590. }
  49591. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  49592. }
  49593. private function getColumnWidth(array $commands)
  49594. {
  49595. $widths = array();
  49596. foreach ($commands as $command) {
  49597. $widths[] = Helper::strlen($command->getName());
  49598. foreach ($command->getAliases() as $alias) {
  49599. $widths[] = Helper::strlen($alias);
  49600. }
  49601. }
  49602. return max($widths) + 2;
  49603. }
  49604. private function calculateTotalWidthForOptions(array $options)
  49605. {
  49606. $totalWidth = 0;
  49607. foreach ($options as $option) {
  49608. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  49609. if ($option->acceptValue()) {
  49610. $valueLength = 1 + Helper::strlen($option->getName());
  49611. $valueLength += $option->isValueOptional() ? 2 : 0;
  49612. $nameLength += $valueLength;
  49613. }
  49614. $totalWidth = max($totalWidth, $nameLength);
  49615. }
  49616. return $totalWidth;
  49617. }
  49618. }
  49619. <?php
  49620. namespace Symfony\Component\Console\Descriptor;
  49621. use Symfony\Component\Console\Application;
  49622. use Symfony\Component\Console\Command\Command;
  49623. use Symfony\Component\Console\Input\InputArgument;
  49624. use Symfony\Component\Console\Input\InputDefinition;
  49625. use Symfony\Component\Console\Input\InputOption;
  49626. class XmlDescriptor extends Descriptor
  49627. {
  49628. public function getInputDefinitionDocument(InputDefinition $definition)
  49629. {
  49630. $dom = new \DOMDocument('1.0', 'UTF-8');
  49631. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  49632. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  49633. foreach ($definition->getArguments() as $argument) {
  49634. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  49635. }
  49636. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  49637. foreach ($definition->getOptions() as $option) {
  49638. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  49639. }
  49640. return $dom;
  49641. }
  49642. public function getCommandDocument(Command $command)
  49643. {
  49644. $dom = new \DOMDocument('1.0', 'UTF-8');
  49645. $dom->appendChild($commandXML = $dom->createElement('command'));
  49646. $command->getSynopsis();
  49647. $command->mergeApplicationDefinition(false);
  49648. $commandXML->setAttribute('id', $command->getName());
  49649. $commandXML->setAttribute('name', $command->getName());
  49650. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  49651. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  49652. $usagesXML->appendChild($dom->createElement('usage', $usage));
  49653. }
  49654. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  49655. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  49656. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  49657. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  49658. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  49659. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  49660. return $dom;
  49661. }
  49662. public function getApplicationDocument(Application $application, $namespace = null)
  49663. {
  49664. $dom = new \DOMDocument('1.0', 'UTF-8');
  49665. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  49666. if ('UNKNOWN' !== $application->getName()) {
  49667. $rootXml->setAttribute('name', $application->getName());
  49668. if ('UNKNOWN' !== $application->getVersion()) {
  49669. $rootXml->setAttribute('version', $application->getVersion());
  49670. }
  49671. }
  49672. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  49673. $description = new ApplicationDescription($application, $namespace);
  49674. if ($namespace) {
  49675. $commandsXML->setAttribute('namespace', $namespace);
  49676. }
  49677. foreach ($description->getCommands() as $command) {
  49678. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  49679. }
  49680. if (!$namespace) {
  49681. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  49682. foreach ($description->getNamespaces() as $namespaceDescription) {
  49683. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  49684. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  49685. foreach ($namespaceDescription['commands'] as $name) {
  49686. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  49687. $commandXML->appendChild($dom->createTextNode($name));
  49688. }
  49689. }
  49690. }
  49691. return $dom;
  49692. }
  49693. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49694. {
  49695. $this->writeDocument($this->getInputArgumentDocument($argument));
  49696. }
  49697. protected function describeInputOption(InputOption $option, array $options = array())
  49698. {
  49699. $this->writeDocument($this->getInputOptionDocument($option));
  49700. }
  49701. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49702. {
  49703. $this->writeDocument($this->getInputDefinitionDocument($definition));
  49704. }
  49705. protected function describeCommand(Command $command, array $options = array())
  49706. {
  49707. $this->writeDocument($this->getCommandDocument($command));
  49708. }
  49709. protected function describeApplication(Application $application, array $options = array())
  49710. {
  49711. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  49712. }
  49713. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  49714. {
  49715. foreach ($importedParent->childNodes as $childNode) {
  49716. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  49717. }
  49718. }
  49719. private function writeDocument(\DOMDocument $dom)
  49720. {
  49721. $dom->formatOutput = true;
  49722. $this->write($dom->saveXML());
  49723. }
  49724. private function getInputArgumentDocument(InputArgument $argument)
  49725. {
  49726. $dom = new \DOMDocument('1.0', 'UTF-8');
  49727. $dom->appendChild($objectXML = $dom->createElement('argument'));
  49728. $objectXML->setAttribute('name', $argument->getName());
  49729. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  49730. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  49731. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49732. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  49733. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49734. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  49735. foreach ($defaults as $default) {
  49736. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49737. $defaultXML->appendChild($dom->createTextNode($default));
  49738. }
  49739. return $dom;
  49740. }
  49741. private function getInputOptionDocument(InputOption $option)
  49742. {
  49743. $dom = new \DOMDocument('1.0', 'UTF-8');
  49744. $dom->appendChild($objectXML = $dom->createElement('option'));
  49745. $objectXML->setAttribute('name', '--'.$option->getName());
  49746. $pos = strpos($option->getShortcut(), '|');
  49747. if (false !== $pos) {
  49748. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  49749. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  49750. } else {
  49751. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  49752. }
  49753. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  49754. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  49755. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  49756. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49757. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  49758. if ($option->acceptValue()) {
  49759. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  49760. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49761. if (!empty($defaults)) {
  49762. foreach ($defaults as $default) {
  49763. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49764. $defaultXML->appendChild($dom->createTextNode($default));
  49765. }
  49766. }
  49767. }
  49768. return $dom;
  49769. }
  49770. }
  49771. <?php
  49772. namespace Symfony\Component\Console\Event;
  49773. class ConsoleCommandEvent extends ConsoleEvent
  49774. {
  49775. const RETURN_CODE_DISABLED = 113;
  49776. private $commandShouldRun = true;
  49777. public function disableCommand()
  49778. {
  49779. return $this->commandShouldRun = false;
  49780. }
  49781. public function enableCommand()
  49782. {
  49783. return $this->commandShouldRun = true;
  49784. }
  49785. public function commandShouldRun()
  49786. {
  49787. return $this->commandShouldRun;
  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. use Symfony\Component\EventDispatcher\Event;
  49796. class ConsoleEvent extends Event
  49797. {
  49798. protected $command;
  49799. private $input;
  49800. private $output;
  49801. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  49802. {
  49803. $this->command = $command;
  49804. $this->input = $input;
  49805. $this->output = $output;
  49806. }
  49807. public function getCommand()
  49808. {
  49809. return $this->command;
  49810. }
  49811. public function getInput()
  49812. {
  49813. return $this->input;
  49814. }
  49815. public function getOutput()
  49816. {
  49817. return $this->output;
  49818. }
  49819. }
  49820. <?php
  49821. namespace Symfony\Component\Console\Event;
  49822. use Symfony\Component\Console\Command\Command;
  49823. use Symfony\Component\Console\Input\InputInterface;
  49824. use Symfony\Component\Console\Output\OutputInterface;
  49825. class ConsoleExceptionEvent extends ConsoleEvent
  49826. {
  49827. private $exception;
  49828. private $exitCode;
  49829. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  49830. {
  49831. parent::__construct($command, $input, $output);
  49832. $this->setException($exception);
  49833. $this->exitCode = (int) $exitCode;
  49834. }
  49835. public function getException()
  49836. {
  49837. return $this->exception;
  49838. }
  49839. public function setException(\Exception $exception)
  49840. {
  49841. $this->exception = $exception;
  49842. }
  49843. public function getExitCode()
  49844. {
  49845. return $this->exitCode;
  49846. }
  49847. }
  49848. <?php
  49849. namespace Symfony\Component\Console\Event;
  49850. use Symfony\Component\Console\Command\Command;
  49851. use Symfony\Component\Console\Input\InputInterface;
  49852. use Symfony\Component\Console\Output\OutputInterface;
  49853. class ConsoleTerminateEvent extends ConsoleEvent
  49854. {
  49855. private $exitCode;
  49856. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  49857. {
  49858. parent::__construct($command, $input, $output);
  49859. $this->setExitCode($exitCode);
  49860. }
  49861. public function setExitCode($exitCode)
  49862. {
  49863. $this->exitCode = (int) $exitCode;
  49864. }
  49865. public function getExitCode()
  49866. {
  49867. return $this->exitCode;
  49868. }
  49869. }
  49870. <?php
  49871. namespace Symfony\Component\Console\Exception;
  49872. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  49873. {
  49874. private $alternatives;
  49875. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  49876. {
  49877. parent::__construct($message, $code, $previous);
  49878. $this->alternatives = $alternatives;
  49879. }
  49880. public function getAlternatives()
  49881. {
  49882. return $this->alternatives;
  49883. }
  49884. }
  49885. <?php
  49886. namespace Symfony\Component\Console\Exception;
  49887. interface ExceptionInterface
  49888. {
  49889. }
  49890. <?php
  49891. namespace Symfony\Component\Console\Exception;
  49892. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  49893. {
  49894. }
  49895. <?php
  49896. namespace Symfony\Component\Console\Exception;
  49897. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  49898. {
  49899. }
  49900. <?php
  49901. namespace Symfony\Component\Console\Exception;
  49902. class LogicException extends \LogicException implements ExceptionInterface
  49903. {
  49904. }
  49905. <?php
  49906. namespace Symfony\Component\Console\Exception;
  49907. class RuntimeException extends \RuntimeException implements ExceptionInterface
  49908. {
  49909. }
  49910. <?php
  49911. namespace Symfony\Component\Console\Formatter;
  49912. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49913. class OutputFormatter implements OutputFormatterInterface
  49914. {
  49915. private $decorated;
  49916. private $styles = array();
  49917. private $styleStack;
  49918. public static function escape($text)
  49919. {
  49920. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  49921. return self::escapeTrailingBackslash($text);
  49922. }
  49923. public static function escapeTrailingBackslash($text)
  49924. {
  49925. if ('\\' === substr($text, -1)) {
  49926. $len = \strlen($text);
  49927. $text = rtrim($text, '\\');
  49928. $text = str_replace("\0", '', $text);
  49929. $text .= str_repeat("\0", $len - \strlen($text));
  49930. }
  49931. return $text;
  49932. }
  49933. public function __construct($decorated = false, array $styles = array())
  49934. {
  49935. $this->decorated = (bool) $decorated;
  49936. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  49937. $this->setStyle('info', new OutputFormatterStyle('green'));
  49938. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  49939. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  49940. foreach ($styles as $name => $style) {
  49941. $this->setStyle($name, $style);
  49942. }
  49943. $this->styleStack = new OutputFormatterStyleStack();
  49944. }
  49945. public function setDecorated($decorated)
  49946. {
  49947. $this->decorated = (bool) $decorated;
  49948. }
  49949. public function isDecorated()
  49950. {
  49951. return $this->decorated;
  49952. }
  49953. public function setStyle($name, OutputFormatterStyleInterface $style)
  49954. {
  49955. $this->styles[strtolower($name)] = $style;
  49956. }
  49957. public function hasStyle($name)
  49958. {
  49959. return isset($this->styles[strtolower($name)]);
  49960. }
  49961. public function getStyle($name)
  49962. {
  49963. if (!$this->hasStyle($name)) {
  49964. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  49965. }
  49966. return $this->styles[strtolower($name)];
  49967. }
  49968. public function format($message)
  49969. {
  49970. $message = (string) $message;
  49971. $offset = 0;
  49972. $output = '';
  49973. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  49974. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  49975. foreach ($matches[0] as $i => $match) {
  49976. $pos = $match[1];
  49977. $text = $match[0];
  49978. if (0 != $pos && '\\' == $message[$pos - 1]) {
  49979. continue;
  49980. }
  49981. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  49982. $offset = $pos + \strlen($text);
  49983. if ($open = '/' != $text[1]) {
  49984. $tag = $matches[1][$i][0];
  49985. } else {
  49986. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  49987. }
  49988. if (!$open && !$tag) {
  49989. $this->styleStack->pop();
  49990. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  49991. $output .= $this->applyCurrentStyle($text);
  49992. } elseif ($open) {
  49993. $this->styleStack->push($style);
  49994. } else {
  49995. $this->styleStack->pop($style);
  49996. }
  49997. }
  49998. $output .= $this->applyCurrentStyle(substr($message, $offset));
  49999. if (false !== strpos($output, "\0")) {
  50000. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  50001. }
  50002. return str_replace('\\<', '<', $output);
  50003. }
  50004. public function getStyleStack()
  50005. {
  50006. return $this->styleStack;
  50007. }
  50008. private function createStyleFromString($string)
  50009. {
  50010. if (isset($this->styles[$string])) {
  50011. return $this->styles[$string];
  50012. }
  50013. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  50014. return false;
  50015. }
  50016. $style = new OutputFormatterStyle();
  50017. foreach ($matches as $match) {
  50018. array_shift($match);
  50019. if ('fg' == $match[0]) {
  50020. $style->setForeground($match[1]);
  50021. } elseif ('bg' == $match[0]) {
  50022. $style->setBackground($match[1]);
  50023. } else {
  50024. try {
  50025. $style->setOption($match[1]);
  50026. } catch (\InvalidArgumentException $e) {
  50027. return false;
  50028. }
  50029. }
  50030. }
  50031. return $style;
  50032. }
  50033. private function applyCurrentStyle($text)
  50034. {
  50035. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  50036. }
  50037. }
  50038. <?php
  50039. namespace Symfony\Component\Console\Formatter;
  50040. interface OutputFormatterInterface
  50041. {
  50042. public function setDecorated($decorated);
  50043. public function isDecorated();
  50044. public function setStyle($name, OutputFormatterStyleInterface $style);
  50045. public function hasStyle($name);
  50046. public function getStyle($name);
  50047. public function format($message);
  50048. }
  50049. <?php
  50050. namespace Symfony\Component\Console\Formatter;
  50051. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50052. class OutputFormatterStyle implements OutputFormatterStyleInterface
  50053. {
  50054. private static $availableForegroundColors = array(
  50055. 'black' => array('set' => 30, 'unset' => 39),
  50056. 'red' => array('set' => 31, 'unset' => 39),
  50057. 'green' => array('set' => 32, 'unset' => 39),
  50058. 'yellow' => array('set' => 33, 'unset' => 39),
  50059. 'blue' => array('set' => 34, 'unset' => 39),
  50060. 'magenta' => array('set' => 35, 'unset' => 39),
  50061. 'cyan' => array('set' => 36, 'unset' => 39),
  50062. 'white' => array('set' => 37, 'unset' => 39),
  50063. 'default' => array('set' => 39, 'unset' => 39),
  50064. );
  50065. private static $availableBackgroundColors = array(
  50066. 'black' => array('set' => 40, 'unset' => 49),
  50067. 'red' => array('set' => 41, 'unset' => 49),
  50068. 'green' => array('set' => 42, 'unset' => 49),
  50069. 'yellow' => array('set' => 43, 'unset' => 49),
  50070. 'blue' => array('set' => 44, 'unset' => 49),
  50071. 'magenta' => array('set' => 45, 'unset' => 49),
  50072. 'cyan' => array('set' => 46, 'unset' => 49),
  50073. 'white' => array('set' => 47, 'unset' => 49),
  50074. 'default' => array('set' => 49, 'unset' => 49),
  50075. );
  50076. private static $availableOptions = array(
  50077. 'bold' => array('set' => 1, 'unset' => 22),
  50078. 'underscore' => array('set' => 4, 'unset' => 24),
  50079. 'blink' => array('set' => 5, 'unset' => 25),
  50080. 'reverse' => array('set' => 7, 'unset' => 27),
  50081. 'conceal' => array('set' => 8, 'unset' => 28),
  50082. );
  50083. private $foreground;
  50084. private $background;
  50085. private $options = array();
  50086. public function __construct($foreground = null, $background = null, array $options = array())
  50087. {
  50088. if (null !== $foreground) {
  50089. $this->setForeground($foreground);
  50090. }
  50091. if (null !== $background) {
  50092. $this->setBackground($background);
  50093. }
  50094. if (\count($options)) {
  50095. $this->setOptions($options);
  50096. }
  50097. }
  50098. public function setForeground($color = null)
  50099. {
  50100. if (null === $color) {
  50101. $this->foreground = null;
  50102. return;
  50103. }
  50104. if (!isset(static::$availableForegroundColors[$color])) {
  50105. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  50106. }
  50107. $this->foreground = static::$availableForegroundColors[$color];
  50108. }
  50109. public function setBackground($color = null)
  50110. {
  50111. if (null === $color) {
  50112. $this->background = null;
  50113. return;
  50114. }
  50115. if (!isset(static::$availableBackgroundColors[$color])) {
  50116. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  50117. }
  50118. $this->background = static::$availableBackgroundColors[$color];
  50119. }
  50120. public function setOption($option)
  50121. {
  50122. if (!isset(static::$availableOptions[$option])) {
  50123. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  50124. }
  50125. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  50126. $this->options[] = static::$availableOptions[$option];
  50127. }
  50128. }
  50129. public function unsetOption($option)
  50130. {
  50131. if (!isset(static::$availableOptions[$option])) {
  50132. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  50133. }
  50134. $pos = array_search(static::$availableOptions[$option], $this->options);
  50135. if (false !== $pos) {
  50136. unset($this->options[$pos]);
  50137. }
  50138. }
  50139. public function setOptions(array $options)
  50140. {
  50141. $this->options = array();
  50142. foreach ($options as $option) {
  50143. $this->setOption($option);
  50144. }
  50145. }
  50146. public function apply($text)
  50147. {
  50148. $setCodes = array();
  50149. $unsetCodes = array();
  50150. if (null !== $this->foreground) {
  50151. $setCodes[] = $this->foreground['set'];
  50152. $unsetCodes[] = $this->foreground['unset'];
  50153. }
  50154. if (null !== $this->background) {
  50155. $setCodes[] = $this->background['set'];
  50156. $unsetCodes[] = $this->background['unset'];
  50157. }
  50158. if (\count($this->options)) {
  50159. foreach ($this->options as $option) {
  50160. $setCodes[] = $option['set'];
  50161. $unsetCodes[] = $option['unset'];
  50162. }
  50163. }
  50164. if (0 === \count($setCodes)) {
  50165. return $text;
  50166. }
  50167. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  50168. }
  50169. }
  50170. <?php
  50171. namespace Symfony\Component\Console\Formatter;
  50172. interface OutputFormatterStyleInterface
  50173. {
  50174. public function setForeground($color = null);
  50175. public function setBackground($color = null);
  50176. public function setOption($option);
  50177. public function unsetOption($option);
  50178. public function setOptions(array $options);
  50179. public function apply($text);
  50180. }
  50181. <?php
  50182. namespace Symfony\Component\Console\Formatter;
  50183. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50184. class OutputFormatterStyleStack
  50185. {
  50186. private $styles;
  50187. private $emptyStyle;
  50188. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  50189. {
  50190. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  50191. $this->reset();
  50192. }
  50193. public function reset()
  50194. {
  50195. $this->styles = array();
  50196. }
  50197. public function push(OutputFormatterStyleInterface $style)
  50198. {
  50199. $this->styles[] = $style;
  50200. }
  50201. public function pop(OutputFormatterStyleInterface $style = null)
  50202. {
  50203. if (empty($this->styles)) {
  50204. return $this->emptyStyle;
  50205. }
  50206. if (null === $style) {
  50207. return array_pop($this->styles);
  50208. }
  50209. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  50210. if ($style->apply('') === $stackedStyle->apply('')) {
  50211. $this->styles = \array_slice($this->styles, 0, $index);
  50212. return $stackedStyle;
  50213. }
  50214. }
  50215. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  50216. }
  50217. public function getCurrent()
  50218. {
  50219. if (empty($this->styles)) {
  50220. return $this->emptyStyle;
  50221. }
  50222. return $this->styles[\count($this->styles) - 1];
  50223. }
  50224. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  50225. {
  50226. $this->emptyStyle = $emptyStyle;
  50227. return $this;
  50228. }
  50229. public function getEmptyStyle()
  50230. {
  50231. return $this->emptyStyle;
  50232. }
  50233. }
  50234. <?php
  50235. namespace Symfony\Component\Console\Helper;
  50236. class DebugFormatterHelper extends Helper
  50237. {
  50238. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  50239. private $started = array();
  50240. private $count = -1;
  50241. public function start($id, $message, $prefix = 'RUN')
  50242. {
  50243. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  50244. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  50245. }
  50246. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  50247. {
  50248. $message = '';
  50249. if ($error) {
  50250. if (isset($this->started[$id]['out'])) {
  50251. $message .= "\n";
  50252. unset($this->started[$id]['out']);
  50253. }
  50254. if (!isset($this->started[$id]['err'])) {
  50255. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  50256. $this->started[$id]['err'] = true;
  50257. }
  50258. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  50259. } else {
  50260. if (isset($this->started[$id]['err'])) {
  50261. $message .= "\n";
  50262. unset($this->started[$id]['err']);
  50263. }
  50264. if (!isset($this->started[$id]['out'])) {
  50265. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  50266. $this->started[$id]['out'] = true;
  50267. }
  50268. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  50269. }
  50270. return $message;
  50271. }
  50272. public function stop($id, $message, $successful, $prefix = 'RES')
  50273. {
  50274. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  50275. if ($successful) {
  50276. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  50277. }
  50278. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  50279. unset($this->started[$id]['out'], $this->started[$id]['err']);
  50280. return $message;
  50281. }
  50282. private function getBorder($id)
  50283. {
  50284. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  50285. }
  50286. public function getName()
  50287. {
  50288. return 'debug_formatter';
  50289. }
  50290. }
  50291. <?php
  50292. namespace Symfony\Component\Console\Helper;
  50293. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  50294. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  50295. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  50296. use Symfony\Component\Console\Descriptor\TextDescriptor;
  50297. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  50298. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50299. use Symfony\Component\Console\Output\OutputInterface;
  50300. class DescriptorHelper extends Helper
  50301. {
  50302. private $descriptors = array();
  50303. public function __construct()
  50304. {
  50305. $this
  50306. ->register('txt', new TextDescriptor())
  50307. ->register('xml', new XmlDescriptor())
  50308. ->register('json', new JsonDescriptor())
  50309. ->register('md', new MarkdownDescriptor())
  50310. ;
  50311. }
  50312. public function describe(OutputInterface $output, $object, array $options = array())
  50313. {
  50314. $options = array_merge(array(
  50315. 'raw_text' => false,
  50316. 'format' => 'txt',
  50317. ), $options);
  50318. if (!isset($this->descriptors[$options['format']])) {
  50319. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  50320. }
  50321. $descriptor = $this->descriptors[$options['format']];
  50322. $descriptor->describe($output, $object, $options);
  50323. }
  50324. public function register($format, DescriptorInterface $descriptor)
  50325. {
  50326. $this->descriptors[$format] = $descriptor;
  50327. return $this;
  50328. }
  50329. public function getName()
  50330. {
  50331. return 'descriptor';
  50332. }
  50333. }
  50334. <?php
  50335. namespace Symfony\Component\Console\Helper;
  50336. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50337. use Symfony\Component\Console\Exception\RuntimeException;
  50338. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  50339. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50340. use Symfony\Component\Console\Output\OutputInterface;
  50341. class DialogHelper extends InputAwareHelper
  50342. {
  50343. private $inputStream;
  50344. private static $shell;
  50345. private static $stty;
  50346. public function __construct($triggerDeprecationError = true)
  50347. {
  50348. if ($triggerDeprecationError) {
  50349. @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);
  50350. }
  50351. }
  50352. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  50353. {
  50354. if ($output instanceof ConsoleOutputInterface) {
  50355. $output = $output->getErrorOutput();
  50356. }
  50357. $width = max(array_map('strlen', array_keys($choices)));
  50358. $messages = (array) $question;
  50359. foreach ($choices as $key => $value) {
  50360. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  50361. }
  50362. $output->writeln($messages);
  50363. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  50364. $selectedChoices = str_replace(' ', '', $picked);
  50365. if ($multiselect) {
  50366. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  50367. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  50368. }
  50369. $selectedChoices = explode(',', $selectedChoices);
  50370. } else {
  50371. $selectedChoices = array($picked);
  50372. }
  50373. $multiselectChoices = array();
  50374. foreach ($selectedChoices as $value) {
  50375. if (empty($choices[$value])) {
  50376. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  50377. }
  50378. $multiselectChoices[] = $value;
  50379. }
  50380. if ($multiselect) {
  50381. return $multiselectChoices;
  50382. }
  50383. return $picked;
  50384. }, $attempts, $default);
  50385. return $result;
  50386. }
  50387. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  50388. {
  50389. if ($this->input && !$this->input->isInteractive()) {
  50390. return $default;
  50391. }
  50392. if ($output instanceof ConsoleOutputInterface) {
  50393. $output = $output->getErrorOutput();
  50394. }
  50395. $output->write($question);
  50396. $inputStream = $this->inputStream ?: STDIN;
  50397. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  50398. $ret = fgets($inputStream, 4096);
  50399. if (false === $ret) {
  50400. throw new RuntimeException('Aborted');
  50401. }
  50402. $ret = trim($ret);
  50403. } else {
  50404. $ret = '';
  50405. $i = 0;
  50406. $ofs = -1;
  50407. $matches = $autocomplete;
  50408. $numMatches = \count($matches);
  50409. $sttyMode = shell_exec('stty -g');
  50410. shell_exec('stty -icanon -echo');
  50411. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  50412. while (!feof($inputStream)) {
  50413. $c = fread($inputStream, 1);
  50414. if ("\177" === $c) {
  50415. if (0 === $numMatches && 0 !== $i) {
  50416. --$i;
  50417. $output->write("\033[1D");
  50418. }
  50419. if (0 === $i) {
  50420. $ofs = -1;
  50421. $matches = $autocomplete;
  50422. $numMatches = \count($matches);
  50423. } else {
  50424. $numMatches = 0;
  50425. }
  50426. $ret = substr($ret, 0, $i);
  50427. } elseif ("\033" === $c) {
  50428. $c .= fread($inputStream, 2);
  50429. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  50430. if ('A' === $c[2] && -1 === $ofs) {
  50431. $ofs = 0;
  50432. }
  50433. if (0 === $numMatches) {
  50434. continue;
  50435. }
  50436. $ofs += ('A' === $c[2]) ? -1 : 1;
  50437. $ofs = ($numMatches + $ofs) % $numMatches;
  50438. }
  50439. } elseif (\ord($c) < 32) {
  50440. if ("\t" === $c || "\n" === $c) {
  50441. if ($numMatches > 0 && -1 !== $ofs) {
  50442. $ret = $matches[$ofs];
  50443. $output->write(substr($ret, $i));
  50444. $i = \strlen($ret);
  50445. }
  50446. if ("\n" === $c) {
  50447. $output->write($c);
  50448. break;
  50449. }
  50450. $numMatches = 0;
  50451. }
  50452. continue;
  50453. } else {
  50454. $output->write($c);
  50455. $ret .= $c;
  50456. ++$i;
  50457. $numMatches = 0;
  50458. $ofs = 0;
  50459. foreach ($autocomplete as $value) {
  50460. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  50461. $matches[$numMatches++] = $value;
  50462. }
  50463. }
  50464. }
  50465. $output->write("\033[K");
  50466. if ($numMatches > 0 && -1 !== $ofs) {
  50467. $output->write("\0337");
  50468. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  50469. $output->write("\0338");
  50470. }
  50471. }
  50472. shell_exec(sprintf('stty %s', $sttyMode));
  50473. }
  50474. return \strlen($ret) > 0 ? $ret : $default;
  50475. }
  50476. public function askConfirmation(OutputInterface $output, $question, $default = true)
  50477. {
  50478. $answer = 'z';
  50479. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  50480. $answer = $this->ask($output, $question);
  50481. }
  50482. if (false === $default) {
  50483. return $answer && 'y' == strtolower($answer[0]);
  50484. }
  50485. return !$answer || 'y' == strtolower($answer[0]);
  50486. }
  50487. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  50488. {
  50489. if ($output instanceof ConsoleOutputInterface) {
  50490. $output = $output->getErrorOutput();
  50491. }
  50492. if ('\\' === \DIRECTORY_SEPARATOR) {
  50493. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  50494. if ('phar:' === substr(__FILE__, 0, 5)) {
  50495. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  50496. copy($exe, $tmpExe);
  50497. $exe = $tmpExe;
  50498. }
  50499. $output->write($question);
  50500. $value = rtrim(shell_exec($exe));
  50501. $output->writeln('');
  50502. if (isset($tmpExe)) {
  50503. unlink($tmpExe);
  50504. }
  50505. return $value;
  50506. }
  50507. if ($this->hasSttyAvailable()) {
  50508. $output->write($question);
  50509. $sttyMode = shell_exec('stty -g');
  50510. shell_exec('stty -echo');
  50511. $value = fgets($this->inputStream ?: STDIN, 4096);
  50512. shell_exec(sprintf('stty %s', $sttyMode));
  50513. if (false === $value) {
  50514. throw new RuntimeException('Aborted');
  50515. }
  50516. $value = trim($value);
  50517. $output->writeln('');
  50518. return $value;
  50519. }
  50520. if (false !== $shell = $this->getShell()) {
  50521. $output->write($question);
  50522. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  50523. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  50524. $value = rtrim(shell_exec($command));
  50525. $output->writeln('');
  50526. return $value;
  50527. }
  50528. if ($fallback) {
  50529. return $this->ask($output, $question);
  50530. }
  50531. throw new RuntimeException('Unable to hide the response');
  50532. }
  50533. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  50534. {
  50535. $that = $this;
  50536. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  50537. return $that->ask($output, $question, $default, $autocomplete);
  50538. };
  50539. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  50540. }
  50541. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  50542. {
  50543. $that = $this;
  50544. $interviewer = function () use ($output, $question, $fallback, $that) {
  50545. return $that->askHiddenResponse($output, $question, $fallback);
  50546. };
  50547. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  50548. }
  50549. public function setInputStream($stream)
  50550. {
  50551. $this->inputStream = $stream;
  50552. }
  50553. public function getInputStream()
  50554. {
  50555. return $this->inputStream;
  50556. }
  50557. public function getName()
  50558. {
  50559. return 'dialog';
  50560. }
  50561. private function getShell()
  50562. {
  50563. if (null !== self::$shell) {
  50564. return self::$shell;
  50565. }
  50566. self::$shell = false;
  50567. if (file_exists('/usr/bin/env')) {
  50568. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  50569. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  50570. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  50571. self::$shell = $sh;
  50572. break;
  50573. }
  50574. }
  50575. }
  50576. return self::$shell;
  50577. }
  50578. private function hasSttyAvailable()
  50579. {
  50580. if (null !== self::$stty) {
  50581. return self::$stty;
  50582. }
  50583. exec('stty 2>&1', $output, $exitcode);
  50584. return self::$stty = 0 === $exitcode;
  50585. }
  50586. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  50587. {
  50588. if ($output instanceof ConsoleOutputInterface) {
  50589. $output = $output->getErrorOutput();
  50590. }
  50591. $e = null;
  50592. while (false === $attempts || $attempts--) {
  50593. if (null !== $e) {
  50594. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  50595. }
  50596. try {
  50597. return \call_user_func($validator, $interviewer());
  50598. } catch (\Exception $e) {
  50599. }
  50600. }
  50601. throw $e;
  50602. }
  50603. }
  50604. <?php
  50605. namespace Symfony\Component\Console\Helper;
  50606. use Symfony\Component\Console\Formatter\OutputFormatter;
  50607. class FormatterHelper extends Helper
  50608. {
  50609. public function formatSection($section, $message, $style = 'info')
  50610. {
  50611. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  50612. }
  50613. public function formatBlock($messages, $style, $large = false)
  50614. {
  50615. if (!\is_array($messages)) {
  50616. $messages = array($messages);
  50617. }
  50618. $len = 0;
  50619. $lines = array();
  50620. foreach ($messages as $message) {
  50621. $message = OutputFormatter::escape($message);
  50622. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  50623. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  50624. }
  50625. $messages = $large ? array(str_repeat(' ', $len)) : array();
  50626. for ($i = 0; isset($lines[$i]); ++$i) {
  50627. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  50628. }
  50629. if ($large) {
  50630. $messages[] = str_repeat(' ', $len);
  50631. }
  50632. for ($i = 0; isset($messages[$i]); ++$i) {
  50633. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  50634. }
  50635. return implode("\n", $messages);
  50636. }
  50637. public function getName()
  50638. {
  50639. return 'formatter';
  50640. }
  50641. }
  50642. <?php
  50643. namespace Symfony\Component\Console\Helper;
  50644. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  50645. abstract class Helper implements HelperInterface
  50646. {
  50647. protected $helperSet = null;
  50648. public function setHelperSet(HelperSet $helperSet = null)
  50649. {
  50650. $this->helperSet = $helperSet;
  50651. }
  50652. public function getHelperSet()
  50653. {
  50654. return $this->helperSet;
  50655. }
  50656. public static function strlen($string)
  50657. {
  50658. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  50659. return \strlen($string);
  50660. }
  50661. return mb_strwidth($string, $encoding);
  50662. }
  50663. public static function formatTime($secs)
  50664. {
  50665. static $timeFormats = array(
  50666. array(0, '< 1 sec'),
  50667. array(1, '1 sec'),
  50668. array(2, 'secs', 1),
  50669. array(60, '1 min'),
  50670. array(120, 'mins', 60),
  50671. array(3600, '1 hr'),
  50672. array(7200, 'hrs', 3600),
  50673. array(86400, '1 day'),
  50674. array(172800, 'days', 86400),
  50675. );
  50676. foreach ($timeFormats as $index => $format) {
  50677. if ($secs >= $format[0]) {
  50678. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  50679. || $index == \count($timeFormats) - 1
  50680. ) {
  50681. if (2 == \count($format)) {
  50682. return $format[1];
  50683. }
  50684. return floor($secs / $format[2]).' '.$format[1];
  50685. }
  50686. }
  50687. }
  50688. }
  50689. public static function formatMemory($memory)
  50690. {
  50691. if ($memory >= 1024 * 1024 * 1024) {
  50692. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  50693. }
  50694. if ($memory >= 1024 * 1024) {
  50695. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  50696. }
  50697. if ($memory >= 1024) {
  50698. return sprintf('%d KiB', $memory / 1024);
  50699. }
  50700. return sprintf('%d B', $memory);
  50701. }
  50702. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  50703. {
  50704. return self::strlen(self::removeDecoration($formatter, $string));
  50705. }
  50706. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  50707. {
  50708. $isDecorated = $formatter->isDecorated();
  50709. $formatter->setDecorated(false);
  50710. $string = $formatter->format($string);
  50711. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  50712. $formatter->setDecorated($isDecorated);
  50713. return $string;
  50714. }
  50715. }
  50716. <?php
  50717. namespace Symfony\Component\Console\Helper;
  50718. interface HelperInterface
  50719. {
  50720. public function setHelperSet(HelperSet $helperSet = null);
  50721. public function getHelperSet();
  50722. public function getName();
  50723. }
  50724. <?php
  50725. namespace Symfony\Component\Console\Helper;
  50726. use Symfony\Component\Console\Command\Command;
  50727. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50728. class HelperSet implements \IteratorAggregate
  50729. {
  50730. private $helpers = array();
  50731. private $command;
  50732. public function __construct(array $helpers = array())
  50733. {
  50734. foreach ($helpers as $alias => $helper) {
  50735. $this->set($helper, \is_int($alias) ? null : $alias);
  50736. }
  50737. }
  50738. public function set(HelperInterface $helper, $alias = null)
  50739. {
  50740. $this->helpers[$helper->getName()] = $helper;
  50741. if (null !== $alias) {
  50742. $this->helpers[$alias] = $helper;
  50743. }
  50744. $helper->setHelperSet($this);
  50745. }
  50746. public function has($name)
  50747. {
  50748. return isset($this->helpers[$name]);
  50749. }
  50750. public function get($name)
  50751. {
  50752. if (!$this->has($name)) {
  50753. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  50754. }
  50755. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  50756. @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);
  50757. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  50758. @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);
  50759. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  50760. @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);
  50761. }
  50762. return $this->helpers[$name];
  50763. }
  50764. public function setCommand(Command $command = null)
  50765. {
  50766. $this->command = $command;
  50767. }
  50768. public function getCommand()
  50769. {
  50770. return $this->command;
  50771. }
  50772. public function getIterator()
  50773. {
  50774. return new \ArrayIterator($this->helpers);
  50775. }
  50776. }
  50777. <?php
  50778. namespace Symfony\Component\Console\Helper;
  50779. use Symfony\Component\Console\Input\InputAwareInterface;
  50780. use Symfony\Component\Console\Input\InputInterface;
  50781. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  50782. {
  50783. protected $input;
  50784. public function setInput(InputInterface $input)
  50785. {
  50786. $this->input = $input;
  50787. }
  50788. }
  50789. <?php
  50790. namespace Symfony\Component\Console\Helper;
  50791. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50792. use Symfony\Component\Console\Output\OutputInterface;
  50793. use Symfony\Component\Process\Exception\ProcessFailedException;
  50794. use Symfony\Component\Process\Process;
  50795. use Symfony\Component\Process\ProcessBuilder;
  50796. class ProcessHelper extends Helper
  50797. {
  50798. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  50799. {
  50800. if ($output instanceof ConsoleOutputInterface) {
  50801. $output = $output->getErrorOutput();
  50802. }
  50803. $formatter = $this->getHelperSet()->get('debug_formatter');
  50804. if (\is_array($cmd)) {
  50805. $process = ProcessBuilder::create($cmd)->getProcess();
  50806. } elseif ($cmd instanceof Process) {
  50807. $process = $cmd;
  50808. } else {
  50809. $process = new Process($cmd);
  50810. }
  50811. if ($verbosity <= $output->getVerbosity()) {
  50812. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  50813. }
  50814. if ($output->isDebug()) {
  50815. $callback = $this->wrapCallback($output, $process, $callback);
  50816. }
  50817. $process->run($callback);
  50818. if ($verbosity <= $output->getVerbosity()) {
  50819. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  50820. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  50821. }
  50822. if (!$process->isSuccessful() && null !== $error) {
  50823. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  50824. }
  50825. return $process;
  50826. }
  50827. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  50828. {
  50829. $process = $this->run($output, $cmd, $error, $callback);
  50830. if (!$process->isSuccessful()) {
  50831. throw new ProcessFailedException($process);
  50832. }
  50833. return $process;
  50834. }
  50835. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  50836. {
  50837. if ($output instanceof ConsoleOutputInterface) {
  50838. $output = $output->getErrorOutput();
  50839. }
  50840. $formatter = $this->getHelperSet()->get('debug_formatter');
  50841. $that = $this;
  50842. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  50843. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  50844. if (null !== $callback) {
  50845. \call_user_func($callback, $type, $buffer);
  50846. }
  50847. };
  50848. }
  50849. public function escapeString($str)
  50850. {
  50851. return str_replace('<', '\\<', $str);
  50852. }
  50853. public function getName()
  50854. {
  50855. return 'process';
  50856. }
  50857. }
  50858. <?php
  50859. namespace Symfony\Component\Console\Helper;
  50860. use Symfony\Component\Console\Exception\LogicException;
  50861. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50862. use Symfony\Component\Console\Output\OutputInterface;
  50863. class ProgressBar
  50864. {
  50865. private $barWidth = 28;
  50866. private $barChar;
  50867. private $emptyBarChar = '-';
  50868. private $progressChar = '>';
  50869. private $format;
  50870. private $internalFormat;
  50871. private $redrawFreq = 1;
  50872. private $output;
  50873. private $step = 0;
  50874. private $max;
  50875. private $startTime;
  50876. private $stepWidth;
  50877. private $percent = 0.0;
  50878. private $formatLineCount;
  50879. private $messages = array();
  50880. private $overwrite = true;
  50881. private $firstRun = true;
  50882. private static $formatters;
  50883. private static $formats;
  50884. public function __construct(OutputInterface $output, $max = 0)
  50885. {
  50886. if ($output instanceof ConsoleOutputInterface) {
  50887. $output = $output->getErrorOutput();
  50888. }
  50889. $this->output = $output;
  50890. $this->setMaxSteps($max);
  50891. if (!$this->output->isDecorated()) {
  50892. $this->overwrite = false;
  50893. $this->setRedrawFrequency($max / 10);
  50894. }
  50895. $this->startTime = time();
  50896. }
  50897. public static function setPlaceholderFormatterDefinition($name, $callable)
  50898. {
  50899. if (!self::$formatters) {
  50900. self::$formatters = self::initPlaceholderFormatters();
  50901. }
  50902. self::$formatters[$name] = $callable;
  50903. }
  50904. public static function getPlaceholderFormatterDefinition($name)
  50905. {
  50906. if (!self::$formatters) {
  50907. self::$formatters = self::initPlaceholderFormatters();
  50908. }
  50909. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  50910. }
  50911. public static function setFormatDefinition($name, $format)
  50912. {
  50913. if (!self::$formats) {
  50914. self::$formats = self::initFormats();
  50915. }
  50916. self::$formats[$name] = $format;
  50917. }
  50918. public static function getFormatDefinition($name)
  50919. {
  50920. if (!self::$formats) {
  50921. self::$formats = self::initFormats();
  50922. }
  50923. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  50924. }
  50925. public function setMessage($message, $name = 'message')
  50926. {
  50927. $this->messages[$name] = $message;
  50928. }
  50929. public function getMessage($name = 'message')
  50930. {
  50931. return $this->messages[$name];
  50932. }
  50933. public function getStartTime()
  50934. {
  50935. return $this->startTime;
  50936. }
  50937. public function getMaxSteps()
  50938. {
  50939. return $this->max;
  50940. }
  50941. public function getStep()
  50942. {
  50943. @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);
  50944. return $this->getProgress();
  50945. }
  50946. public function getProgress()
  50947. {
  50948. return $this->step;
  50949. }
  50950. public function getStepWidth()
  50951. {
  50952. return $this->stepWidth;
  50953. }
  50954. public function getProgressPercent()
  50955. {
  50956. return $this->percent;
  50957. }
  50958. public function setBarWidth($size)
  50959. {
  50960. $this->barWidth = (int) $size;
  50961. }
  50962. public function getBarWidth()
  50963. {
  50964. return $this->barWidth;
  50965. }
  50966. public function setBarCharacter($char)
  50967. {
  50968. $this->barChar = $char;
  50969. }
  50970. public function getBarCharacter()
  50971. {
  50972. if (null === $this->barChar) {
  50973. return $this->max ? '=' : $this->emptyBarChar;
  50974. }
  50975. return $this->barChar;
  50976. }
  50977. public function setEmptyBarCharacter($char)
  50978. {
  50979. $this->emptyBarChar = $char;
  50980. }
  50981. public function getEmptyBarCharacter()
  50982. {
  50983. return $this->emptyBarChar;
  50984. }
  50985. public function setProgressCharacter($char)
  50986. {
  50987. $this->progressChar = $char;
  50988. }
  50989. public function getProgressCharacter()
  50990. {
  50991. return $this->progressChar;
  50992. }
  50993. public function setFormat($format)
  50994. {
  50995. $this->format = null;
  50996. $this->internalFormat = $format;
  50997. }
  50998. public function setRedrawFrequency($freq)
  50999. {
  51000. $this->redrawFreq = max((int) $freq, 1);
  51001. }
  51002. public function start($max = null)
  51003. {
  51004. $this->startTime = time();
  51005. $this->step = 0;
  51006. $this->percent = 0.0;
  51007. if (null !== $max) {
  51008. $this->setMaxSteps($max);
  51009. }
  51010. $this->display();
  51011. }
  51012. public function advance($step = 1)
  51013. {
  51014. $this->setProgress($this->step + $step);
  51015. }
  51016. public function setCurrent($step)
  51017. {
  51018. @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);
  51019. $this->setProgress($step);
  51020. }
  51021. public function setOverwrite($overwrite)
  51022. {
  51023. $this->overwrite = (bool) $overwrite;
  51024. }
  51025. public function setProgress($step)
  51026. {
  51027. $step = (int) $step;
  51028. if ($step < $this->step) {
  51029. throw new LogicException('You can\'t regress the progress bar.');
  51030. }
  51031. if ($this->max && $step > $this->max) {
  51032. $this->max = $step;
  51033. }
  51034. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  51035. $currPeriod = (int) ($step / $this->redrawFreq);
  51036. $this->step = $step;
  51037. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  51038. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  51039. $this->display();
  51040. }
  51041. }
  51042. public function finish()
  51043. {
  51044. if (!$this->max) {
  51045. $this->max = $this->step;
  51046. }
  51047. if ($this->step === $this->max && !$this->overwrite) {
  51048. return;
  51049. }
  51050. $this->setProgress($this->max);
  51051. }
  51052. public function display()
  51053. {
  51054. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  51055. return;
  51056. }
  51057. if (null === $this->format) {
  51058. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  51059. }
  51060. $self = $this;
  51061. $output = $this->output;
  51062. $messages = $this->messages;
  51063. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  51064. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  51065. $text = \call_user_func($formatter, $self, $output);
  51066. } elseif (isset($messages[$matches[1]])) {
  51067. $text = $messages[$matches[1]];
  51068. } else {
  51069. return $matches[0];
  51070. }
  51071. if (isset($matches[2])) {
  51072. $text = sprintf('%'.$matches[2], $text);
  51073. }
  51074. return $text;
  51075. }, $this->format));
  51076. }
  51077. public function clear()
  51078. {
  51079. if (!$this->overwrite) {
  51080. return;
  51081. }
  51082. if (null === $this->format) {
  51083. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  51084. }
  51085. $this->overwrite('');
  51086. }
  51087. private function setRealFormat($format)
  51088. {
  51089. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  51090. $this->format = self::getFormatDefinition($format.'_nomax');
  51091. } elseif (null !== self::getFormatDefinition($format)) {
  51092. $this->format = self::getFormatDefinition($format);
  51093. } else {
  51094. $this->format = $format;
  51095. }
  51096. $this->formatLineCount = substr_count($this->format, "\n");
  51097. }
  51098. private function setMaxSteps($max)
  51099. {
  51100. $this->max = max(0, (int) $max);
  51101. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  51102. }
  51103. private function overwrite($message)
  51104. {
  51105. if ($this->overwrite) {
  51106. if (!$this->firstRun) {
  51107. $this->output->write("\x0D");
  51108. $this->output->write("\x1B[2K");
  51109. if ($this->formatLineCount > 0) {
  51110. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  51111. }
  51112. }
  51113. } elseif ($this->step > 0) {
  51114. $this->output->writeln('');
  51115. }
  51116. $this->firstRun = false;
  51117. $this->output->write($message);
  51118. }
  51119. private function determineBestFormat()
  51120. {
  51121. switch ($this->output->getVerbosity()) {
  51122. case OutputInterface::VERBOSITY_VERBOSE:
  51123. return $this->max ? 'verbose' : 'verbose_nomax';
  51124. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51125. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  51126. case OutputInterface::VERBOSITY_DEBUG:
  51127. return $this->max ? 'debug' : 'debug_nomax';
  51128. default:
  51129. return $this->max ? 'normal' : 'normal_nomax';
  51130. }
  51131. }
  51132. private static function initPlaceholderFormatters()
  51133. {
  51134. return array(
  51135. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  51136. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  51137. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  51138. if ($completeBars < $bar->getBarWidth()) {
  51139. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  51140. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  51141. }
  51142. return $display;
  51143. },
  51144. 'elapsed' => function (ProgressBar $bar) {
  51145. return Helper::formatTime(time() - $bar->getStartTime());
  51146. },
  51147. 'remaining' => function (ProgressBar $bar) {
  51148. if (!$bar->getMaxSteps()) {
  51149. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  51150. }
  51151. if (!$bar->getProgress()) {
  51152. $remaining = 0;
  51153. } else {
  51154. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  51155. }
  51156. return Helper::formatTime($remaining);
  51157. },
  51158. 'estimated' => function (ProgressBar $bar) {
  51159. if (!$bar->getMaxSteps()) {
  51160. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  51161. }
  51162. if (!$bar->getProgress()) {
  51163. $estimated = 0;
  51164. } else {
  51165. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  51166. }
  51167. return Helper::formatTime($estimated);
  51168. },
  51169. 'memory' => function (ProgressBar $bar) {
  51170. return Helper::formatMemory(memory_get_usage(true));
  51171. },
  51172. 'current' => function (ProgressBar $bar) {
  51173. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  51174. },
  51175. 'max' => function (ProgressBar $bar) {
  51176. return $bar->getMaxSteps();
  51177. },
  51178. 'percent' => function (ProgressBar $bar) {
  51179. return floor($bar->getProgressPercent() * 100);
  51180. },
  51181. );
  51182. }
  51183. private static function initFormats()
  51184. {
  51185. return array(
  51186. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  51187. 'normal_nomax' => ' %current% [%bar%]',
  51188. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  51189. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  51190. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  51191. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  51192. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  51193. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  51194. );
  51195. }
  51196. }
  51197. <?php
  51198. namespace Symfony\Component\Console\Helper;
  51199. use Symfony\Component\Console\Exception\LogicException;
  51200. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  51201. use Symfony\Component\Console\Output\NullOutput;
  51202. use Symfony\Component\Console\Output\OutputInterface;
  51203. class ProgressHelper extends Helper
  51204. {
  51205. const FORMAT_QUIET = ' %percent%%';
  51206. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  51207. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  51208. const FORMAT_QUIET_NOMAX = ' %current%';
  51209. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  51210. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  51211. private $barWidth = 28;
  51212. private $barChar = '=';
  51213. private $emptyBarChar = '-';
  51214. private $progressChar = '>';
  51215. private $format = null;
  51216. private $redrawFreq = 1;
  51217. private $lastMessagesLength;
  51218. private $barCharOriginal;
  51219. private $output;
  51220. private $current;
  51221. private $max;
  51222. private $startTime;
  51223. private $defaultFormatVars = array(
  51224. 'current',
  51225. 'max',
  51226. 'bar',
  51227. 'percent',
  51228. 'elapsed',
  51229. );
  51230. private $formatVars;
  51231. private $widths = array(
  51232. 'current' => 4,
  51233. 'max' => 4,
  51234. 'percent' => 3,
  51235. 'elapsed' => 6,
  51236. );
  51237. private $timeFormats = array(
  51238. array(0, '???'),
  51239. array(2, '1 sec'),
  51240. array(59, 'secs', 1),
  51241. array(60, '1 min'),
  51242. array(3600, 'mins', 60),
  51243. array(5400, '1 hr'),
  51244. array(86400, 'hrs', 3600),
  51245. array(129600, '1 day'),
  51246. array(604800, 'days', 86400),
  51247. );
  51248. public function __construct($triggerDeprecationError = true)
  51249. {
  51250. if ($triggerDeprecationError) {
  51251. @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);
  51252. }
  51253. }
  51254. public function setBarWidth($size)
  51255. {
  51256. $this->barWidth = (int) $size;
  51257. }
  51258. public function setBarCharacter($char)
  51259. {
  51260. $this->barChar = $char;
  51261. }
  51262. public function setEmptyBarCharacter($char)
  51263. {
  51264. $this->emptyBarChar = $char;
  51265. }
  51266. public function setProgressCharacter($char)
  51267. {
  51268. $this->progressChar = $char;
  51269. }
  51270. public function setFormat($format)
  51271. {
  51272. $this->format = $format;
  51273. }
  51274. public function setRedrawFrequency($freq)
  51275. {
  51276. $this->redrawFreq = (int) $freq;
  51277. }
  51278. public function start(OutputInterface $output, $max = null)
  51279. {
  51280. if ($output instanceof ConsoleOutputInterface) {
  51281. $output = $output->getErrorOutput();
  51282. }
  51283. $this->startTime = time();
  51284. $this->current = 0;
  51285. $this->max = (int) $max;
  51286. $this->output = $output->isDecorated() ? $output : new NullOutput();
  51287. $this->lastMessagesLength = 0;
  51288. $this->barCharOriginal = '';
  51289. if (null === $this->format) {
  51290. switch ($output->getVerbosity()) {
  51291. case OutputInterface::VERBOSITY_QUIET:
  51292. $this->format = self::FORMAT_QUIET_NOMAX;
  51293. if ($this->max > 0) {
  51294. $this->format = self::FORMAT_QUIET;
  51295. }
  51296. break;
  51297. case OutputInterface::VERBOSITY_VERBOSE:
  51298. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51299. case OutputInterface::VERBOSITY_DEBUG:
  51300. $this->format = self::FORMAT_VERBOSE_NOMAX;
  51301. if ($this->max > 0) {
  51302. $this->format = self::FORMAT_VERBOSE;
  51303. }
  51304. break;
  51305. default:
  51306. $this->format = self::FORMAT_NORMAL_NOMAX;
  51307. if ($this->max > 0) {
  51308. $this->format = self::FORMAT_NORMAL;
  51309. }
  51310. break;
  51311. }
  51312. }
  51313. $this->initialize();
  51314. }
  51315. public function advance($step = 1, $redraw = false)
  51316. {
  51317. $this->setCurrent($this->current + $step, $redraw);
  51318. }
  51319. public function setCurrent($current, $redraw = false)
  51320. {
  51321. if (null === $this->startTime) {
  51322. throw new LogicException('You must start the progress bar before calling setCurrent().');
  51323. }
  51324. $current = (int) $current;
  51325. if ($current < $this->current) {
  51326. throw new LogicException('You can\'t regress the progress bar');
  51327. }
  51328. if (0 === $this->current) {
  51329. $redraw = true;
  51330. }
  51331. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  51332. $this->current = $current;
  51333. $currPeriod = (int) ($this->current / $this->redrawFreq);
  51334. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  51335. $this->display();
  51336. }
  51337. }
  51338. public function display($finish = false)
  51339. {
  51340. if (null === $this->startTime) {
  51341. throw new LogicException('You must start the progress bar before calling display().');
  51342. }
  51343. $message = $this->format;
  51344. foreach ($this->generate($finish) as $name => $value) {
  51345. $message = str_replace("%{$name}%", $value, $message);
  51346. }
  51347. $this->overwrite($this->output, $message);
  51348. }
  51349. public function clear()
  51350. {
  51351. $this->overwrite($this->output, '');
  51352. }
  51353. public function finish()
  51354. {
  51355. if (null === $this->startTime) {
  51356. throw new LogicException('You must start the progress bar before calling finish().');
  51357. }
  51358. if (null !== $this->startTime) {
  51359. if (!$this->max) {
  51360. $this->barChar = $this->barCharOriginal;
  51361. $this->display(true);
  51362. }
  51363. $this->startTime = null;
  51364. $this->output->writeln('');
  51365. $this->output = null;
  51366. }
  51367. }
  51368. private function initialize()
  51369. {
  51370. $this->formatVars = array();
  51371. foreach ($this->defaultFormatVars as $var) {
  51372. if (false !== strpos($this->format, "%{$var}%")) {
  51373. $this->formatVars[$var] = true;
  51374. }
  51375. }
  51376. if ($this->max > 0) {
  51377. $this->widths['max'] = $this->strlen($this->max);
  51378. $this->widths['current'] = $this->widths['max'];
  51379. } else {
  51380. $this->barCharOriginal = $this->barChar;
  51381. $this->barChar = $this->emptyBarChar;
  51382. }
  51383. }
  51384. private function generate($finish = false)
  51385. {
  51386. $vars = array();
  51387. $percent = 0;
  51388. if ($this->max > 0) {
  51389. $percent = (float) $this->current / $this->max;
  51390. }
  51391. if (isset($this->formatVars['bar'])) {
  51392. if ($this->max > 0) {
  51393. $completeBars = floor($percent * $this->barWidth);
  51394. } else {
  51395. if (!$finish) {
  51396. $completeBars = floor($this->current % $this->barWidth);
  51397. } else {
  51398. $completeBars = $this->barWidth;
  51399. }
  51400. }
  51401. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  51402. $bar = str_repeat($this->barChar, $completeBars);
  51403. if ($completeBars < $this->barWidth) {
  51404. $bar .= $this->progressChar;
  51405. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  51406. }
  51407. $vars['bar'] = $bar;
  51408. }
  51409. if (isset($this->formatVars['elapsed'])) {
  51410. $elapsed = time() - $this->startTime;
  51411. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  51412. }
  51413. if (isset($this->formatVars['current'])) {
  51414. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  51415. }
  51416. if (isset($this->formatVars['max'])) {
  51417. $vars['max'] = $this->max;
  51418. }
  51419. if (isset($this->formatVars['percent'])) {
  51420. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  51421. }
  51422. return $vars;
  51423. }
  51424. private function humaneTime($secs)
  51425. {
  51426. $text = '';
  51427. foreach ($this->timeFormats as $format) {
  51428. if ($secs < $format[0]) {
  51429. if (2 == \count($format)) {
  51430. $text = $format[1];
  51431. break;
  51432. } else {
  51433. $text = ceil($secs / $format[2]).' '.$format[1];
  51434. break;
  51435. }
  51436. }
  51437. }
  51438. return $text;
  51439. }
  51440. private function overwrite(OutputInterface $output, $message)
  51441. {
  51442. $length = $this->strlen($message);
  51443. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  51444. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  51445. }
  51446. $output->write("\x0D");
  51447. $output->write($message);
  51448. $this->lastMessagesLength = $this->strlen($message);
  51449. }
  51450. public function getName()
  51451. {
  51452. return 'progress';
  51453. }
  51454. }
  51455. <?php
  51456. namespace Symfony\Component\Console\Helper;
  51457. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51458. use Symfony\Component\Console\Exception\LogicException;
  51459. use Symfony\Component\Console\Output\OutputInterface;
  51460. class ProgressIndicator
  51461. {
  51462. private $output;
  51463. private $startTime;
  51464. private $format;
  51465. private $message;
  51466. private $indicatorValues;
  51467. private $indicatorCurrent;
  51468. private $indicatorChangeInterval;
  51469. private $indicatorUpdateTime;
  51470. private $started = false;
  51471. private static $formatters;
  51472. private static $formats;
  51473. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  51474. {
  51475. $this->output = $output;
  51476. if (null === $format) {
  51477. $format = $this->determineBestFormat();
  51478. }
  51479. if (null === $indicatorValues) {
  51480. $indicatorValues = array('-', '\\', '|', '/');
  51481. }
  51482. $indicatorValues = array_values($indicatorValues);
  51483. if (2 > \count($indicatorValues)) {
  51484. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  51485. }
  51486. $this->format = self::getFormatDefinition($format);
  51487. $this->indicatorChangeInterval = $indicatorChangeInterval;
  51488. $this->indicatorValues = $indicatorValues;
  51489. $this->startTime = time();
  51490. }
  51491. public function setMessage($message)
  51492. {
  51493. $this->message = $message;
  51494. $this->display();
  51495. }
  51496. public function getMessage()
  51497. {
  51498. return $this->message;
  51499. }
  51500. public function getStartTime()
  51501. {
  51502. return $this->startTime;
  51503. }
  51504. public function getCurrentValue()
  51505. {
  51506. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  51507. }
  51508. public function start($message)
  51509. {
  51510. if ($this->started) {
  51511. throw new LogicException('Progress indicator already started.');
  51512. }
  51513. $this->message = $message;
  51514. $this->started = true;
  51515. $this->startTime = time();
  51516. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  51517. $this->indicatorCurrent = 0;
  51518. $this->display();
  51519. }
  51520. public function advance()
  51521. {
  51522. if (!$this->started) {
  51523. throw new LogicException('Progress indicator has not yet been started.');
  51524. }
  51525. if (!$this->output->isDecorated()) {
  51526. return;
  51527. }
  51528. $currentTime = $this->getCurrentTimeInMilliseconds();
  51529. if ($currentTime < $this->indicatorUpdateTime) {
  51530. return;
  51531. }
  51532. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  51533. ++$this->indicatorCurrent;
  51534. $this->display();
  51535. }
  51536. public function finish($message)
  51537. {
  51538. if (!$this->started) {
  51539. throw new LogicException('Progress indicator has not yet been started.');
  51540. }
  51541. $this->message = $message;
  51542. $this->display();
  51543. $this->output->writeln('');
  51544. $this->started = false;
  51545. }
  51546. public static function getFormatDefinition($name)
  51547. {
  51548. if (!self::$formats) {
  51549. self::$formats = self::initFormats();
  51550. }
  51551. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  51552. }
  51553. public static function setPlaceholderFormatterDefinition($name, $callable)
  51554. {
  51555. if (!self::$formatters) {
  51556. self::$formatters = self::initPlaceholderFormatters();
  51557. }
  51558. self::$formatters[$name] = $callable;
  51559. }
  51560. public static function getPlaceholderFormatterDefinition($name)
  51561. {
  51562. if (!self::$formatters) {
  51563. self::$formatters = self::initPlaceholderFormatters();
  51564. }
  51565. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  51566. }
  51567. private function display()
  51568. {
  51569. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  51570. return;
  51571. }
  51572. $self = $this;
  51573. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  51574. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  51575. return \call_user_func($formatter, $self);
  51576. }
  51577. return $matches[0];
  51578. }, $this->format));
  51579. }
  51580. private function determineBestFormat()
  51581. {
  51582. switch ($this->output->getVerbosity()) {
  51583. case OutputInterface::VERBOSITY_VERBOSE:
  51584. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  51585. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51586. case OutputInterface::VERBOSITY_DEBUG:
  51587. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  51588. default:
  51589. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  51590. }
  51591. }
  51592. private function overwrite($message)
  51593. {
  51594. if ($this->output->isDecorated()) {
  51595. $this->output->write("\x0D\x1B[2K");
  51596. $this->output->write($message);
  51597. } else {
  51598. $this->output->writeln($message);
  51599. }
  51600. }
  51601. private function getCurrentTimeInMilliseconds()
  51602. {
  51603. return round(microtime(true) * 1000);
  51604. }
  51605. private static function initPlaceholderFormatters()
  51606. {
  51607. return array(
  51608. 'indicator' => function (ProgressIndicator $indicator) {
  51609. return $indicator->getCurrentValue();
  51610. },
  51611. 'message' => function (ProgressIndicator $indicator) {
  51612. return $indicator->getMessage();
  51613. },
  51614. 'elapsed' => function (ProgressIndicator $indicator) {
  51615. return Helper::formatTime(time() - $indicator->getStartTime());
  51616. },
  51617. 'memory' => function () {
  51618. return Helper::formatMemory(memory_get_usage(true));
  51619. },
  51620. );
  51621. }
  51622. private static function initFormats()
  51623. {
  51624. return array(
  51625. 'normal' => ' %indicator% %message%',
  51626. 'normal_no_ansi' => ' %message%',
  51627. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  51628. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  51629. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  51630. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  51631. );
  51632. }
  51633. }
  51634. <?php
  51635. namespace Symfony\Component\Console\Helper;
  51636. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51637. use Symfony\Component\Console\Exception\RuntimeException;
  51638. use Symfony\Component\Console\Formatter\OutputFormatter;
  51639. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  51640. use Symfony\Component\Console\Input\InputInterface;
  51641. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  51642. use Symfony\Component\Console\Output\OutputInterface;
  51643. use Symfony\Component\Console\Question\ChoiceQuestion;
  51644. use Symfony\Component\Console\Question\Question;
  51645. class QuestionHelper extends Helper
  51646. {
  51647. private $inputStream;
  51648. private static $shell;
  51649. private static $stty;
  51650. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51651. {
  51652. if ($output instanceof ConsoleOutputInterface) {
  51653. $output = $output->getErrorOutput();
  51654. }
  51655. if (!$input->isInteractive()) {
  51656. $default = $question->getDefault();
  51657. if (null !== $default && $question instanceof ChoiceQuestion) {
  51658. $choices = $question->getChoices();
  51659. if (!$question->isMultiselect()) {
  51660. return isset($choices[$default]) ? $choices[$default] : $default;
  51661. }
  51662. $default = explode(',', $default);
  51663. foreach ($default as $k => $v) {
  51664. $v = trim($v);
  51665. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  51666. }
  51667. }
  51668. return $default;
  51669. }
  51670. if (!$question->getValidator()) {
  51671. return $this->doAsk($output, $question);
  51672. }
  51673. $that = $this;
  51674. $interviewer = function () use ($output, $question, $that) {
  51675. return $that->doAsk($output, $question);
  51676. };
  51677. return $this->validateAttempts($interviewer, $output, $question);
  51678. }
  51679. public function setInputStream($stream)
  51680. {
  51681. if (!\is_resource($stream)) {
  51682. throw new InvalidArgumentException('Input stream must be a valid resource.');
  51683. }
  51684. $this->inputStream = $stream;
  51685. }
  51686. public function getInputStream()
  51687. {
  51688. return $this->inputStream;
  51689. }
  51690. public function getName()
  51691. {
  51692. return 'question';
  51693. }
  51694. public function doAsk(OutputInterface $output, Question $question)
  51695. {
  51696. $this->writePrompt($output, $question);
  51697. $inputStream = $this->inputStream ?: STDIN;
  51698. $autocomplete = $question->getAutocompleterValues();
  51699. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  51700. $ret = false;
  51701. if ($question->isHidden()) {
  51702. try {
  51703. $ret = trim($this->getHiddenResponse($output, $inputStream));
  51704. } catch (RuntimeException $e) {
  51705. if (!$question->isHiddenFallback()) {
  51706. throw $e;
  51707. }
  51708. }
  51709. }
  51710. if (false === $ret) {
  51711. $ret = fgets($inputStream, 4096);
  51712. if (false === $ret) {
  51713. throw new RuntimeException('Aborted');
  51714. }
  51715. $ret = trim($ret);
  51716. }
  51717. } else {
  51718. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  51719. }
  51720. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  51721. if ($normalizer = $question->getNormalizer()) {
  51722. return $normalizer($ret);
  51723. }
  51724. return $ret;
  51725. }
  51726. protected function writePrompt(OutputInterface $output, Question $question)
  51727. {
  51728. $message = $question->getQuestion();
  51729. if ($question instanceof ChoiceQuestion) {
  51730. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  51731. $messages = (array) $question->getQuestion();
  51732. foreach ($question->getChoices() as $key => $value) {
  51733. $width = $maxWidth - $this->strlen($key);
  51734. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  51735. }
  51736. $output->writeln($messages);
  51737. $message = $question->getPrompt();
  51738. }
  51739. $output->write($message);
  51740. }
  51741. protected function writeError(OutputInterface $output, \Exception $error)
  51742. {
  51743. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  51744. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  51745. } else {
  51746. $message = '<error>'.$error->getMessage().'</error>';
  51747. }
  51748. $output->writeln($message);
  51749. }
  51750. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  51751. {
  51752. $ret = '';
  51753. $i = 0;
  51754. $ofs = -1;
  51755. $matches = $autocomplete;
  51756. $numMatches = \count($matches);
  51757. $sttyMode = shell_exec('stty -g');
  51758. shell_exec('stty -icanon -echo');
  51759. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  51760. while (!feof($inputStream)) {
  51761. $c = fread($inputStream, 1);
  51762. if ("\177" === $c) {
  51763. if (0 === $numMatches && 0 !== $i) {
  51764. --$i;
  51765. $output->write("\033[1D");
  51766. }
  51767. if (0 === $i) {
  51768. $ofs = -1;
  51769. $matches = $autocomplete;
  51770. $numMatches = \count($matches);
  51771. } else {
  51772. $numMatches = 0;
  51773. }
  51774. $ret = substr($ret, 0, $i);
  51775. } elseif ("\033" === $c) {
  51776. $c .= fread($inputStream, 2);
  51777. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  51778. if ('A' === $c[2] && -1 === $ofs) {
  51779. $ofs = 0;
  51780. }
  51781. if (0 === $numMatches) {
  51782. continue;
  51783. }
  51784. $ofs += ('A' === $c[2]) ? -1 : 1;
  51785. $ofs = ($numMatches + $ofs) % $numMatches;
  51786. }
  51787. } elseif (\ord($c) < 32) {
  51788. if ("\t" === $c || "\n" === $c) {
  51789. if ($numMatches > 0 && -1 !== $ofs) {
  51790. $ret = $matches[$ofs];
  51791. $output->write(substr($ret, $i));
  51792. $i = \strlen($ret);
  51793. }
  51794. if ("\n" === $c) {
  51795. $output->write($c);
  51796. break;
  51797. }
  51798. $numMatches = 0;
  51799. }
  51800. continue;
  51801. } else {
  51802. $output->write($c);
  51803. $ret .= $c;
  51804. ++$i;
  51805. $numMatches = 0;
  51806. $ofs = 0;
  51807. foreach ($autocomplete as $value) {
  51808. if (0 === strpos($value, $ret)) {
  51809. $matches[$numMatches++] = $value;
  51810. }
  51811. }
  51812. }
  51813. $output->write("\033[K");
  51814. if ($numMatches > 0 && -1 !== $ofs) {
  51815. $output->write("\0337");
  51816. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  51817. $output->write("\0338");
  51818. }
  51819. }
  51820. shell_exec(sprintf('stty %s', $sttyMode));
  51821. return $ret;
  51822. }
  51823. private function getHiddenResponse(OutputInterface $output, $inputStream)
  51824. {
  51825. if ('\\' === \DIRECTORY_SEPARATOR) {
  51826. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  51827. if ('phar:' === substr(__FILE__, 0, 5)) {
  51828. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  51829. copy($exe, $tmpExe);
  51830. $exe = $tmpExe;
  51831. }
  51832. $value = rtrim(shell_exec($exe));
  51833. $output->writeln('');
  51834. if (isset($tmpExe)) {
  51835. unlink($tmpExe);
  51836. }
  51837. return $value;
  51838. }
  51839. if ($this->hasSttyAvailable()) {
  51840. $sttyMode = shell_exec('stty -g');
  51841. shell_exec('stty -echo');
  51842. $value = fgets($inputStream, 4096);
  51843. shell_exec(sprintf('stty %s', $sttyMode));
  51844. if (false === $value) {
  51845. throw new RuntimeException('Aborted');
  51846. }
  51847. $value = trim($value);
  51848. $output->writeln('');
  51849. return $value;
  51850. }
  51851. if (false !== $shell = $this->getShell()) {
  51852. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  51853. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  51854. $value = rtrim(shell_exec($command));
  51855. $output->writeln('');
  51856. return $value;
  51857. }
  51858. throw new RuntimeException('Unable to hide the response.');
  51859. }
  51860. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  51861. {
  51862. $error = null;
  51863. $attempts = $question->getMaxAttempts();
  51864. while (null === $attempts || $attempts--) {
  51865. if (null !== $error) {
  51866. $this->writeError($output, $error);
  51867. }
  51868. try {
  51869. return \call_user_func($question->getValidator(), $interviewer());
  51870. } catch (RuntimeException $e) {
  51871. throw $e;
  51872. } catch (\Exception $error) {
  51873. }
  51874. }
  51875. throw $error;
  51876. }
  51877. private function getShell()
  51878. {
  51879. if (null !== self::$shell) {
  51880. return self::$shell;
  51881. }
  51882. self::$shell = false;
  51883. if (file_exists('/usr/bin/env')) {
  51884. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  51885. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  51886. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  51887. self::$shell = $sh;
  51888. break;
  51889. }
  51890. }
  51891. }
  51892. return self::$shell;
  51893. }
  51894. private function hasSttyAvailable()
  51895. {
  51896. if (null !== self::$stty) {
  51897. return self::$stty;
  51898. }
  51899. exec('stty 2>&1', $output, $exitcode);
  51900. return self::$stty = 0 === $exitcode;
  51901. }
  51902. }
  51903. <?php
  51904. namespace Symfony\Component\Console\Helper;
  51905. use Symfony\Component\Console\Exception\LogicException;
  51906. use Symfony\Component\Console\Formatter\OutputFormatter;
  51907. use Symfony\Component\Console\Input\InputInterface;
  51908. use Symfony\Component\Console\Output\OutputInterface;
  51909. use Symfony\Component\Console\Question\ChoiceQuestion;
  51910. use Symfony\Component\Console\Question\ConfirmationQuestion;
  51911. use Symfony\Component\Console\Question\Question;
  51912. use Symfony\Component\Console\Style\SymfonyStyle;
  51913. class SymfonyQuestionHelper extends QuestionHelper
  51914. {
  51915. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51916. {
  51917. $validator = $question->getValidator();
  51918. $question->setValidator(function ($value) use ($validator) {
  51919. if (null !== $validator) {
  51920. $value = $validator($value);
  51921. } else {
  51922. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  51923. throw new LogicException('A value is required.');
  51924. }
  51925. }
  51926. return $value;
  51927. });
  51928. return parent::ask($input, $output, $question);
  51929. }
  51930. protected function writePrompt(OutputInterface $output, Question $question)
  51931. {
  51932. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  51933. $default = $question->getDefault();
  51934. switch (true) {
  51935. case null === $default:
  51936. $text = sprintf(' <info>%s</info>:', $text);
  51937. break;
  51938. case $question instanceof ConfirmationQuestion:
  51939. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  51940. break;
  51941. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  51942. $choices = $question->getChoices();
  51943. $default = explode(',', $default);
  51944. foreach ($default as $key => $value) {
  51945. $default[$key] = $choices[trim($value)];
  51946. }
  51947. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  51948. break;
  51949. case $question instanceof ChoiceQuestion:
  51950. $choices = $question->getChoices();
  51951. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  51952. break;
  51953. default:
  51954. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  51955. }
  51956. $output->writeln($text);
  51957. if ($question instanceof ChoiceQuestion) {
  51958. $width = max(array_map('strlen', array_keys($question->getChoices())));
  51959. foreach ($question->getChoices() as $key => $value) {
  51960. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  51961. }
  51962. }
  51963. $output->write(' > ');
  51964. }
  51965. protected function writeError(OutputInterface $output, \Exception $error)
  51966. {
  51967. if ($output instanceof SymfonyStyle) {
  51968. $output->newLine();
  51969. $output->error($error->getMessage());
  51970. return;
  51971. }
  51972. parent::writeError($output, $error);
  51973. }
  51974. }
  51975. <?php
  51976. namespace Symfony\Component\Console\Helper;
  51977. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51978. use Symfony\Component\Console\Output\OutputInterface;
  51979. class Table
  51980. {
  51981. private $headers = array();
  51982. private $rows = array();
  51983. private $columnWidths = array();
  51984. private $numberOfColumns;
  51985. private $output;
  51986. private $style;
  51987. private $columnStyles = array();
  51988. private static $styles;
  51989. public function __construct(OutputInterface $output)
  51990. {
  51991. $this->output = $output;
  51992. if (!self::$styles) {
  51993. self::$styles = self::initStyles();
  51994. }
  51995. $this->setStyle('default');
  51996. }
  51997. public static function setStyleDefinition($name, TableStyle $style)
  51998. {
  51999. if (!self::$styles) {
  52000. self::$styles = self::initStyles();
  52001. }
  52002. self::$styles[$name] = $style;
  52003. }
  52004. public static function getStyleDefinition($name)
  52005. {
  52006. if (!self::$styles) {
  52007. self::$styles = self::initStyles();
  52008. }
  52009. if (isset(self::$styles[$name])) {
  52010. return self::$styles[$name];
  52011. }
  52012. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  52013. }
  52014. public function setStyle($name)
  52015. {
  52016. $this->style = $this->resolveStyle($name);
  52017. return $this;
  52018. }
  52019. public function getStyle()
  52020. {
  52021. return $this->style;
  52022. }
  52023. public function setColumnStyle($columnIndex, $name)
  52024. {
  52025. $columnIndex = (int) $columnIndex;
  52026. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  52027. return $this;
  52028. }
  52029. public function getColumnStyle($columnIndex)
  52030. {
  52031. if (isset($this->columnStyles[$columnIndex])) {
  52032. return $this->columnStyles[$columnIndex];
  52033. }
  52034. return $this->getStyle();
  52035. }
  52036. public function setHeaders(array $headers)
  52037. {
  52038. $headers = array_values($headers);
  52039. if (!empty($headers) && !\is_array($headers[0])) {
  52040. $headers = array($headers);
  52041. }
  52042. $this->headers = $headers;
  52043. return $this;
  52044. }
  52045. public function setRows(array $rows)
  52046. {
  52047. $this->rows = array();
  52048. return $this->addRows($rows);
  52049. }
  52050. public function addRows(array $rows)
  52051. {
  52052. foreach ($rows as $row) {
  52053. $this->addRow($row);
  52054. }
  52055. return $this;
  52056. }
  52057. public function addRow($row)
  52058. {
  52059. if ($row instanceof TableSeparator) {
  52060. $this->rows[] = $row;
  52061. return $this;
  52062. }
  52063. if (!\is_array($row)) {
  52064. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  52065. }
  52066. $this->rows[] = array_values($row);
  52067. return $this;
  52068. }
  52069. public function setRow($column, array $row)
  52070. {
  52071. $this->rows[$column] = $row;
  52072. return $this;
  52073. }
  52074. public function render()
  52075. {
  52076. $this->calculateNumberOfColumns();
  52077. $rows = $this->buildTableRows($this->rows);
  52078. $headers = $this->buildTableRows($this->headers);
  52079. $this->calculateColumnsWidth(array_merge($headers, $rows));
  52080. $this->renderRowSeparator();
  52081. if (!empty($headers)) {
  52082. foreach ($headers as $header) {
  52083. $this->renderRow($header, $this->style->getCellHeaderFormat());
  52084. $this->renderRowSeparator();
  52085. }
  52086. }
  52087. foreach ($rows as $row) {
  52088. if ($row instanceof TableSeparator) {
  52089. $this->renderRowSeparator();
  52090. } else {
  52091. $this->renderRow($row, $this->style->getCellRowFormat());
  52092. }
  52093. }
  52094. if (!empty($rows)) {
  52095. $this->renderRowSeparator();
  52096. }
  52097. $this->cleanup();
  52098. }
  52099. private function renderRowSeparator()
  52100. {
  52101. if (0 === $count = $this->numberOfColumns) {
  52102. return;
  52103. }
  52104. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  52105. return;
  52106. }
  52107. $markup = $this->style->getCrossingChar();
  52108. for ($column = 0; $column < $count; ++$column) {
  52109. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  52110. }
  52111. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  52112. }
  52113. private function renderColumnSeparator()
  52114. {
  52115. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  52116. }
  52117. private function renderRow(array $row, $cellFormat)
  52118. {
  52119. if (empty($row)) {
  52120. return;
  52121. }
  52122. $rowContent = $this->renderColumnSeparator();
  52123. foreach ($this->getRowColumns($row) as $column) {
  52124. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  52125. $rowContent .= $this->renderColumnSeparator();
  52126. }
  52127. $this->output->writeln($rowContent);
  52128. }
  52129. private function renderCell(array $row, $column, $cellFormat)
  52130. {
  52131. $cell = isset($row[$column]) ? $row[$column] : '';
  52132. $width = $this->columnWidths[$column];
  52133. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  52134. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  52135. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  52136. }
  52137. }
  52138. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  52139. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  52140. }
  52141. $style = $this->getColumnStyle($column);
  52142. if ($cell instanceof TableSeparator) {
  52143. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  52144. }
  52145. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  52146. $content = sprintf($style->getCellRowContentFormat(), $cell);
  52147. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  52148. }
  52149. private function calculateNumberOfColumns()
  52150. {
  52151. if (null !== $this->numberOfColumns) {
  52152. return;
  52153. }
  52154. $columns = array(0);
  52155. foreach (array_merge($this->headers, $this->rows) as $row) {
  52156. if ($row instanceof TableSeparator) {
  52157. continue;
  52158. }
  52159. $columns[] = $this->getNumberOfColumns($row);
  52160. }
  52161. $this->numberOfColumns = max($columns);
  52162. }
  52163. private function buildTableRows($rows)
  52164. {
  52165. $unmergedRows = array();
  52166. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  52167. $rows = $this->fillNextRows($rows, $rowKey);
  52168. foreach ($rows[$rowKey] as $column => $cell) {
  52169. if (!strstr($cell, "\n")) {
  52170. continue;
  52171. }
  52172. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  52173. foreach ($lines as $lineKey => $line) {
  52174. if ($cell instanceof TableCell) {
  52175. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  52176. }
  52177. if (0 === $lineKey) {
  52178. $rows[$rowKey][$column] = $line;
  52179. } else {
  52180. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  52181. }
  52182. }
  52183. }
  52184. }
  52185. $tableRows = array();
  52186. foreach ($rows as $rowKey => $row) {
  52187. $tableRows[] = $this->fillCells($row);
  52188. if (isset($unmergedRows[$rowKey])) {
  52189. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  52190. }
  52191. }
  52192. return $tableRows;
  52193. }
  52194. private function fillNextRows(array $rows, $line)
  52195. {
  52196. $unmergedRows = array();
  52197. foreach ($rows[$line] as $column => $cell) {
  52198. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  52199. $nbLines = $cell->getRowspan() - 1;
  52200. $lines = array($cell);
  52201. if (strstr($cell, "\n")) {
  52202. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  52203. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  52204. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  52205. unset($lines[0]);
  52206. }
  52207. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  52208. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  52209. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  52210. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  52211. if ($nbLines === $unmergedRowKey - $line) {
  52212. break;
  52213. }
  52214. }
  52215. }
  52216. }
  52217. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  52218. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  52219. foreach ($unmergedRow as $cellKey => $cell) {
  52220. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  52221. }
  52222. } else {
  52223. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  52224. foreach ($unmergedRow as $column => $cell) {
  52225. if (!empty($cell)) {
  52226. $row[$column] = $unmergedRow[$column];
  52227. }
  52228. }
  52229. array_splice($rows, $unmergedRowKey, 0, array($row));
  52230. }
  52231. }
  52232. return $rows;
  52233. }
  52234. private function fillCells($row)
  52235. {
  52236. $newRow = array();
  52237. foreach ($row as $column => $cell) {
  52238. $newRow[] = $cell;
  52239. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  52240. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  52241. $newRow[] = '';
  52242. }
  52243. }
  52244. }
  52245. return $newRow ?: $row;
  52246. }
  52247. private function copyRow(array $rows, $line)
  52248. {
  52249. $row = $rows[$line];
  52250. foreach ($row as $cellKey => $cellValue) {
  52251. $row[$cellKey] = '';
  52252. if ($cellValue instanceof TableCell) {
  52253. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  52254. }
  52255. }
  52256. return $row;
  52257. }
  52258. private function getNumberOfColumns(array $row)
  52259. {
  52260. $columns = \count($row);
  52261. foreach ($row as $column) {
  52262. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  52263. }
  52264. return $columns;
  52265. }
  52266. private function getRowColumns(array $row)
  52267. {
  52268. $columns = range(0, $this->numberOfColumns - 1);
  52269. foreach ($row as $cellKey => $cell) {
  52270. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  52271. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  52272. }
  52273. }
  52274. return $columns;
  52275. }
  52276. private function calculateColumnsWidth($rows)
  52277. {
  52278. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  52279. $lengths = array();
  52280. foreach ($rows as $row) {
  52281. if ($row instanceof TableSeparator) {
  52282. continue;
  52283. }
  52284. foreach ($row as $i => $cell) {
  52285. if ($cell instanceof TableCell) {
  52286. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  52287. $textLength = Helper::strlen($textContent);
  52288. if ($textLength > 0) {
  52289. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  52290. foreach ($contentColumns as $position => $content) {
  52291. $row[$i + $position] = $content;
  52292. }
  52293. }
  52294. }
  52295. }
  52296. $lengths[] = $this->getCellWidth($row, $column);
  52297. }
  52298. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  52299. }
  52300. }
  52301. private function getColumnSeparatorWidth()
  52302. {
  52303. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  52304. }
  52305. private function getCellWidth(array $row, $column)
  52306. {
  52307. if (isset($row[$column])) {
  52308. $cell = $row[$column];
  52309. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  52310. return $cellWidth;
  52311. }
  52312. return 0;
  52313. }
  52314. private function cleanup()
  52315. {
  52316. $this->columnWidths = array();
  52317. $this->numberOfColumns = null;
  52318. }
  52319. private static function initStyles()
  52320. {
  52321. $borderless = new TableStyle();
  52322. $borderless
  52323. ->setHorizontalBorderChar('=')
  52324. ->setVerticalBorderChar(' ')
  52325. ->setCrossingChar(' ')
  52326. ;
  52327. $compact = new TableStyle();
  52328. $compact
  52329. ->setHorizontalBorderChar('')
  52330. ->setVerticalBorderChar(' ')
  52331. ->setCrossingChar('')
  52332. ->setCellRowContentFormat('%s')
  52333. ;
  52334. $styleGuide = new TableStyle();
  52335. $styleGuide
  52336. ->setHorizontalBorderChar('-')
  52337. ->setVerticalBorderChar(' ')
  52338. ->setCrossingChar(' ')
  52339. ->setCellHeaderFormat('%s')
  52340. ;
  52341. return array(
  52342. 'default' => new TableStyle(),
  52343. 'borderless' => $borderless,
  52344. 'compact' => $compact,
  52345. 'symfony-style-guide' => $styleGuide,
  52346. );
  52347. }
  52348. private function resolveStyle($name)
  52349. {
  52350. if ($name instanceof TableStyle) {
  52351. return $name;
  52352. }
  52353. if (isset(self::$styles[$name])) {
  52354. return self::$styles[$name];
  52355. }
  52356. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  52357. }
  52358. }
  52359. <?php
  52360. namespace Symfony\Component\Console\Helper;
  52361. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52362. class TableCell
  52363. {
  52364. private $value;
  52365. private $options = array(
  52366. 'rowspan' => 1,
  52367. 'colspan' => 1,
  52368. );
  52369. public function __construct($value = '', array $options = array())
  52370. {
  52371. if (is_numeric($value) && !\is_string($value)) {
  52372. $value = (string) $value;
  52373. }
  52374. $this->value = $value;
  52375. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  52376. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  52377. }
  52378. $this->options = array_merge($this->options, $options);
  52379. }
  52380. public function __toString()
  52381. {
  52382. return $this->value;
  52383. }
  52384. public function getColspan()
  52385. {
  52386. return (int) $this->options['colspan'];
  52387. }
  52388. public function getRowspan()
  52389. {
  52390. return (int) $this->options['rowspan'];
  52391. }
  52392. }
  52393. <?php
  52394. namespace Symfony\Component\Console\Helper;
  52395. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52396. use Symfony\Component\Console\Output\NullOutput;
  52397. use Symfony\Component\Console\Output\OutputInterface;
  52398. class TableHelper extends Helper
  52399. {
  52400. const LAYOUT_DEFAULT = 0;
  52401. const LAYOUT_BORDERLESS = 1;
  52402. const LAYOUT_COMPACT = 2;
  52403. private $table;
  52404. public function __construct($triggerDeprecationError = true)
  52405. {
  52406. if ($triggerDeprecationError) {
  52407. @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);
  52408. }
  52409. $this->table = new Table(new NullOutput());
  52410. }
  52411. public function setLayout($layout)
  52412. {
  52413. switch ($layout) {
  52414. case self::LAYOUT_BORDERLESS:
  52415. $this->table->setStyle('borderless');
  52416. break;
  52417. case self::LAYOUT_COMPACT:
  52418. $this->table->setStyle('compact');
  52419. break;
  52420. case self::LAYOUT_DEFAULT:
  52421. $this->table->setStyle('default');
  52422. break;
  52423. default:
  52424. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  52425. }
  52426. return $this;
  52427. }
  52428. public function setHeaders(array $headers)
  52429. {
  52430. $this->table->setHeaders($headers);
  52431. return $this;
  52432. }
  52433. public function setRows(array $rows)
  52434. {
  52435. $this->table->setRows($rows);
  52436. return $this;
  52437. }
  52438. public function addRows(array $rows)
  52439. {
  52440. $this->table->addRows($rows);
  52441. return $this;
  52442. }
  52443. public function addRow(array $row)
  52444. {
  52445. $this->table->addRow($row);
  52446. return $this;
  52447. }
  52448. public function setRow($column, array $row)
  52449. {
  52450. $this->table->setRow($column, $row);
  52451. return $this;
  52452. }
  52453. public function setPaddingChar($paddingChar)
  52454. {
  52455. $this->table->getStyle()->setPaddingChar($paddingChar);
  52456. return $this;
  52457. }
  52458. public function setHorizontalBorderChar($horizontalBorderChar)
  52459. {
  52460. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  52461. return $this;
  52462. }
  52463. public function setVerticalBorderChar($verticalBorderChar)
  52464. {
  52465. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  52466. return $this;
  52467. }
  52468. public function setCrossingChar($crossingChar)
  52469. {
  52470. $this->table->getStyle()->setCrossingChar($crossingChar);
  52471. return $this;
  52472. }
  52473. public function setCellHeaderFormat($cellHeaderFormat)
  52474. {
  52475. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  52476. return $this;
  52477. }
  52478. public function setCellRowFormat($cellRowFormat)
  52479. {
  52480. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  52481. return $this;
  52482. }
  52483. public function setCellRowContentFormat($cellRowContentFormat)
  52484. {
  52485. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  52486. return $this;
  52487. }
  52488. public function setBorderFormat($borderFormat)
  52489. {
  52490. $this->table->getStyle()->setBorderFormat($borderFormat);
  52491. return $this;
  52492. }
  52493. public function setPadType($padType)
  52494. {
  52495. $this->table->getStyle()->setPadType($padType);
  52496. return $this;
  52497. }
  52498. public function render(OutputInterface $output)
  52499. {
  52500. $p = new \ReflectionProperty($this->table, 'output');
  52501. $p->setAccessible(true);
  52502. $p->setValue($this->table, $output);
  52503. $this->table->render();
  52504. }
  52505. public function getName()
  52506. {
  52507. return 'table';
  52508. }
  52509. }
  52510. <?php
  52511. namespace Symfony\Component\Console\Helper;
  52512. class TableSeparator extends TableCell
  52513. {
  52514. public function __construct(array $options = array())
  52515. {
  52516. parent::__construct('', $options);
  52517. }
  52518. }
  52519. <?php
  52520. namespace Symfony\Component\Console\Helper;
  52521. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52522. use Symfony\Component\Console\Exception\LogicException;
  52523. class TableStyle
  52524. {
  52525. private $paddingChar = ' ';
  52526. private $horizontalBorderChar = '-';
  52527. private $verticalBorderChar = '|';
  52528. private $crossingChar = '+';
  52529. private $cellHeaderFormat = '<info>%s</info>';
  52530. private $cellRowFormat = '%s';
  52531. private $cellRowContentFormat = ' %s ';
  52532. private $borderFormat = '%s';
  52533. private $padType = STR_PAD_RIGHT;
  52534. public function setPaddingChar($paddingChar)
  52535. {
  52536. if (!$paddingChar) {
  52537. throw new LogicException('The padding char must not be empty');
  52538. }
  52539. $this->paddingChar = $paddingChar;
  52540. return $this;
  52541. }
  52542. public function getPaddingChar()
  52543. {
  52544. return $this->paddingChar;
  52545. }
  52546. public function setHorizontalBorderChar($horizontalBorderChar)
  52547. {
  52548. $this->horizontalBorderChar = $horizontalBorderChar;
  52549. return $this;
  52550. }
  52551. public function getHorizontalBorderChar()
  52552. {
  52553. return $this->horizontalBorderChar;
  52554. }
  52555. public function setVerticalBorderChar($verticalBorderChar)
  52556. {
  52557. $this->verticalBorderChar = $verticalBorderChar;
  52558. return $this;
  52559. }
  52560. public function getVerticalBorderChar()
  52561. {
  52562. return $this->verticalBorderChar;
  52563. }
  52564. public function setCrossingChar($crossingChar)
  52565. {
  52566. $this->crossingChar = $crossingChar;
  52567. return $this;
  52568. }
  52569. public function getCrossingChar()
  52570. {
  52571. return $this->crossingChar;
  52572. }
  52573. public function setCellHeaderFormat($cellHeaderFormat)
  52574. {
  52575. $this->cellHeaderFormat = $cellHeaderFormat;
  52576. return $this;
  52577. }
  52578. public function getCellHeaderFormat()
  52579. {
  52580. return $this->cellHeaderFormat;
  52581. }
  52582. public function setCellRowFormat($cellRowFormat)
  52583. {
  52584. $this->cellRowFormat = $cellRowFormat;
  52585. return $this;
  52586. }
  52587. public function getCellRowFormat()
  52588. {
  52589. return $this->cellRowFormat;
  52590. }
  52591. public function setCellRowContentFormat($cellRowContentFormat)
  52592. {
  52593. $this->cellRowContentFormat = $cellRowContentFormat;
  52594. return $this;
  52595. }
  52596. public function getCellRowContentFormat()
  52597. {
  52598. return $this->cellRowContentFormat;
  52599. }
  52600. public function setBorderFormat($borderFormat)
  52601. {
  52602. $this->borderFormat = $borderFormat;
  52603. return $this;
  52604. }
  52605. public function getBorderFormat()
  52606. {
  52607. return $this->borderFormat;
  52608. }
  52609. public function setPadType($padType)
  52610. {
  52611. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  52612. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  52613. }
  52614. $this->padType = $padType;
  52615. return $this;
  52616. }
  52617. public function getPadType()
  52618. {
  52619. return $this->padType;
  52620. }
  52621. }
  52622. <?php
  52623. namespace Symfony\Component\Console\Input;
  52624. use Symfony\Component\Console\Exception\RuntimeException;
  52625. class ArgvInput extends Input
  52626. {
  52627. private $tokens;
  52628. private $parsed;
  52629. public function __construct(array $argv = null, InputDefinition $definition = null)
  52630. {
  52631. if (null === $argv) {
  52632. $argv = $_SERVER['argv'];
  52633. }
  52634. array_shift($argv);
  52635. $this->tokens = $argv;
  52636. parent::__construct($definition);
  52637. }
  52638. protected function setTokens(array $tokens)
  52639. {
  52640. $this->tokens = $tokens;
  52641. }
  52642. protected function parse()
  52643. {
  52644. $parseOptions = true;
  52645. $this->parsed = $this->tokens;
  52646. while (null !== $token = array_shift($this->parsed)) {
  52647. if ($parseOptions && '' == $token) {
  52648. $this->parseArgument($token);
  52649. } elseif ($parseOptions && '--' == $token) {
  52650. $parseOptions = false;
  52651. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  52652. $this->parseLongOption($token);
  52653. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  52654. $this->parseShortOption($token);
  52655. } else {
  52656. $this->parseArgument($token);
  52657. }
  52658. }
  52659. }
  52660. private function parseShortOption($token)
  52661. {
  52662. $name = substr($token, 1);
  52663. if (\strlen($name) > 1) {
  52664. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  52665. $this->addShortOption($name[0], substr($name, 1));
  52666. } else {
  52667. $this->parseShortOptionSet($name);
  52668. }
  52669. } else {
  52670. $this->addShortOption($name, null);
  52671. }
  52672. }
  52673. private function parseShortOptionSet($name)
  52674. {
  52675. $len = \strlen($name);
  52676. for ($i = 0; $i < $len; ++$i) {
  52677. if (!$this->definition->hasShortcut($name[$i])) {
  52678. $encoding = mb_detect_encoding($name, null, true);
  52679. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  52680. }
  52681. $option = $this->definition->getOptionForShortcut($name[$i]);
  52682. if ($option->acceptValue()) {
  52683. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  52684. break;
  52685. } else {
  52686. $this->addLongOption($option->getName(), null);
  52687. }
  52688. }
  52689. }
  52690. private function parseLongOption($token)
  52691. {
  52692. $name = substr($token, 2);
  52693. if (false !== $pos = strpos($name, '=')) {
  52694. if (0 === \strlen($value = substr($name, $pos + 1))) {
  52695. array_unshift($this->parsed, null);
  52696. }
  52697. $this->addLongOption(substr($name, 0, $pos), $value);
  52698. } else {
  52699. $this->addLongOption($name, null);
  52700. }
  52701. }
  52702. private function parseArgument($token)
  52703. {
  52704. $c = \count($this->arguments);
  52705. if ($this->definition->hasArgument($c)) {
  52706. $arg = $this->definition->getArgument($c);
  52707. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  52708. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  52709. $arg = $this->definition->getArgument($c - 1);
  52710. $this->arguments[$arg->getName()][] = $token;
  52711. } else {
  52712. $all = $this->definition->getArguments();
  52713. if (\count($all)) {
  52714. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  52715. }
  52716. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  52717. }
  52718. }
  52719. private function addShortOption($shortcut, $value)
  52720. {
  52721. if (!$this->definition->hasShortcut($shortcut)) {
  52722. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  52723. }
  52724. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52725. }
  52726. private function addLongOption($name, $value)
  52727. {
  52728. if (!$this->definition->hasOption($name)) {
  52729. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  52730. }
  52731. $option = $this->definition->getOption($name);
  52732. if (!isset($value[0])) {
  52733. $value = null;
  52734. }
  52735. if (null !== $value && !$option->acceptValue()) {
  52736. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  52737. }
  52738. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  52739. $next = array_shift($this->parsed);
  52740. if (isset($next[0]) && '-' !== $next[0]) {
  52741. $value = $next;
  52742. } elseif (empty($next)) {
  52743. $value = null;
  52744. } else {
  52745. array_unshift($this->parsed, $next);
  52746. }
  52747. }
  52748. if (null === $value) {
  52749. if ($option->isValueRequired()) {
  52750. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  52751. }
  52752. if (!$option->isArray()) {
  52753. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52754. }
  52755. }
  52756. if ($option->isArray()) {
  52757. $this->options[$name][] = $value;
  52758. } else {
  52759. $this->options[$name] = $value;
  52760. }
  52761. }
  52762. public function getFirstArgument()
  52763. {
  52764. foreach ($this->tokens as $token) {
  52765. if ($token && '-' === $token[0]) {
  52766. continue;
  52767. }
  52768. return $token;
  52769. }
  52770. }
  52771. public function hasParameterOption($values)
  52772. {
  52773. $values = (array) $values;
  52774. foreach ($this->tokens as $token) {
  52775. foreach ($values as $value) {
  52776. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52777. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  52778. return true;
  52779. }
  52780. }
  52781. }
  52782. return false;
  52783. }
  52784. public function getParameterOption($values, $default = false)
  52785. {
  52786. $values = (array) $values;
  52787. $tokens = $this->tokens;
  52788. while (0 < \count($tokens)) {
  52789. $token = array_shift($tokens);
  52790. foreach ($values as $value) {
  52791. if ($token === $value) {
  52792. return array_shift($tokens);
  52793. }
  52794. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52795. if ('' !== $leading && 0 === strpos($token, $leading)) {
  52796. return substr($token, \strlen($leading));
  52797. }
  52798. }
  52799. }
  52800. return $default;
  52801. }
  52802. public function __toString()
  52803. {
  52804. $self = $this;
  52805. $tokens = array_map(function ($token) use ($self) {
  52806. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  52807. return $match[1].$self->escapeToken($match[2]);
  52808. }
  52809. if ($token && '-' !== $token[0]) {
  52810. return $self->escapeToken($token);
  52811. }
  52812. return $token;
  52813. }, $this->tokens);
  52814. return implode(' ', $tokens);
  52815. }
  52816. }
  52817. <?php
  52818. namespace Symfony\Component\Console\Input;
  52819. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52820. use Symfony\Component\Console\Exception\InvalidOptionException;
  52821. class ArrayInput extends Input
  52822. {
  52823. private $parameters;
  52824. public function __construct(array $parameters, InputDefinition $definition = null)
  52825. {
  52826. $this->parameters = $parameters;
  52827. parent::__construct($definition);
  52828. }
  52829. public function getFirstArgument()
  52830. {
  52831. foreach ($this->parameters as $key => $value) {
  52832. if ($key && '-' === $key[0]) {
  52833. continue;
  52834. }
  52835. return $value;
  52836. }
  52837. }
  52838. public function hasParameterOption($values)
  52839. {
  52840. $values = (array) $values;
  52841. foreach ($this->parameters as $k => $v) {
  52842. if (!\is_int($k)) {
  52843. $v = $k;
  52844. }
  52845. if (\in_array($v, $values)) {
  52846. return true;
  52847. }
  52848. }
  52849. return false;
  52850. }
  52851. public function getParameterOption($values, $default = false)
  52852. {
  52853. $values = (array) $values;
  52854. foreach ($this->parameters as $k => $v) {
  52855. if (\is_int($k)) {
  52856. if (\in_array($v, $values)) {
  52857. return true;
  52858. }
  52859. } elseif (\in_array($k, $values)) {
  52860. return $v;
  52861. }
  52862. }
  52863. return $default;
  52864. }
  52865. public function __toString()
  52866. {
  52867. $params = array();
  52868. foreach ($this->parameters as $param => $val) {
  52869. if ($param && '-' === $param[0]) {
  52870. if (\is_array($val)) {
  52871. foreach ($val as $v) {
  52872. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  52873. }
  52874. } else {
  52875. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  52876. }
  52877. } else {
  52878. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  52879. }
  52880. }
  52881. return implode(' ', $params);
  52882. }
  52883. protected function parse()
  52884. {
  52885. foreach ($this->parameters as $key => $value) {
  52886. if (0 === strpos($key, '--')) {
  52887. $this->addLongOption(substr($key, 2), $value);
  52888. } elseif ('-' === $key[0]) {
  52889. $this->addShortOption(substr($key, 1), $value);
  52890. } else {
  52891. $this->addArgument($key, $value);
  52892. }
  52893. }
  52894. }
  52895. private function addShortOption($shortcut, $value)
  52896. {
  52897. if (!$this->definition->hasShortcut($shortcut)) {
  52898. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  52899. }
  52900. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52901. }
  52902. private function addLongOption($name, $value)
  52903. {
  52904. if (!$this->definition->hasOption($name)) {
  52905. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  52906. }
  52907. $option = $this->definition->getOption($name);
  52908. if (null === $value) {
  52909. if ($option->isValueRequired()) {
  52910. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  52911. }
  52912. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52913. }
  52914. $this->options[$name] = $value;
  52915. }
  52916. private function addArgument($name, $value)
  52917. {
  52918. if (!$this->definition->hasArgument($name)) {
  52919. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52920. }
  52921. $this->arguments[$name] = $value;
  52922. }
  52923. }
  52924. <?php
  52925. namespace Symfony\Component\Console\Input;
  52926. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52927. use Symfony\Component\Console\Exception\RuntimeException;
  52928. abstract class Input implements InputInterface
  52929. {
  52930. protected $definition;
  52931. protected $options = array();
  52932. protected $arguments = array();
  52933. protected $interactive = true;
  52934. public function __construct(InputDefinition $definition = null)
  52935. {
  52936. if (null === $definition) {
  52937. $this->definition = new InputDefinition();
  52938. } else {
  52939. $this->bind($definition);
  52940. $this->validate();
  52941. }
  52942. }
  52943. public function bind(InputDefinition $definition)
  52944. {
  52945. $this->arguments = array();
  52946. $this->options = array();
  52947. $this->definition = $definition;
  52948. $this->parse();
  52949. }
  52950. abstract protected function parse();
  52951. public function validate()
  52952. {
  52953. $definition = $this->definition;
  52954. $givenArguments = $this->arguments;
  52955. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  52956. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  52957. });
  52958. if (\count($missingArguments) > 0) {
  52959. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  52960. }
  52961. }
  52962. public function isInteractive()
  52963. {
  52964. return $this->interactive;
  52965. }
  52966. public function setInteractive($interactive)
  52967. {
  52968. $this->interactive = (bool) $interactive;
  52969. }
  52970. public function getArguments()
  52971. {
  52972. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  52973. }
  52974. public function getArgument($name)
  52975. {
  52976. if (!$this->definition->hasArgument($name)) {
  52977. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52978. }
  52979. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  52980. }
  52981. public function setArgument($name, $value)
  52982. {
  52983. if (!$this->definition->hasArgument($name)) {
  52984. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52985. }
  52986. $this->arguments[$name] = $value;
  52987. }
  52988. public function hasArgument($name)
  52989. {
  52990. return $this->definition->hasArgument($name);
  52991. }
  52992. public function getOptions()
  52993. {
  52994. return array_merge($this->definition->getOptionDefaults(), $this->options);
  52995. }
  52996. public function getOption($name)
  52997. {
  52998. if (!$this->definition->hasOption($name)) {
  52999. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  53000. }
  53001. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  53002. }
  53003. public function setOption($name, $value)
  53004. {
  53005. if (!$this->definition->hasOption($name)) {
  53006. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  53007. }
  53008. $this->options[$name] = $value;
  53009. }
  53010. public function hasOption($name)
  53011. {
  53012. return $this->definition->hasOption($name);
  53013. }
  53014. public function escapeToken($token)
  53015. {
  53016. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  53017. }
  53018. }
  53019. <?php
  53020. namespace Symfony\Component\Console\Input;
  53021. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53022. use Symfony\Component\Console\Exception\LogicException;
  53023. class InputArgument
  53024. {
  53025. const REQUIRED = 1;
  53026. const OPTIONAL = 2;
  53027. const IS_ARRAY = 4;
  53028. private $name;
  53029. private $mode;
  53030. private $default;
  53031. private $description;
  53032. public function __construct($name, $mode = null, $description = '', $default = null)
  53033. {
  53034. if (null === $mode) {
  53035. $mode = self::OPTIONAL;
  53036. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  53037. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  53038. }
  53039. $this->name = $name;
  53040. $this->mode = $mode;
  53041. $this->description = $description;
  53042. $this->setDefault($default);
  53043. }
  53044. public function getName()
  53045. {
  53046. return $this->name;
  53047. }
  53048. public function isRequired()
  53049. {
  53050. return self::REQUIRED === (self::REQUIRED & $this->mode);
  53051. }
  53052. public function isArray()
  53053. {
  53054. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  53055. }
  53056. public function setDefault($default = null)
  53057. {
  53058. if (self::REQUIRED === $this->mode && null !== $default) {
  53059. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  53060. }
  53061. if ($this->isArray()) {
  53062. if (null === $default) {
  53063. $default = array();
  53064. } elseif (!\is_array($default)) {
  53065. throw new LogicException('A default value for an array argument must be an array.');
  53066. }
  53067. }
  53068. $this->default = $default;
  53069. }
  53070. public function getDefault()
  53071. {
  53072. return $this->default;
  53073. }
  53074. public function getDescription()
  53075. {
  53076. return $this->description;
  53077. }
  53078. }
  53079. <?php
  53080. namespace Symfony\Component\Console\Input;
  53081. interface InputAwareInterface
  53082. {
  53083. public function setInput(InputInterface $input);
  53084. }
  53085. <?php
  53086. namespace Symfony\Component\Console\Input;
  53087. use Symfony\Component\Console\Descriptor\TextDescriptor;
  53088. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  53089. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53090. use Symfony\Component\Console\Exception\LogicException;
  53091. use Symfony\Component\Console\Output\BufferedOutput;
  53092. class InputDefinition
  53093. {
  53094. private $arguments;
  53095. private $requiredCount;
  53096. private $hasAnArrayArgument = false;
  53097. private $hasOptional;
  53098. private $options;
  53099. private $shortcuts;
  53100. public function __construct(array $definition = array())
  53101. {
  53102. $this->setDefinition($definition);
  53103. }
  53104. public function setDefinition(array $definition)
  53105. {
  53106. $arguments = array();
  53107. $options = array();
  53108. foreach ($definition as $item) {
  53109. if ($item instanceof InputOption) {
  53110. $options[] = $item;
  53111. } else {
  53112. $arguments[] = $item;
  53113. }
  53114. }
  53115. $this->setArguments($arguments);
  53116. $this->setOptions($options);
  53117. }
  53118. public function setArguments($arguments = array())
  53119. {
  53120. $this->arguments = array();
  53121. $this->requiredCount = 0;
  53122. $this->hasOptional = false;
  53123. $this->hasAnArrayArgument = false;
  53124. $this->addArguments($arguments);
  53125. }
  53126. public function addArguments($arguments = array())
  53127. {
  53128. if (null !== $arguments) {
  53129. foreach ($arguments as $argument) {
  53130. $this->addArgument($argument);
  53131. }
  53132. }
  53133. }
  53134. public function addArgument(InputArgument $argument)
  53135. {
  53136. if (isset($this->arguments[$argument->getName()])) {
  53137. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  53138. }
  53139. if ($this->hasAnArrayArgument) {
  53140. throw new LogicException('Cannot add an argument after an array argument.');
  53141. }
  53142. if ($argument->isRequired() && $this->hasOptional) {
  53143. throw new LogicException('Cannot add a required argument after an optional one.');
  53144. }
  53145. if ($argument->isArray()) {
  53146. $this->hasAnArrayArgument = true;
  53147. }
  53148. if ($argument->isRequired()) {
  53149. ++$this->requiredCount;
  53150. } else {
  53151. $this->hasOptional = true;
  53152. }
  53153. $this->arguments[$argument->getName()] = $argument;
  53154. }
  53155. public function getArgument($name)
  53156. {
  53157. if (!$this->hasArgument($name)) {
  53158. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  53159. }
  53160. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  53161. return $arguments[$name];
  53162. }
  53163. public function hasArgument($name)
  53164. {
  53165. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  53166. return isset($arguments[$name]);
  53167. }
  53168. public function getArguments()
  53169. {
  53170. return $this->arguments;
  53171. }
  53172. public function getArgumentCount()
  53173. {
  53174. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  53175. }
  53176. public function getArgumentRequiredCount()
  53177. {
  53178. return $this->requiredCount;
  53179. }
  53180. public function getArgumentDefaults()
  53181. {
  53182. $values = array();
  53183. foreach ($this->arguments as $argument) {
  53184. $values[$argument->getName()] = $argument->getDefault();
  53185. }
  53186. return $values;
  53187. }
  53188. public function setOptions($options = array())
  53189. {
  53190. $this->options = array();
  53191. $this->shortcuts = array();
  53192. $this->addOptions($options);
  53193. }
  53194. public function addOptions($options = array())
  53195. {
  53196. foreach ($options as $option) {
  53197. $this->addOption($option);
  53198. }
  53199. }
  53200. public function addOption(InputOption $option)
  53201. {
  53202. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  53203. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  53204. }
  53205. if ($option->getShortcut()) {
  53206. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  53207. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  53208. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  53209. }
  53210. }
  53211. }
  53212. $this->options[$option->getName()] = $option;
  53213. if ($option->getShortcut()) {
  53214. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  53215. $this->shortcuts[$shortcut] = $option->getName();
  53216. }
  53217. }
  53218. }
  53219. public function getOption($name)
  53220. {
  53221. if (!$this->hasOption($name)) {
  53222. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  53223. }
  53224. return $this->options[$name];
  53225. }
  53226. public function hasOption($name)
  53227. {
  53228. return isset($this->options[$name]);
  53229. }
  53230. public function getOptions()
  53231. {
  53232. return $this->options;
  53233. }
  53234. public function hasShortcut($name)
  53235. {
  53236. return isset($this->shortcuts[$name]);
  53237. }
  53238. public function getOptionForShortcut($shortcut)
  53239. {
  53240. return $this->getOption($this->shortcutToName($shortcut));
  53241. }
  53242. public function getOptionDefaults()
  53243. {
  53244. $values = array();
  53245. foreach ($this->options as $option) {
  53246. $values[$option->getName()] = $option->getDefault();
  53247. }
  53248. return $values;
  53249. }
  53250. private function shortcutToName($shortcut)
  53251. {
  53252. if (!isset($this->shortcuts[$shortcut])) {
  53253. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  53254. }
  53255. return $this->shortcuts[$shortcut];
  53256. }
  53257. public function getSynopsis($short = false)
  53258. {
  53259. $elements = array();
  53260. if ($short && $this->getOptions()) {
  53261. $elements[] = '[options]';
  53262. } elseif (!$short) {
  53263. foreach ($this->getOptions() as $option) {
  53264. $value = '';
  53265. if ($option->acceptValue()) {
  53266. $value = sprintf(
  53267. ' %s%s%s',
  53268. $option->isValueOptional() ? '[' : '',
  53269. strtoupper($option->getName()),
  53270. $option->isValueOptional() ? ']' : ''
  53271. );
  53272. }
  53273. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  53274. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  53275. }
  53276. }
  53277. if (\count($elements) && $this->getArguments()) {
  53278. $elements[] = '[--]';
  53279. }
  53280. foreach ($this->getArguments() as $argument) {
  53281. $element = '<'.$argument->getName().'>';
  53282. if (!$argument->isRequired()) {
  53283. $element = '['.$element.']';
  53284. } elseif ($argument->isArray()) {
  53285. $element .= ' ('.$element.')';
  53286. }
  53287. if ($argument->isArray()) {
  53288. $element .= '...';
  53289. }
  53290. $elements[] = $element;
  53291. }
  53292. return implode(' ', $elements);
  53293. }
  53294. public function asText()
  53295. {
  53296. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  53297. $descriptor = new TextDescriptor();
  53298. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  53299. $descriptor->describe($output, $this, array('raw_output' => true));
  53300. return $output->fetch();
  53301. }
  53302. public function asXml($asDom = false)
  53303. {
  53304. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  53305. $descriptor = new XmlDescriptor();
  53306. if ($asDom) {
  53307. return $descriptor->getInputDefinitionDocument($this);
  53308. }
  53309. $output = new BufferedOutput();
  53310. $descriptor->describe($output, $this);
  53311. return $output->fetch();
  53312. }
  53313. }
  53314. <?php
  53315. namespace Symfony\Component\Console\Input;
  53316. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53317. use Symfony\Component\Console\Exception\RuntimeException;
  53318. interface InputInterface
  53319. {
  53320. public function getFirstArgument();
  53321. public function hasParameterOption($values);
  53322. public function getParameterOption($values, $default = false);
  53323. public function bind(InputDefinition $definition);
  53324. public function validate();
  53325. public function getArguments();
  53326. public function getArgument($name);
  53327. public function setArgument($name, $value);
  53328. public function hasArgument($name);
  53329. public function getOptions();
  53330. public function getOption($name);
  53331. public function setOption($name, $value);
  53332. public function hasOption($name);
  53333. public function isInteractive();
  53334. public function setInteractive($interactive);
  53335. }
  53336. <?php
  53337. namespace Symfony\Component\Console\Input;
  53338. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53339. use Symfony\Component\Console\Exception\LogicException;
  53340. class InputOption
  53341. {
  53342. const VALUE_NONE = 1;
  53343. const VALUE_REQUIRED = 2;
  53344. const VALUE_OPTIONAL = 4;
  53345. const VALUE_IS_ARRAY = 8;
  53346. private $name;
  53347. private $shortcut;
  53348. private $mode;
  53349. private $default;
  53350. private $description;
  53351. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  53352. {
  53353. if (0 === strpos($name, '--')) {
  53354. $name = substr($name, 2);
  53355. }
  53356. if (empty($name)) {
  53357. throw new InvalidArgumentException('An option name cannot be empty.');
  53358. }
  53359. if (empty($shortcut)) {
  53360. $shortcut = null;
  53361. }
  53362. if (null !== $shortcut) {
  53363. if (\is_array($shortcut)) {
  53364. $shortcut = implode('|', $shortcut);
  53365. }
  53366. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  53367. $shortcuts = array_filter($shortcuts);
  53368. $shortcut = implode('|', $shortcuts);
  53369. if (empty($shortcut)) {
  53370. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  53371. }
  53372. }
  53373. if (null === $mode) {
  53374. $mode = self::VALUE_NONE;
  53375. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  53376. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  53377. }
  53378. $this->name = $name;
  53379. $this->shortcut = $shortcut;
  53380. $this->mode = $mode;
  53381. $this->description = $description;
  53382. if ($this->isArray() && !$this->acceptValue()) {
  53383. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  53384. }
  53385. $this->setDefault($default);
  53386. }
  53387. public function getShortcut()
  53388. {
  53389. return $this->shortcut;
  53390. }
  53391. public function getName()
  53392. {
  53393. return $this->name;
  53394. }
  53395. public function acceptValue()
  53396. {
  53397. return $this->isValueRequired() || $this->isValueOptional();
  53398. }
  53399. public function isValueRequired()
  53400. {
  53401. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  53402. }
  53403. public function isValueOptional()
  53404. {
  53405. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  53406. }
  53407. public function isArray()
  53408. {
  53409. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  53410. }
  53411. public function setDefault($default = null)
  53412. {
  53413. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  53414. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  53415. }
  53416. if ($this->isArray()) {
  53417. if (null === $default) {
  53418. $default = array();
  53419. } elseif (!\is_array($default)) {
  53420. throw new LogicException('A default value for an array option must be an array.');
  53421. }
  53422. }
  53423. $this->default = $this->acceptValue() ? $default : false;
  53424. }
  53425. public function getDefault()
  53426. {
  53427. return $this->default;
  53428. }
  53429. public function getDescription()
  53430. {
  53431. return $this->description;
  53432. }
  53433. public function equals(self $option)
  53434. {
  53435. return $option->getName() === $this->getName()
  53436. && $option->getShortcut() === $this->getShortcut()
  53437. && $option->getDefault() === $this->getDefault()
  53438. && $option->isArray() === $this->isArray()
  53439. && $option->isValueRequired() === $this->isValueRequired()
  53440. && $option->isValueOptional() === $this->isValueOptional()
  53441. ;
  53442. }
  53443. }
  53444. <?php
  53445. namespace Symfony\Component\Console\Input;
  53446. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53447. class StringInput extends ArgvInput
  53448. {
  53449. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  53450. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  53451. public function __construct($input, InputDefinition $definition = null)
  53452. {
  53453. if ($definition) {
  53454. @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);
  53455. }
  53456. parent::__construct(array(), null);
  53457. $this->setTokens($this->tokenize($input));
  53458. if (null !== $definition) {
  53459. $this->bind($definition);
  53460. }
  53461. }
  53462. private function tokenize($input)
  53463. {
  53464. $tokens = array();
  53465. $length = \strlen($input);
  53466. $cursor = 0;
  53467. while ($cursor < $length) {
  53468. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  53469. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  53470. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  53471. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  53472. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  53473. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  53474. $tokens[] = stripcslashes($match[1]);
  53475. } else {
  53476. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  53477. }
  53478. $cursor += \strlen($match[0]);
  53479. }
  53480. return $tokens;
  53481. }
  53482. }
  53483. Copyright (c) 2004-2018 Fabien Potencier
  53484. Permission is hereby granted, free of charge, to any person obtaining a copy
  53485. of this software and associated documentation files (the "Software"), to deal
  53486. in the Software without restriction, including without limitation the rights
  53487. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  53488. copies of the Software, and to permit persons to whom the Software is furnished
  53489. to do so, subject to the following conditions:
  53490. The above copyright notice and this permission notice shall be included in all
  53491. copies or substantial portions of the Software.
  53492. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53493. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  53494. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  53495. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  53496. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  53497. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  53498. THE SOFTWARE.
  53499. <?php
  53500. namespace Symfony\Component\Console\Logger;
  53501. use Psr\Log\AbstractLogger;
  53502. use Psr\Log\InvalidArgumentException;
  53503. use Psr\Log\LogLevel;
  53504. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  53505. use Symfony\Component\Console\Output\OutputInterface;
  53506. class ConsoleLogger extends AbstractLogger
  53507. {
  53508. const INFO = 'info';
  53509. const ERROR = 'error';
  53510. private $output;
  53511. private $verbosityLevelMap = array(
  53512. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  53513. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  53514. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  53515. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  53516. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  53517. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  53518. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  53519. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  53520. );
  53521. private $formatLevelMap = array(
  53522. LogLevel::EMERGENCY => self::ERROR,
  53523. LogLevel::ALERT => self::ERROR,
  53524. LogLevel::CRITICAL => self::ERROR,
  53525. LogLevel::ERROR => self::ERROR,
  53526. LogLevel::WARNING => self::INFO,
  53527. LogLevel::NOTICE => self::INFO,
  53528. LogLevel::INFO => self::INFO,
  53529. LogLevel::DEBUG => self::INFO,
  53530. );
  53531. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  53532. {
  53533. $this->output = $output;
  53534. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  53535. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  53536. }
  53537. public function log($level, $message, array $context = array())
  53538. {
  53539. if (!isset($this->verbosityLevelMap[$level])) {
  53540. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  53541. }
  53542. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  53543. $output = $this->output->getErrorOutput();
  53544. } else {
  53545. $output = $this->output;
  53546. }
  53547. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  53548. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  53549. }
  53550. }
  53551. private function interpolate($message, array $context)
  53552. {
  53553. $replace = array();
  53554. foreach ($context as $key => $val) {
  53555. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  53556. $replace[sprintf('{%s}', $key)] = $val;
  53557. }
  53558. }
  53559. return strtr($message, $replace);
  53560. }
  53561. }
  53562. <?php
  53563. namespace Symfony\Component\Console\Output;
  53564. class BufferedOutput extends Output
  53565. {
  53566. private $buffer = '';
  53567. public function fetch()
  53568. {
  53569. $content = $this->buffer;
  53570. $this->buffer = '';
  53571. return $content;
  53572. }
  53573. protected function doWrite($message, $newline)
  53574. {
  53575. $this->buffer .= $message;
  53576. if ($newline) {
  53577. $this->buffer .= PHP_EOL;
  53578. }
  53579. }
  53580. }
  53581. <?php
  53582. namespace Symfony\Component\Console\Output;
  53583. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53584. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  53585. {
  53586. private $stderr;
  53587. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  53588. {
  53589. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  53590. $actualDecorated = $this->isDecorated();
  53591. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  53592. if (null === $decorated) {
  53593. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  53594. }
  53595. }
  53596. public function setDecorated($decorated)
  53597. {
  53598. parent::setDecorated($decorated);
  53599. $this->stderr->setDecorated($decorated);
  53600. }
  53601. public function setFormatter(OutputFormatterInterface $formatter)
  53602. {
  53603. parent::setFormatter($formatter);
  53604. $this->stderr->setFormatter($formatter);
  53605. }
  53606. public function setVerbosity($level)
  53607. {
  53608. parent::setVerbosity($level);
  53609. $this->stderr->setVerbosity($level);
  53610. }
  53611. public function getErrorOutput()
  53612. {
  53613. return $this->stderr;
  53614. }
  53615. public function setErrorOutput(OutputInterface $error)
  53616. {
  53617. $this->stderr = $error;
  53618. }
  53619. protected function hasStdoutSupport()
  53620. {
  53621. return false === $this->isRunningOS400();
  53622. }
  53623. protected function hasStderrSupport()
  53624. {
  53625. return false === $this->isRunningOS400();
  53626. }
  53627. private function isRunningOS400()
  53628. {
  53629. $checks = array(
  53630. \function_exists('php_uname') ? php_uname('s') : '',
  53631. getenv('OSTYPE'),
  53632. PHP_OS,
  53633. );
  53634. return false !== stripos(implode(';', $checks), 'OS400');
  53635. }
  53636. private function openOutputStream()
  53637. {
  53638. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  53639. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  53640. }
  53641. private function openErrorStream()
  53642. {
  53643. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  53644. return fopen($errorStream, 'w');
  53645. }
  53646. }
  53647. <?php
  53648. namespace Symfony\Component\Console\Output;
  53649. interface ConsoleOutputInterface extends OutputInterface
  53650. {
  53651. public function getErrorOutput();
  53652. public function setErrorOutput(OutputInterface $error);
  53653. }
  53654. <?php
  53655. namespace Symfony\Component\Console\Output;
  53656. use Symfony\Component\Console\Formatter\OutputFormatter;
  53657. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53658. class NullOutput implements OutputInterface
  53659. {
  53660. public function setFormatter(OutputFormatterInterface $formatter)
  53661. {
  53662. }
  53663. public function getFormatter()
  53664. {
  53665. return new OutputFormatter();
  53666. }
  53667. public function setDecorated($decorated)
  53668. {
  53669. }
  53670. public function isDecorated()
  53671. {
  53672. return false;
  53673. }
  53674. public function setVerbosity($level)
  53675. {
  53676. }
  53677. public function getVerbosity()
  53678. {
  53679. return self::VERBOSITY_QUIET;
  53680. }
  53681. public function isQuiet()
  53682. {
  53683. return true;
  53684. }
  53685. public function isVerbose()
  53686. {
  53687. return false;
  53688. }
  53689. public function isVeryVerbose()
  53690. {
  53691. return false;
  53692. }
  53693. public function isDebug()
  53694. {
  53695. return false;
  53696. }
  53697. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53698. {
  53699. }
  53700. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53701. {
  53702. }
  53703. }
  53704. <?php
  53705. namespace Symfony\Component\Console\Output;
  53706. use Symfony\Component\Console\Formatter\OutputFormatter;
  53707. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53708. abstract class Output implements OutputInterface
  53709. {
  53710. private $verbosity;
  53711. private $formatter;
  53712. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  53713. {
  53714. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  53715. $this->formatter = $formatter ?: new OutputFormatter();
  53716. $this->formatter->setDecorated($decorated);
  53717. }
  53718. public function setFormatter(OutputFormatterInterface $formatter)
  53719. {
  53720. $this->formatter = $formatter;
  53721. }
  53722. public function getFormatter()
  53723. {
  53724. return $this->formatter;
  53725. }
  53726. public function setDecorated($decorated)
  53727. {
  53728. $this->formatter->setDecorated($decorated);
  53729. }
  53730. public function isDecorated()
  53731. {
  53732. return $this->formatter->isDecorated();
  53733. }
  53734. public function setVerbosity($level)
  53735. {
  53736. $this->verbosity = (int) $level;
  53737. }
  53738. public function getVerbosity()
  53739. {
  53740. return $this->verbosity;
  53741. }
  53742. public function isQuiet()
  53743. {
  53744. return self::VERBOSITY_QUIET === $this->verbosity;
  53745. }
  53746. public function isVerbose()
  53747. {
  53748. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  53749. }
  53750. public function isVeryVerbose()
  53751. {
  53752. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  53753. }
  53754. public function isDebug()
  53755. {
  53756. return self::VERBOSITY_DEBUG <= $this->verbosity;
  53757. }
  53758. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53759. {
  53760. $this->write($messages, true, $options);
  53761. }
  53762. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53763. {
  53764. $messages = (array) $messages;
  53765. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  53766. $type = $types & $options ?: self::OUTPUT_NORMAL;
  53767. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  53768. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  53769. if ($verbosity > $this->getVerbosity()) {
  53770. return;
  53771. }
  53772. foreach ($messages as $message) {
  53773. switch ($type) {
  53774. case OutputInterface::OUTPUT_NORMAL:
  53775. $message = $this->formatter->format($message);
  53776. break;
  53777. case OutputInterface::OUTPUT_RAW:
  53778. break;
  53779. case OutputInterface::OUTPUT_PLAIN:
  53780. $message = strip_tags($this->formatter->format($message));
  53781. break;
  53782. }
  53783. $this->doWrite($message, $newline);
  53784. }
  53785. }
  53786. abstract protected function doWrite($message, $newline);
  53787. }
  53788. <?php
  53789. namespace Symfony\Component\Console\Output;
  53790. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53791. interface OutputInterface
  53792. {
  53793. const VERBOSITY_QUIET = 16;
  53794. const VERBOSITY_NORMAL = 32;
  53795. const VERBOSITY_VERBOSE = 64;
  53796. const VERBOSITY_VERY_VERBOSE = 128;
  53797. const VERBOSITY_DEBUG = 256;
  53798. const OUTPUT_NORMAL = 1;
  53799. const OUTPUT_RAW = 2;
  53800. const OUTPUT_PLAIN = 4;
  53801. public function write($messages, $newline = false, $options = 0);
  53802. public function writeln($messages, $options = 0);
  53803. public function setVerbosity($level);
  53804. public function getVerbosity();
  53805. public function setDecorated($decorated);
  53806. public function isDecorated();
  53807. public function setFormatter(OutputFormatterInterface $formatter);
  53808. public function getFormatter();
  53809. }
  53810. <?php
  53811. namespace Symfony\Component\Console\Output;
  53812. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53813. use Symfony\Component\Console\Exception\RuntimeException;
  53814. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53815. class StreamOutput extends Output
  53816. {
  53817. private $stream;
  53818. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  53819. {
  53820. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  53821. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  53822. }
  53823. $this->stream = $stream;
  53824. if (null === $decorated) {
  53825. $decorated = $this->hasColorSupport();
  53826. }
  53827. parent::__construct($verbosity, $decorated, $formatter);
  53828. }
  53829. public function getStream()
  53830. {
  53831. return $this->stream;
  53832. }
  53833. protected function doWrite($message, $newline)
  53834. {
  53835. if ($newline) {
  53836. $message .= PHP_EOL;
  53837. }
  53838. if (false === @fwrite($this->stream, $message)) {
  53839. throw new RuntimeException('Unable to write output.');
  53840. }
  53841. fflush($this->stream);
  53842. }
  53843. protected function hasColorSupport()
  53844. {
  53845. if ('Hyper' === getenv('TERM_PROGRAM')) {
  53846. return true;
  53847. }
  53848. if (\DIRECTORY_SEPARATOR === '\\') {
  53849. return (\function_exists('sapi_windows_vt100_support')
  53850. && @sapi_windows_vt100_support($this->stream))
  53851. || false !== getenv('ANSICON')
  53852. || 'ON' === getenv('ConEmuANSI')
  53853. || 'xterm' === getenv('TERM');
  53854. }
  53855. if (\function_exists('stream_isatty')) {
  53856. return @stream_isatty($this->stream);
  53857. }
  53858. if (\function_exists('posix_isatty')) {
  53859. return @posix_isatty($this->stream);
  53860. }
  53861. $stat = @fstat($this->stream);
  53862. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  53863. }
  53864. }
  53865. <?php
  53866. namespace Symfony\Component\Console\Question;
  53867. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53868. class ChoiceQuestion extends Question
  53869. {
  53870. private $choices;
  53871. private $multiselect = false;
  53872. private $prompt = ' > ';
  53873. private $errorMessage = 'Value "%s" is invalid';
  53874. public function __construct($question, array $choices, $default = null)
  53875. {
  53876. if (!$choices) {
  53877. throw new \LogicException('Choice question must have at least 1 choice available.');
  53878. }
  53879. parent::__construct($question, $default);
  53880. $this->choices = $choices;
  53881. $this->setValidator($this->getDefaultValidator());
  53882. $this->setAutocompleterValues($choices);
  53883. }
  53884. public function getChoices()
  53885. {
  53886. return $this->choices;
  53887. }
  53888. public function setMultiselect($multiselect)
  53889. {
  53890. $this->multiselect = $multiselect;
  53891. $this->setValidator($this->getDefaultValidator());
  53892. return $this;
  53893. }
  53894. public function isMultiselect()
  53895. {
  53896. return $this->multiselect;
  53897. }
  53898. public function getPrompt()
  53899. {
  53900. return $this->prompt;
  53901. }
  53902. public function setPrompt($prompt)
  53903. {
  53904. $this->prompt = $prompt;
  53905. return $this;
  53906. }
  53907. public function setErrorMessage($errorMessage)
  53908. {
  53909. $this->errorMessage = $errorMessage;
  53910. $this->setValidator($this->getDefaultValidator());
  53911. return $this;
  53912. }
  53913. private function getDefaultValidator()
  53914. {
  53915. $choices = $this->choices;
  53916. $errorMessage = $this->errorMessage;
  53917. $multiselect = $this->multiselect;
  53918. $isAssoc = $this->isAssoc($choices);
  53919. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  53920. $selectedChoices = str_replace(' ', '', $selected);
  53921. if ($multiselect) {
  53922. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  53923. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  53924. }
  53925. $selectedChoices = explode(',', $selectedChoices);
  53926. } else {
  53927. $selectedChoices = array($selected);
  53928. }
  53929. $multiselectChoices = array();
  53930. foreach ($selectedChoices as $value) {
  53931. $results = array();
  53932. foreach ($choices as $key => $choice) {
  53933. if ($choice === $value) {
  53934. $results[] = $key;
  53935. }
  53936. }
  53937. if (\count($results) > 1) {
  53938. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  53939. }
  53940. $result = array_search($value, $choices);
  53941. if (!$isAssoc) {
  53942. if (false !== $result) {
  53943. $result = $choices[$result];
  53944. } elseif (isset($choices[$value])) {
  53945. $result = $choices[$value];
  53946. }
  53947. } elseif (false === $result && isset($choices[$value])) {
  53948. $result = $value;
  53949. }
  53950. if (false === $result) {
  53951. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  53952. }
  53953. $multiselectChoices[] = (string) $result;
  53954. }
  53955. if ($multiselect) {
  53956. return $multiselectChoices;
  53957. }
  53958. return current($multiselectChoices);
  53959. };
  53960. }
  53961. }
  53962. <?php
  53963. namespace Symfony\Component\Console\Question;
  53964. class ConfirmationQuestion extends Question
  53965. {
  53966. private $trueAnswerRegex;
  53967. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  53968. {
  53969. parent::__construct($question, (bool) $default);
  53970. $this->trueAnswerRegex = $trueAnswerRegex;
  53971. $this->setNormalizer($this->getDefaultNormalizer());
  53972. }
  53973. private function getDefaultNormalizer()
  53974. {
  53975. $default = $this->getDefault();
  53976. $regex = $this->trueAnswerRegex;
  53977. return function ($answer) use ($default, $regex) {
  53978. if (\is_bool($answer)) {
  53979. return $answer;
  53980. }
  53981. $answerIsTrue = (bool) preg_match($regex, $answer);
  53982. if (false === $default) {
  53983. return $answer && $answerIsTrue;
  53984. }
  53985. return !$answer || $answerIsTrue;
  53986. };
  53987. }
  53988. }
  53989. <?php
  53990. namespace Symfony\Component\Console\Question;
  53991. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53992. use Symfony\Component\Console\Exception\LogicException;
  53993. class Question
  53994. {
  53995. private $question;
  53996. private $attempts;
  53997. private $hidden = false;
  53998. private $hiddenFallback = true;
  53999. private $autocompleterValues;
  54000. private $validator;
  54001. private $default;
  54002. private $normalizer;
  54003. public function __construct($question, $default = null)
  54004. {
  54005. $this->question = $question;
  54006. $this->default = $default;
  54007. }
  54008. public function getQuestion()
  54009. {
  54010. return $this->question;
  54011. }
  54012. public function getDefault()
  54013. {
  54014. return $this->default;
  54015. }
  54016. public function isHidden()
  54017. {
  54018. return $this->hidden;
  54019. }
  54020. public function setHidden($hidden)
  54021. {
  54022. if ($this->autocompleterValues) {
  54023. throw new LogicException('A hidden question cannot use the autocompleter.');
  54024. }
  54025. $this->hidden = (bool) $hidden;
  54026. return $this;
  54027. }
  54028. public function isHiddenFallback()
  54029. {
  54030. return $this->hiddenFallback;
  54031. }
  54032. public function setHiddenFallback($fallback)
  54033. {
  54034. $this->hiddenFallback = (bool) $fallback;
  54035. return $this;
  54036. }
  54037. public function getAutocompleterValues()
  54038. {
  54039. return $this->autocompleterValues;
  54040. }
  54041. public function setAutocompleterValues($values)
  54042. {
  54043. if (\is_array($values)) {
  54044. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  54045. }
  54046. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  54047. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  54048. }
  54049. if ($this->hidden) {
  54050. throw new LogicException('A hidden question cannot use the autocompleter.');
  54051. }
  54052. $this->autocompleterValues = $values;
  54053. return $this;
  54054. }
  54055. public function setValidator($validator)
  54056. {
  54057. $this->validator = $validator;
  54058. return $this;
  54059. }
  54060. public function getValidator()
  54061. {
  54062. return $this->validator;
  54063. }
  54064. public function setMaxAttempts($attempts)
  54065. {
  54066. if (null !== $attempts && $attempts < 1) {
  54067. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  54068. }
  54069. $this->attempts = $attempts;
  54070. return $this;
  54071. }
  54072. public function getMaxAttempts()
  54073. {
  54074. return $this->attempts;
  54075. }
  54076. public function setNormalizer($normalizer)
  54077. {
  54078. $this->normalizer = $normalizer;
  54079. return $this;
  54080. }
  54081. public function getNormalizer()
  54082. {
  54083. return $this->normalizer;
  54084. }
  54085. protected function isAssoc($array)
  54086. {
  54087. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  54088. }
  54089. }
  54090. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  54091. $�������Æ,Í;§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��������à�  ��
  54092. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  54093. ����������������� ��`.rdata����� ���
  54094. �����������������@��@.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
  54095. 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
  54096. 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
  54097. 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">
  54098. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  54099. <security>
  54100. <requestedPrivileges>
  54101. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  54102. </requestedPrivileges>
  54103. </security>
  54104. </trustInfo>
  54105. <dependency>
  54106. <dependentAssembly>
  54107. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  54108. </dependentAssembly>
  54109. </dependency>
  54110. </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
  54111. namespace Symfony\Component\Console;
  54112. use Symfony\Component\Console\Exception\RuntimeException;
  54113. use Symfony\Component\Console\Input\StringInput;
  54114. use Symfony\Component\Console\Output\ConsoleOutput;
  54115. use Symfony\Component\Process\PhpExecutableFinder;
  54116. use Symfony\Component\Process\ProcessBuilder;
  54117. class Shell
  54118. {
  54119. private $application;
  54120. private $history;
  54121. private $output;
  54122. private $hasReadline;
  54123. private $processIsolation = false;
  54124. public function __construct(Application $application)
  54125. {
  54126. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  54127. $this->hasReadline = \function_exists('readline');
  54128. $this->application = $application;
  54129. $this->history = getenv('HOME').'/.history_'.$application->getName();
  54130. $this->output = new ConsoleOutput();
  54131. }
  54132. public function run()
  54133. {
  54134. $this->application->setAutoExit(false);
  54135. $this->application->setCatchExceptions(true);
  54136. if ($this->hasReadline) {
  54137. readline_read_history($this->history);
  54138. readline_completion_function(array($this, 'autocompleter'));
  54139. }
  54140. $this->output->writeln($this->getHeader());
  54141. $php = null;
  54142. if ($this->processIsolation) {
  54143. $finder = new PhpExecutableFinder();
  54144. $php = $finder->find();
  54145. $this->output->writeln(<<<'EOF'
  54146. <info>Running with process isolation, you should consider this:</info>
  54147. * each command is executed as separate process,
  54148. * commands don't support interactivity, all params must be passed explicitly,
  54149. * commands output is not colorized.
  54150. EOF
  54151. );
  54152. }
  54153. while (true) {
  54154. $command = $this->readline();
  54155. if (false === $command) {
  54156. $this->output->writeln("\n");
  54157. break;
  54158. }
  54159. if ($this->hasReadline) {
  54160. readline_add_history($command);
  54161. readline_write_history($this->history);
  54162. }
  54163. if ($this->processIsolation) {
  54164. $pb = new ProcessBuilder();
  54165. $process = $pb
  54166. ->add($php)
  54167. ->add($_SERVER['argv'][0])
  54168. ->add($command)
  54169. ->inheritEnvironmentVariables(true)
  54170. ->getProcess()
  54171. ;
  54172. $output = $this->output;
  54173. $process->run(function ($type, $data) use ($output) {
  54174. $output->writeln($data);
  54175. });
  54176. $ret = $process->getExitCode();
  54177. } else {
  54178. $ret = $this->application->run(new StringInput($command), $this->output);
  54179. }
  54180. if (0 !== $ret) {
  54181. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  54182. }
  54183. }
  54184. }
  54185. protected function getHeader()
  54186. {
  54187. return <<<EOF
  54188. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  54189. At the prompt, type <comment>help</comment> for some help,
  54190. or <comment>list</comment> to get a list of available commands.
  54191. To exit the shell, type <comment>^D</comment>.
  54192. EOF;
  54193. }
  54194. protected function getPrompt()
  54195. {
  54196. return $this->output->getFormatter()->format($this->application->getName().' > ');
  54197. }
  54198. protected function getOutput()
  54199. {
  54200. return $this->output;
  54201. }
  54202. protected function getApplication()
  54203. {
  54204. return $this->application;
  54205. }
  54206. private function autocompleter($text)
  54207. {
  54208. $info = readline_info();
  54209. $text = substr($info['line_buffer'], 0, $info['end']);
  54210. if ($info['point'] !== $info['end']) {
  54211. return true;
  54212. }
  54213. if (false === strpos($text, ' ') || !$text) {
  54214. return array_keys($this->application->all());
  54215. }
  54216. try {
  54217. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  54218. } catch (\Exception $e) {
  54219. return true;
  54220. }
  54221. $list = array('--help');
  54222. foreach ($command->getDefinition()->getOptions() as $option) {
  54223. $list[] = '--'.$option->getName();
  54224. }
  54225. return $list;
  54226. }
  54227. private function readline()
  54228. {
  54229. if ($this->hasReadline) {
  54230. $line = readline($this->getPrompt());
  54231. } else {
  54232. $this->output->write($this->getPrompt());
  54233. $line = fgets(STDIN, 1024);
  54234. $line = (false === $line || '' === $line) ? false : rtrim($line);
  54235. }
  54236. return $line;
  54237. }
  54238. public function getProcessIsolation()
  54239. {
  54240. return $this->processIsolation;
  54241. }
  54242. public function setProcessIsolation($processIsolation)
  54243. {
  54244. $this->processIsolation = (bool) $processIsolation;
  54245. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  54246. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  54247. }
  54248. }
  54249. }
  54250. <?php
  54251. namespace Symfony\Component\Console\Style;
  54252. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  54253. use Symfony\Component\Console\Helper\ProgressBar;
  54254. use Symfony\Component\Console\Output\OutputInterface;
  54255. abstract class OutputStyle implements OutputInterface, StyleInterface
  54256. {
  54257. private $output;
  54258. public function __construct(OutputInterface $output)
  54259. {
  54260. $this->output = $output;
  54261. }
  54262. public function newLine($count = 1)
  54263. {
  54264. $this->output->write(str_repeat(PHP_EOL, $count));
  54265. }
  54266. public function createProgressBar($max = 0)
  54267. {
  54268. return new ProgressBar($this->output, $max);
  54269. }
  54270. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  54271. {
  54272. $this->output->write($messages, $newline, $type);
  54273. }
  54274. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  54275. {
  54276. $this->output->writeln($messages, $type);
  54277. }
  54278. public function setVerbosity($level)
  54279. {
  54280. $this->output->setVerbosity($level);
  54281. }
  54282. public function getVerbosity()
  54283. {
  54284. return $this->output->getVerbosity();
  54285. }
  54286. public function setDecorated($decorated)
  54287. {
  54288. $this->output->setDecorated($decorated);
  54289. }
  54290. public function isDecorated()
  54291. {
  54292. return $this->output->isDecorated();
  54293. }
  54294. public function setFormatter(OutputFormatterInterface $formatter)
  54295. {
  54296. $this->output->setFormatter($formatter);
  54297. }
  54298. public function getFormatter()
  54299. {
  54300. return $this->output->getFormatter();
  54301. }
  54302. }
  54303. <?php
  54304. namespace Symfony\Component\Console\Style;
  54305. interface StyleInterface
  54306. {
  54307. public function title($message);
  54308. public function section($message);
  54309. public function listing(array $elements);
  54310. public function text($message);
  54311. public function success($message);
  54312. public function error($message);
  54313. public function warning($message);
  54314. public function note($message);
  54315. public function caution($message);
  54316. public function table(array $headers, array $rows);
  54317. public function ask($question, $default = null, $validator = null);
  54318. public function askHidden($question, $validator = null);
  54319. public function confirm($question, $default = true);
  54320. public function choice($question, array $choices, $default = null);
  54321. public function newLine($count = 1);
  54322. public function progressStart($max = 0);
  54323. public function progressAdvance($step = 1);
  54324. public function progressFinish();
  54325. }
  54326. <?php
  54327. namespace Symfony\Component\Console\Style;
  54328. use Symfony\Component\Console\Application;
  54329. use Symfony\Component\Console\Exception\RuntimeException;
  54330. use Symfony\Component\Console\Formatter\OutputFormatter;
  54331. use Symfony\Component\Console\Helper\Helper;
  54332. use Symfony\Component\Console\Helper\ProgressBar;
  54333. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  54334. use Symfony\Component\Console\Helper\Table;
  54335. use Symfony\Component\Console\Input\InputInterface;
  54336. use Symfony\Component\Console\Output\BufferedOutput;
  54337. use Symfony\Component\Console\Output\OutputInterface;
  54338. use Symfony\Component\Console\Question\ChoiceQuestion;
  54339. use Symfony\Component\Console\Question\ConfirmationQuestion;
  54340. use Symfony\Component\Console\Question\Question;
  54341. class SymfonyStyle extends OutputStyle
  54342. {
  54343. const MAX_LINE_LENGTH = 120;
  54344. private $input;
  54345. private $questionHelper;
  54346. private $progressBar;
  54347. private $lineLength;
  54348. private $bufferedOutput;
  54349. public function __construct(InputInterface $input, OutputInterface $output)
  54350. {
  54351. $this->input = $input;
  54352. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  54353. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  54354. parent::__construct($output);
  54355. }
  54356. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  54357. {
  54358. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  54359. $this->autoPrependBlock();
  54360. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  54361. $this->newLine();
  54362. }
  54363. public function title($message)
  54364. {
  54365. $this->autoPrependBlock();
  54366. $this->writeln(array(
  54367. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  54368. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  54369. ));
  54370. $this->newLine();
  54371. }
  54372. public function section($message)
  54373. {
  54374. $this->autoPrependBlock();
  54375. $this->writeln(array(
  54376. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  54377. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  54378. ));
  54379. $this->newLine();
  54380. }
  54381. public function listing(array $elements)
  54382. {
  54383. $this->autoPrependText();
  54384. $elements = array_map(function ($element) {
  54385. return sprintf(' * %s', $element);
  54386. }, $elements);
  54387. $this->writeln($elements);
  54388. $this->newLine();
  54389. }
  54390. public function text($message)
  54391. {
  54392. $this->autoPrependText();
  54393. $messages = \is_array($message) ? array_values($message) : array($message);
  54394. foreach ($messages as $message) {
  54395. $this->writeln(sprintf(' %s', $message));
  54396. }
  54397. }
  54398. public function comment($message)
  54399. {
  54400. $messages = \is_array($message) ? array_values($message) : array($message);
  54401. $this->autoPrependBlock();
  54402. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  54403. $this->newLine();
  54404. }
  54405. public function success($message)
  54406. {
  54407. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  54408. }
  54409. public function error($message)
  54410. {
  54411. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  54412. }
  54413. public function warning($message)
  54414. {
  54415. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  54416. }
  54417. public function note($message)
  54418. {
  54419. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  54420. }
  54421. public function caution($message)
  54422. {
  54423. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  54424. }
  54425. public function table(array $headers, array $rows)
  54426. {
  54427. $style = clone Table::getStyleDefinition('symfony-style-guide');
  54428. $style->setCellHeaderFormat('<info>%s</info>');
  54429. $table = new Table($this);
  54430. $table->setHeaders($headers);
  54431. $table->setRows($rows);
  54432. $table->setStyle($style);
  54433. $table->render();
  54434. $this->newLine();
  54435. }
  54436. public function ask($question, $default = null, $validator = null)
  54437. {
  54438. $question = new Question($question, $default);
  54439. $question->setValidator($validator);
  54440. return $this->askQuestion($question);
  54441. }
  54442. public function askHidden($question, $validator = null)
  54443. {
  54444. $question = new Question($question);
  54445. $question->setHidden(true);
  54446. $question->setValidator($validator);
  54447. return $this->askQuestion($question);
  54448. }
  54449. public function confirm($question, $default = true)
  54450. {
  54451. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  54452. }
  54453. public function choice($question, array $choices, $default = null)
  54454. {
  54455. if (null !== $default) {
  54456. $values = array_flip($choices);
  54457. $default = $values[$default];
  54458. }
  54459. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  54460. }
  54461. public function progressStart($max = 0)
  54462. {
  54463. $this->progressBar = $this->createProgressBar($max);
  54464. $this->progressBar->start();
  54465. }
  54466. public function progressAdvance($step = 1)
  54467. {
  54468. $this->getProgressBar()->advance($step);
  54469. }
  54470. public function progressFinish()
  54471. {
  54472. $this->getProgressBar()->finish();
  54473. $this->newLine(2);
  54474. $this->progressBar = null;
  54475. }
  54476. public function createProgressBar($max = 0)
  54477. {
  54478. $progressBar = parent::createProgressBar($max);
  54479. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  54480. $progressBar->setEmptyBarCharacter('â–‘');
  54481. $progressBar->setProgressCharacter('');
  54482. $progressBar->setBarCharacter('â–“');
  54483. }
  54484. return $progressBar;
  54485. }
  54486. public function askQuestion(Question $question)
  54487. {
  54488. if ($this->input->isInteractive()) {
  54489. $this->autoPrependBlock();
  54490. }
  54491. if (!$this->questionHelper) {
  54492. $this->questionHelper = new SymfonyQuestionHelper();
  54493. }
  54494. $answer = $this->questionHelper->ask($this->input, $this, $question);
  54495. if ($this->input->isInteractive()) {
  54496. $this->newLine();
  54497. $this->bufferedOutput->write("\n");
  54498. }
  54499. return $answer;
  54500. }
  54501. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  54502. {
  54503. parent::writeln($messages, $type);
  54504. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  54505. }
  54506. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  54507. {
  54508. parent::write($messages, $newline, $type);
  54509. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  54510. }
  54511. public function newLine($count = 1)
  54512. {
  54513. parent::newLine($count);
  54514. $this->bufferedOutput->write(str_repeat("\n", $count));
  54515. }
  54516. private function getProgressBar()
  54517. {
  54518. if (!$this->progressBar) {
  54519. throw new RuntimeException('The ProgressBar is not started.');
  54520. }
  54521. return $this->progressBar;
  54522. }
  54523. private function getTerminalWidth()
  54524. {
  54525. $application = new Application();
  54526. $dimensions = $application->getTerminalDimensions();
  54527. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  54528. }
  54529. private function autoPrependBlock()
  54530. {
  54531. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  54532. if (!isset($chars[0])) {
  54533. return $this->newLine();
  54534. }
  54535. $this->newLine(2 - substr_count($chars, "\n"));
  54536. }
  54537. private function autoPrependText()
  54538. {
  54539. $fetched = $this->bufferedOutput->fetch();
  54540. if ("\n" !== substr($fetched, -1)) {
  54541. $this->newLine();
  54542. }
  54543. }
  54544. private function reduceBuffer($messages)
  54545. {
  54546. return array_map(function ($value) {
  54547. return substr($value, -4);
  54548. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  54549. }
  54550. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  54551. {
  54552. $indentLength = 0;
  54553. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  54554. $lines = array();
  54555. if (null !== $type) {
  54556. $type = sprintf('[%s] ', $type);
  54557. $indentLength = \strlen($type);
  54558. $lineIndentation = str_repeat(' ', $indentLength);
  54559. }
  54560. foreach ($messages as $key => $message) {
  54561. if ($escape) {
  54562. $message = OutputFormatter::escape($message);
  54563. }
  54564. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  54565. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  54566. $lines[] = '';
  54567. }
  54568. }
  54569. $firstLineIndex = 0;
  54570. if ($padding && $this->isDecorated()) {
  54571. $firstLineIndex = 1;
  54572. array_unshift($lines, '');
  54573. $lines[] = '';
  54574. }
  54575. foreach ($lines as $i => &$line) {
  54576. if (null !== $type) {
  54577. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  54578. }
  54579. $line = $prefix.$line;
  54580. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  54581. if ($style) {
  54582. $line = sprintf('<%s>%s</>', $style, $line);
  54583. }
  54584. }
  54585. return $lines;
  54586. }
  54587. }
  54588. <?php
  54589. namespace Symfony\Component\Console\Tester;
  54590. use Symfony\Component\Console\Application;
  54591. use Symfony\Component\Console\Input\ArrayInput;
  54592. use Symfony\Component\Console\Input\InputInterface;
  54593. use Symfony\Component\Console\Output\OutputInterface;
  54594. use Symfony\Component\Console\Output\StreamOutput;
  54595. class ApplicationTester
  54596. {
  54597. private $application;
  54598. private $input;
  54599. private $output;
  54600. private $statusCode;
  54601. public function __construct(Application $application)
  54602. {
  54603. $this->application = $application;
  54604. }
  54605. public function run(array $input, $options = array())
  54606. {
  54607. $this->input = new ArrayInput($input);
  54608. if (isset($options['interactive'])) {
  54609. $this->input->setInteractive($options['interactive']);
  54610. }
  54611. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  54612. if (isset($options['decorated'])) {
  54613. $this->output->setDecorated($options['decorated']);
  54614. }
  54615. if (isset($options['verbosity'])) {
  54616. $this->output->setVerbosity($options['verbosity']);
  54617. }
  54618. return $this->statusCode = $this->application->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\Console\Tester;
  54644. use Symfony\Component\Console\Command\Command;
  54645. use Symfony\Component\Console\Input\ArrayInput;
  54646. use Symfony\Component\Console\Input\InputInterface;
  54647. use Symfony\Component\Console\Output\OutputInterface;
  54648. use Symfony\Component\Console\Output\StreamOutput;
  54649. class CommandTester
  54650. {
  54651. private $command;
  54652. private $input;
  54653. private $output;
  54654. private $statusCode;
  54655. public function __construct(Command $command)
  54656. {
  54657. $this->command = $command;
  54658. }
  54659. public function execute(array $input, array $options = array())
  54660. {
  54661. if (!isset($input['command'])
  54662. && (null !== $application = $this->command->getApplication())
  54663. && $application->getDefinition()->hasArgument('command')
  54664. ) {
  54665. $input = array_merge(array('command' => $this->command->getName()), $input);
  54666. }
  54667. $this->input = new ArrayInput($input);
  54668. if (isset($options['interactive'])) {
  54669. $this->input->setInteractive($options['interactive']);
  54670. }
  54671. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  54672. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  54673. if (isset($options['verbosity'])) {
  54674. $this->output->setVerbosity($options['verbosity']);
  54675. }
  54676. return $this->statusCode = $this->command->run($this->input, $this->output);
  54677. }
  54678. public function getDisplay($normalize = false)
  54679. {
  54680. rewind($this->output->getStream());
  54681. $display = stream_get_contents($this->output->getStream());
  54682. if ($normalize) {
  54683. $display = str_replace(PHP_EOL, "\n", $display);
  54684. }
  54685. return $display;
  54686. }
  54687. public function getInput()
  54688. {
  54689. return $this->input;
  54690. }
  54691. public function getOutput()
  54692. {
  54693. return $this->output;
  54694. }
  54695. public function getStatusCode()
  54696. {
  54697. return $this->statusCode;
  54698. }
  54699. }
  54700. <?php
  54701. namespace Symfony\Component\Debug;
  54702. use Psr\Log\AbstractLogger;
  54703. class BufferingLogger extends AbstractLogger
  54704. {
  54705. private $logs = array();
  54706. public function log($level, $message, array $context = array())
  54707. {
  54708. $this->logs[] = array($level, $message, $context);
  54709. }
  54710. public function cleanLogs()
  54711. {
  54712. $logs = $this->logs;
  54713. $this->logs = array();
  54714. return $logs;
  54715. }
  54716. }
  54717. <?php
  54718. namespace Symfony\Component\Debug;
  54719. class Debug
  54720. {
  54721. private static $enabled = false;
  54722. public static function enable($errorReportingLevel = null, $displayErrors = true)
  54723. {
  54724. if (static::$enabled) {
  54725. return;
  54726. }
  54727. static::$enabled = true;
  54728. if (null !== $errorReportingLevel) {
  54729. error_reporting($errorReportingLevel);
  54730. } else {
  54731. error_reporting(-1);
  54732. }
  54733. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  54734. ini_set('display_errors', 0);
  54735. ExceptionHandler::register();
  54736. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  54737. ini_set('display_errors', 1);
  54738. }
  54739. if ($displayErrors) {
  54740. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  54741. } else {
  54742. ErrorHandler::register()->throwAt(0, true);
  54743. }
  54744. DebugClassLoader::enable();
  54745. }
  54746. }
  54747. <?php
  54748. namespace Symfony\Component\Debug;
  54749. class DebugClassLoader
  54750. {
  54751. private $classLoader;
  54752. private $isFinder;
  54753. private $loaded = array();
  54754. private $wasFinder;
  54755. private static $caseCheck;
  54756. private static $deprecated = array();
  54757. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  54758. private static $darwinCache = array('/' => array('/', array()));
  54759. public function __construct($classLoader)
  54760. {
  54761. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  54762. if ($this->wasFinder) {
  54763. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  54764. $this->classLoader = array($classLoader, 'loadClass');
  54765. $this->isFinder = true;
  54766. } else {
  54767. $this->classLoader = $classLoader;
  54768. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  54769. }
  54770. if (!isset(self::$caseCheck)) {
  54771. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  54772. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  54773. $dir = substr($file, 0, 1 + $i);
  54774. $file = substr($file, 1 + $i);
  54775. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  54776. $test = realpath($dir.$test);
  54777. if (false === $test || false === $i) {
  54778. self::$caseCheck = 0;
  54779. } elseif (substr($test, -\strlen($file)) === $file) {
  54780. self::$caseCheck = 1;
  54781. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  54782. self::$caseCheck = 2;
  54783. } else {
  54784. self::$caseCheck = 0;
  54785. }
  54786. }
  54787. }
  54788. public function getClassLoader()
  54789. {
  54790. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  54791. }
  54792. public static function enable()
  54793. {
  54794. class_exists('Symfony\Component\Debug\ErrorHandler');
  54795. class_exists('Psr\Log\LogLevel');
  54796. if (!\is_array($functions = spl_autoload_functions())) {
  54797. return;
  54798. }
  54799. foreach ($functions as $function) {
  54800. spl_autoload_unregister($function);
  54801. }
  54802. foreach ($functions as $function) {
  54803. if (!\is_array($function) || !$function[0] instanceof self) {
  54804. $function = array(new static($function), 'loadClass');
  54805. }
  54806. spl_autoload_register($function);
  54807. }
  54808. }
  54809. public static function disable()
  54810. {
  54811. if (!\is_array($functions = spl_autoload_functions())) {
  54812. return;
  54813. }
  54814. foreach ($functions as $function) {
  54815. spl_autoload_unregister($function);
  54816. }
  54817. foreach ($functions as $function) {
  54818. if (\is_array($function) && $function[0] instanceof self) {
  54819. $function = $function[0]->getClassLoader();
  54820. }
  54821. spl_autoload_register($function);
  54822. }
  54823. }
  54824. public function findFile($class)
  54825. {
  54826. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  54827. if ($this->wasFinder) {
  54828. return $this->classLoader[0]->findFile($class);
  54829. }
  54830. }
  54831. public function loadClass($class)
  54832. {
  54833. ErrorHandler::stackErrors();
  54834. try {
  54835. if ($this->isFinder && !isset($this->loaded[$class])) {
  54836. $this->loaded[$class] = true;
  54837. if ($file = $this->classLoader[0]->findFile($class)) {
  54838. require $file;
  54839. }
  54840. } else {
  54841. \call_user_func($this->classLoader, $class);
  54842. $file = false;
  54843. }
  54844. } catch (\Exception $e) {
  54845. ErrorHandler::unstackErrors();
  54846. throw $e;
  54847. } catch (\Throwable $e) {
  54848. ErrorHandler::unstackErrors();
  54849. throw $e;
  54850. }
  54851. ErrorHandler::unstackErrors();
  54852. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  54853. if ($class && '\\' === $class[0]) {
  54854. $class = substr($class, 1);
  54855. }
  54856. if ($exists) {
  54857. $refl = new \ReflectionClass($class);
  54858. $name = $refl->getName();
  54859. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  54860. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  54861. }
  54862. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  54863. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  54864. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  54865. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  54866. } else {
  54867. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  54868. $len = 0;
  54869. $ns = '';
  54870. } else {
  54871. $ns = substr($name, 0, $len);
  54872. }
  54873. $parent = get_parent_class($class);
  54874. if (!$parent || strncmp($ns, $parent, $len)) {
  54875. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  54876. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  54877. }
  54878. $parentInterfaces = array();
  54879. $deprecatedInterfaces = array();
  54880. if ($parent) {
  54881. foreach (class_implements($parent) as $interface) {
  54882. $parentInterfaces[$interface] = 1;
  54883. }
  54884. }
  54885. foreach ($refl->getInterfaceNames() as $interface) {
  54886. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  54887. $deprecatedInterfaces[] = $interface;
  54888. }
  54889. foreach (class_implements($interface) as $interface) {
  54890. $parentInterfaces[$interface] = 1;
  54891. }
  54892. }
  54893. foreach ($deprecatedInterfaces as $interface) {
  54894. if (!isset($parentInterfaces[$interface])) {
  54895. @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);
  54896. }
  54897. }
  54898. }
  54899. }
  54900. }
  54901. if ($file) {
  54902. if (!$exists) {
  54903. if (false !== strpos($class, '/')) {
  54904. 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));
  54905. }
  54906. 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));
  54907. }
  54908. if (self::$caseCheck) {
  54909. $real = explode('\\', $class.strrchr($file, '.'));
  54910. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  54911. $i = \count($tail) - 1;
  54912. $j = \count($real) - 1;
  54913. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  54914. --$i;
  54915. --$j;
  54916. }
  54917. array_splice($tail, 0, $i + 1);
  54918. }
  54919. if (self::$caseCheck && $tail) {
  54920. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  54921. $tailLen = \strlen($tail);
  54922. $real = $refl->getFileName();
  54923. if (2 === self::$caseCheck) {
  54924. $i = 1 + strrpos($real, '/');
  54925. $file = substr($real, $i);
  54926. $real = substr($real, 0, $i);
  54927. if (isset(self::$darwinCache[$real])) {
  54928. $kDir = $real;
  54929. } else {
  54930. $kDir = strtolower($real);
  54931. if (isset(self::$darwinCache[$kDir])) {
  54932. $real = self::$darwinCache[$kDir][0];
  54933. } else {
  54934. $dir = getcwd();
  54935. chdir($real);
  54936. $real = getcwd().'/';
  54937. chdir($dir);
  54938. $dir = $real;
  54939. $k = $kDir;
  54940. $i = \strlen($dir) - 1;
  54941. while (!isset(self::$darwinCache[$k])) {
  54942. self::$darwinCache[$k] = array($dir, array());
  54943. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  54944. while ('/' !== $dir[--$i]) {
  54945. }
  54946. $k = substr($k, 0, ++$i);
  54947. $dir = substr($dir, 0, $i--);
  54948. }
  54949. }
  54950. }
  54951. $dirFiles = self::$darwinCache[$kDir][1];
  54952. if (isset($dirFiles[$file])) {
  54953. $kFile = $file;
  54954. } else {
  54955. $kFile = strtolower($file);
  54956. if (!isset($dirFiles[$kFile])) {
  54957. foreach (scandir($real, 2) as $f) {
  54958. if ('.' !== $f[0]) {
  54959. $dirFiles[$f] = $f;
  54960. if ($f === $file) {
  54961. $kFile = $k = $file;
  54962. } elseif ($f !== $k = strtolower($f)) {
  54963. $dirFiles[$k] = $f;
  54964. }
  54965. }
  54966. }
  54967. self::$darwinCache[$kDir][1] = $dirFiles;
  54968. }
  54969. }
  54970. $real .= $dirFiles[$kFile];
  54971. }
  54972. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  54973. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  54974. ) {
  54975. 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)));
  54976. }
  54977. }
  54978. return true;
  54979. }
  54980. }
  54981. }
  54982. <?php
  54983. namespace Symfony\Component\Debug;
  54984. use Psr\Log\LoggerInterface;
  54985. use Psr\Log\LogLevel;
  54986. use Symfony\Component\Debug\Exception\ContextErrorException;
  54987. use Symfony\Component\Debug\Exception\FatalErrorException;
  54988. use Symfony\Component\Debug\Exception\FatalThrowableError;
  54989. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  54990. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  54991. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  54992. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  54993. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  54994. class ErrorHandler
  54995. {
  54996. const TYPE_DEPRECATION = -100;
  54997. private $levels = array(
  54998. E_DEPRECATED => 'Deprecated',
  54999. E_USER_DEPRECATED => 'User Deprecated',
  55000. E_NOTICE => 'Notice',
  55001. E_USER_NOTICE => 'User Notice',
  55002. E_STRICT => 'Runtime Notice',
  55003. E_WARNING => 'Warning',
  55004. E_USER_WARNING => 'User Warning',
  55005. E_COMPILE_WARNING => 'Compile Warning',
  55006. E_CORE_WARNING => 'Core Warning',
  55007. E_USER_ERROR => 'User Error',
  55008. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  55009. E_COMPILE_ERROR => 'Compile Error',
  55010. E_PARSE => 'Parse Error',
  55011. E_ERROR => 'Error',
  55012. E_CORE_ERROR => 'Core Error',
  55013. );
  55014. private $loggers = array(
  55015. E_DEPRECATED => array(null, LogLevel::INFO),
  55016. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  55017. E_NOTICE => array(null, LogLevel::WARNING),
  55018. E_USER_NOTICE => array(null, LogLevel::WARNING),
  55019. E_STRICT => array(null, LogLevel::WARNING),
  55020. E_WARNING => array(null, LogLevel::WARNING),
  55021. E_USER_WARNING => array(null, LogLevel::WARNING),
  55022. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  55023. E_CORE_WARNING => array(null, LogLevel::WARNING),
  55024. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  55025. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  55026. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  55027. E_PARSE => array(null, LogLevel::CRITICAL),
  55028. E_ERROR => array(null, LogLevel::CRITICAL),
  55029. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  55030. );
  55031. private $thrownErrors = 0x1FFF;
  55032. private $scopedErrors = 0x1FFF;
  55033. private $tracedErrors = 0x77FB;
  55034. private $screamedErrors = 0x55;
  55035. private $loggedErrors = 0;
  55036. private $loggedTraces = array();
  55037. private $isRecursive = 0;
  55038. private $isRoot = false;
  55039. private $exceptionHandler;
  55040. private $bootstrappingLogger;
  55041. private static $reservedMemory;
  55042. private static $stackedErrors = array();
  55043. private static $stackedErrorLevels = array();
  55044. private static $toStringException = null;
  55045. private static $exitCode = 0;
  55046. private $displayErrors = 0x1FFF;
  55047. public static function register($handler = null, $replace = true)
  55048. {
  55049. if (null === self::$reservedMemory) {
  55050. self::$reservedMemory = str_repeat('x', 10240);
  55051. register_shutdown_function(__CLASS__.'::handleFatalError');
  55052. }
  55053. $levels = -1;
  55054. if ($handlerIsNew = !$handler instanceof self) {
  55055. if (null !== $handler) {
  55056. $levels = $replace ? $handler : 0;
  55057. $replace = true;
  55058. }
  55059. $handler = new static();
  55060. }
  55061. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  55062. restore_error_handler();
  55063. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  55064. $handler->isRoot = true;
  55065. }
  55066. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  55067. $handler = $prev[0];
  55068. $replace = false;
  55069. }
  55070. if (!$replace && $prev) {
  55071. restore_error_handler();
  55072. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  55073. } else {
  55074. $handlerIsRegistered = true;
  55075. }
  55076. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  55077. restore_exception_handler();
  55078. if (!$handlerIsRegistered) {
  55079. $handler = $prev[0];
  55080. } elseif ($handler !== $prev[0] && $replace) {
  55081. set_exception_handler(array($handler, 'handleException'));
  55082. $p = $prev[0]->setExceptionHandler(null);
  55083. $handler->setExceptionHandler($p);
  55084. $prev[0]->setExceptionHandler($p);
  55085. }
  55086. } else {
  55087. $handler->setExceptionHandler($prev);
  55088. }
  55089. $handler->throwAt($levels & $handler->thrownErrors, true);
  55090. return $handler;
  55091. }
  55092. public function __construct(BufferingLogger $bootstrappingLogger = null)
  55093. {
  55094. if ($bootstrappingLogger) {
  55095. $this->bootstrappingLogger = $bootstrappingLogger;
  55096. $this->setDefaultLogger($bootstrappingLogger);
  55097. }
  55098. }
  55099. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  55100. {
  55101. $loggers = array();
  55102. if (\is_array($levels)) {
  55103. foreach ($levels as $type => $logLevel) {
  55104. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  55105. $loggers[$type] = array($logger, $logLevel);
  55106. }
  55107. }
  55108. } else {
  55109. if (null === $levels) {
  55110. $levels = E_ALL | E_STRICT;
  55111. }
  55112. foreach ($this->loggers as $type => $log) {
  55113. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  55114. $log[0] = $logger;
  55115. $loggers[$type] = $log;
  55116. }
  55117. }
  55118. }
  55119. $this->setLoggers($loggers);
  55120. }
  55121. public function setLoggers(array $loggers)
  55122. {
  55123. $prevLogged = $this->loggedErrors;
  55124. $prev = $this->loggers;
  55125. $flush = array();
  55126. foreach ($loggers as $type => $log) {
  55127. if (!isset($prev[$type])) {
  55128. throw new \InvalidArgumentException('Unknown error type: '.$type);
  55129. }
  55130. if (!\is_array($log)) {
  55131. $log = array($log);
  55132. } elseif (!array_key_exists(0, $log)) {
  55133. throw new \InvalidArgumentException('No logger provided');
  55134. }
  55135. if (null === $log[0]) {
  55136. $this->loggedErrors &= ~$type;
  55137. } elseif ($log[0] instanceof LoggerInterface) {
  55138. $this->loggedErrors |= $type;
  55139. } else {
  55140. throw new \InvalidArgumentException('Invalid logger provided');
  55141. }
  55142. $this->loggers[$type] = $log + $prev[$type];
  55143. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  55144. $flush[$type] = $type;
  55145. }
  55146. }
  55147. $this->reRegister($prevLogged | $this->thrownErrors);
  55148. if ($flush) {
  55149. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  55150. $type = $log[2]['type'];
  55151. if (!isset($flush[$type])) {
  55152. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  55153. } elseif ($this->loggers[$type][0]) {
  55154. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  55155. }
  55156. }
  55157. }
  55158. return $prev;
  55159. }
  55160. public function setExceptionHandler($handler)
  55161. {
  55162. if (null !== $handler && !\is_callable($handler)) {
  55163. throw new \LogicException('The exception handler must be a valid PHP callable.');
  55164. }
  55165. $prev = $this->exceptionHandler;
  55166. $this->exceptionHandler = $handler;
  55167. return $prev;
  55168. }
  55169. public function throwAt($levels, $replace = false)
  55170. {
  55171. $prev = $this->thrownErrors;
  55172. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  55173. if (!$replace) {
  55174. $this->thrownErrors |= $prev;
  55175. }
  55176. $this->reRegister($prev | $this->loggedErrors);
  55177. $this->displayErrors = $this->thrownErrors;
  55178. return $prev;
  55179. }
  55180. public function scopeAt($levels, $replace = false)
  55181. {
  55182. $prev = $this->scopedErrors;
  55183. $this->scopedErrors = (int) $levels;
  55184. if (!$replace) {
  55185. $this->scopedErrors |= $prev;
  55186. }
  55187. return $prev;
  55188. }
  55189. public function traceAt($levels, $replace = false)
  55190. {
  55191. $prev = $this->tracedErrors;
  55192. $this->tracedErrors = (int) $levels;
  55193. if (!$replace) {
  55194. $this->tracedErrors |= $prev;
  55195. }
  55196. return $prev;
  55197. }
  55198. public function screamAt($levels, $replace = false)
  55199. {
  55200. $prev = $this->screamedErrors;
  55201. $this->screamedErrors = (int) $levels;
  55202. if (!$replace) {
  55203. $this->screamedErrors |= $prev;
  55204. }
  55205. return $prev;
  55206. }
  55207. private function reRegister($prev)
  55208. {
  55209. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  55210. $handler = set_error_handler('var_dump');
  55211. $handler = \is_array($handler) ? $handler[0] : null;
  55212. restore_error_handler();
  55213. if ($handler === $this) {
  55214. restore_error_handler();
  55215. if ($this->isRoot) {
  55216. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  55217. } else {
  55218. set_error_handler(array($this, 'handleError'));
  55219. }
  55220. }
  55221. }
  55222. }
  55223. public function handleError($type, $message, $file, $line)
  55224. {
  55225. $level = error_reporting();
  55226. $silenced = 0 === ($level & $type);
  55227. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  55228. $log = $this->loggedErrors & $type;
  55229. $throw = $this->thrownErrors & $type & $level;
  55230. $type &= $level | $this->screamedErrors;
  55231. if (!$type || (!$log && !$throw)) {
  55232. return !$silenced && $type && $log;
  55233. }
  55234. $scope = $this->scopedErrors & $type;
  55235. if (4 < $numArgs = \func_num_args()) {
  55236. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  55237. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  55238. } else {
  55239. $context = array();
  55240. $backtrace = null;
  55241. }
  55242. if (isset($context['GLOBALS']) && $scope) {
  55243. $e = $context;
  55244. unset($e['GLOBALS'], $context);
  55245. $context = $e;
  55246. }
  55247. if (null !== $backtrace && $type & E_ERROR) {
  55248. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  55249. return true;
  55250. }
  55251. if ($throw) {
  55252. if (null !== self::$toStringException) {
  55253. $throw = self::$toStringException;
  55254. self::$toStringException = null;
  55255. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  55256. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  55257. } else {
  55258. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  55259. }
  55260. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  55261. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  55262. }
  55263. if (E_USER_ERROR & $type) {
  55264. $backtrace = $backtrace ?: $throw->getTrace();
  55265. for ($i = 1; isset($backtrace[$i]); ++$i) {
  55266. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  55267. && '__toString' === $backtrace[$i]['function']
  55268. && '->' === $backtrace[$i]['type']
  55269. && !isset($backtrace[$i - 1]['class'])
  55270. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  55271. ) {
  55272. foreach ($context as $e) {
  55273. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  55274. if (1 === $i) {
  55275. $throw = $e;
  55276. break;
  55277. }
  55278. self::$toStringException = $e;
  55279. return true;
  55280. }
  55281. }
  55282. if (1 < $i) {
  55283. $this->handleException($throw);
  55284. return false;
  55285. }
  55286. }
  55287. }
  55288. }
  55289. throw $throw;
  55290. }
  55291. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  55292. $trace = true;
  55293. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  55294. $trace = false;
  55295. } else {
  55296. $this->loggedTraces[$e] = 1;
  55297. }
  55298. $e = compact('type', 'file', 'line', 'level');
  55299. if ($type & $level) {
  55300. if ($scope) {
  55301. $e['scope_vars'] = $context;
  55302. if ($trace) {
  55303. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  55304. }
  55305. } elseif ($trace) {
  55306. if (null === $backtrace) {
  55307. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  55308. } else {
  55309. foreach ($backtrace as &$frame) {
  55310. unset($frame['args'], $frame);
  55311. }
  55312. $e['stack'] = $backtrace;
  55313. }
  55314. }
  55315. }
  55316. if ($this->isRecursive) {
  55317. $log = 0;
  55318. } elseif (self::$stackedErrorLevels) {
  55319. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  55320. } else {
  55321. try {
  55322. $this->isRecursive = true;
  55323. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  55324. $this->isRecursive = false;
  55325. } catch (\Exception $e) {
  55326. $this->isRecursive = false;
  55327. throw $e;
  55328. } catch (\Throwable $e) {
  55329. $this->isRecursive = false;
  55330. throw $e;
  55331. }
  55332. }
  55333. return !$silenced && $type && $log;
  55334. }
  55335. public function handleException($exception, array $error = null)
  55336. {
  55337. if (null === $error) {
  55338. self::$exitCode = 255;
  55339. }
  55340. if (!$exception instanceof \Exception) {
  55341. $exception = new FatalThrowableError($exception);
  55342. }
  55343. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  55344. $handlerException = null;
  55345. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  55346. $e = array(
  55347. 'type' => $type,
  55348. 'file' => $exception->getFile(),
  55349. 'line' => $exception->getLine(),
  55350. 'level' => error_reporting(),
  55351. 'stack' => $exception->getTrace(),
  55352. );
  55353. if ($exception instanceof FatalErrorException) {
  55354. if ($exception instanceof FatalThrowableError) {
  55355. $error = array(
  55356. 'type' => $type,
  55357. 'message' => $message = $exception->getMessage(),
  55358. 'file' => $e['file'],
  55359. 'line' => $e['line'],
  55360. );
  55361. } else {
  55362. $message = 'Fatal '.$exception->getMessage();
  55363. }
  55364. } elseif ($exception instanceof \ErrorException) {
  55365. $message = 'Uncaught '.$exception->getMessage();
  55366. if ($exception instanceof ContextErrorException) {
  55367. $e['context'] = $exception->getContext();
  55368. }
  55369. } else {
  55370. $message = 'Uncaught Exception: '.$exception->getMessage();
  55371. }
  55372. }
  55373. if ($this->loggedErrors & $type) {
  55374. try {
  55375. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  55376. } catch (\Exception $handlerException) {
  55377. } catch (\Throwable $handlerException) {
  55378. }
  55379. }
  55380. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  55381. foreach ($this->getFatalErrorHandlers() as $handler) {
  55382. if ($e = $handler->handleError($error, $exception)) {
  55383. $exception = $e;
  55384. break;
  55385. }
  55386. }
  55387. }
  55388. $exceptionHandler = $this->exceptionHandler;
  55389. $this->exceptionHandler = null;
  55390. try {
  55391. if (null !== $exceptionHandler) {
  55392. return \call_user_func($exceptionHandler, $exception);
  55393. }
  55394. $handlerException = $handlerException ?: $exception;
  55395. } catch (\Exception $handlerException) {
  55396. } catch (\Throwable $handlerException) {
  55397. }
  55398. if ($exception === $handlerException) {
  55399. self::$reservedMemory = null;
  55400. throw $exception;
  55401. }
  55402. $this->handleException($handlerException);
  55403. }
  55404. public static function handleFatalError(array $error = null)
  55405. {
  55406. if (null === self::$reservedMemory) {
  55407. return;
  55408. }
  55409. $handler = self::$reservedMemory = null;
  55410. $handlers = array();
  55411. $previousHandler = null;
  55412. $sameHandlerLimit = 10;
  55413. while (!\is_array($handler) || !$handler[0] instanceof self) {
  55414. $handler = set_exception_handler('var_dump');
  55415. restore_exception_handler();
  55416. if (!$handler) {
  55417. break;
  55418. }
  55419. restore_exception_handler();
  55420. if ($handler !== $previousHandler) {
  55421. array_unshift($handlers, $handler);
  55422. $previousHandler = $handler;
  55423. } elseif (0 === --$sameHandlerLimit) {
  55424. $handler = null;
  55425. break;
  55426. }
  55427. }
  55428. foreach ($handlers as $h) {
  55429. set_exception_handler($h);
  55430. }
  55431. if (!$handler) {
  55432. return;
  55433. }
  55434. if ($handler !== $h) {
  55435. $handler[0]->setExceptionHandler($h);
  55436. }
  55437. $handler = $handler[0];
  55438. $handlers = array();
  55439. if ($exit = null === $error) {
  55440. $error = error_get_last();
  55441. }
  55442. try {
  55443. while (self::$stackedErrorLevels) {
  55444. static::unstackErrors();
  55445. }
  55446. } catch (\Exception $exception) {
  55447. } catch (\Throwable $exception) {
  55448. }
  55449. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  55450. $handler->throwAt(0, true);
  55451. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  55452. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  55453. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  55454. } else {
  55455. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  55456. }
  55457. }
  55458. try {
  55459. if (isset($exception)) {
  55460. self::$exitCode = 255;
  55461. $handler->handleException($exception, $error);
  55462. }
  55463. } catch (FatalErrorException $e) {
  55464. }
  55465. if ($exit && self::$exitCode) {
  55466. $exitCode = self::$exitCode;
  55467. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  55468. }
  55469. }
  55470. public static function stackErrors()
  55471. {
  55472. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  55473. }
  55474. public static function unstackErrors()
  55475. {
  55476. $level = array_pop(self::$stackedErrorLevels);
  55477. if (null !== $level) {
  55478. $e = error_reporting($level);
  55479. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  55480. error_reporting($e);
  55481. }
  55482. }
  55483. if (empty(self::$stackedErrorLevels)) {
  55484. $errors = self::$stackedErrors;
  55485. self::$stackedErrors = array();
  55486. foreach ($errors as $e) {
  55487. $e[0]->log($e[1], $e[2], $e[3]);
  55488. }
  55489. }
  55490. }
  55491. protected function getFatalErrorHandlers()
  55492. {
  55493. return array(
  55494. new UndefinedFunctionFatalErrorHandler(),
  55495. new UndefinedMethodFatalErrorHandler(),
  55496. new ClassNotFoundFatalErrorHandler(),
  55497. );
  55498. }
  55499. public function setLevel($level)
  55500. {
  55501. @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);
  55502. $level = null === $level ? error_reporting() : $level;
  55503. $this->throwAt($level, true);
  55504. }
  55505. public function setDisplayErrors($displayErrors)
  55506. {
  55507. @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);
  55508. if ($displayErrors) {
  55509. $this->throwAt($this->displayErrors, true);
  55510. } else {
  55511. $displayErrors = $this->displayErrors;
  55512. $this->throwAt(0, true);
  55513. $this->displayErrors = $displayErrors;
  55514. }
  55515. }
  55516. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  55517. {
  55518. @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);
  55519. $handler = set_error_handler('var_dump');
  55520. $handler = \is_array($handler) ? $handler[0] : null;
  55521. restore_error_handler();
  55522. if (!$handler instanceof self) {
  55523. return;
  55524. }
  55525. if ('deprecation' === $channel) {
  55526. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  55527. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  55528. } elseif ('scream' === $channel) {
  55529. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  55530. $handler->screamAt(E_ALL | E_STRICT);
  55531. } elseif ('emergency' === $channel) {
  55532. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  55533. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  55534. }
  55535. }
  55536. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  55537. {
  55538. $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());
  55539. return $this->handleError($level, $message, $file, $line, (array) $context);
  55540. }
  55541. public function handleFatal()
  55542. {
  55543. @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);
  55544. static::handleFatalError();
  55545. }
  55546. }
  55547. class ErrorHandlerCanary
  55548. {
  55549. private static $displayErrors = null;
  55550. public function __construct()
  55551. {
  55552. if (null === self::$displayErrors) {
  55553. self::$displayErrors = ini_set('display_errors', 1);
  55554. }
  55555. }
  55556. public function __destruct()
  55557. {
  55558. if (null !== self::$displayErrors) {
  55559. ini_set('display_errors', self::$displayErrors);
  55560. self::$displayErrors = null;
  55561. }
  55562. }
  55563. }
  55564. <?php
  55565. namespace Symfony\Component\Debug\Exception;
  55566. class ClassNotFoundException extends FatalErrorException
  55567. {
  55568. public function __construct($message, \ErrorException $previous)
  55569. {
  55570. parent::__construct(
  55571. $message,
  55572. $previous->getCode(),
  55573. $previous->getSeverity(),
  55574. $previous->getFile(),
  55575. $previous->getLine(),
  55576. null,
  55577. true,
  55578. null,
  55579. $previous->getPrevious()
  55580. );
  55581. $this->setTrace($previous->getTrace());
  55582. }
  55583. }
  55584. <?php
  55585. namespace Symfony\Component\Debug\Exception;
  55586. class ContextErrorException extends \ErrorException
  55587. {
  55588. private $context = array();
  55589. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  55590. {
  55591. parent::__construct($message, $code, $severity, $filename, $lineno);
  55592. $this->context = $context;
  55593. }
  55594. public function getContext()
  55595. {
  55596. return $this->context;
  55597. }
  55598. }
  55599. <?php
  55600. namespace Symfony\Component\Debug\Exception;
  55601. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  55602. class DummyException extends \ErrorException
  55603. {
  55604. }
  55605. <?php
  55606. namespace Symfony\Component\HttpKernel\Exception;
  55607. class FatalErrorException extends \ErrorException
  55608. {
  55609. }
  55610. namespace Symfony\Component\Debug\Exception;
  55611. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  55612. class FatalErrorException extends LegacyFatalErrorException
  55613. {
  55614. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  55615. {
  55616. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  55617. if (null !== $trace) {
  55618. if (!$traceArgs) {
  55619. foreach ($trace as &$frame) {
  55620. unset($frame['args'], $frame['this'], $frame);
  55621. }
  55622. }
  55623. $this->setTrace($trace);
  55624. } elseif (null !== $traceOffset) {
  55625. if (\function_exists('xdebug_get_function_stack')) {
  55626. $trace = xdebug_get_function_stack();
  55627. if (0 < $traceOffset) {
  55628. array_splice($trace, -$traceOffset);
  55629. }
  55630. foreach ($trace as &$frame) {
  55631. if (!isset($frame['type'])) {
  55632. if (isset($frame['class'])) {
  55633. $frame['type'] = '::';
  55634. }
  55635. } elseif ('dynamic' === $frame['type']) {
  55636. $frame['type'] = '->';
  55637. } elseif ('static' === $frame['type']) {
  55638. $frame['type'] = '::';
  55639. }
  55640. if (!$traceArgs) {
  55641. unset($frame['params'], $frame['args']);
  55642. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  55643. $frame['args'] = $frame['params'];
  55644. unset($frame['params']);
  55645. }
  55646. }
  55647. unset($frame);
  55648. $trace = array_reverse($trace);
  55649. } elseif (\function_exists('symfony_debug_backtrace')) {
  55650. $trace = symfony_debug_backtrace();
  55651. if (0 < $traceOffset) {
  55652. array_splice($trace, 0, $traceOffset);
  55653. }
  55654. } else {
  55655. $trace = array();
  55656. }
  55657. $this->setTrace($trace);
  55658. }
  55659. }
  55660. protected function setTrace($trace)
  55661. {
  55662. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  55663. $traceReflector->setAccessible(true);
  55664. $traceReflector->setValue($this, $trace);
  55665. }
  55666. }
  55667. <?php
  55668. namespace Symfony\Component\Debug\Exception;
  55669. class FatalThrowableError extends FatalErrorException
  55670. {
  55671. public function __construct(\Throwable $e)
  55672. {
  55673. if ($e instanceof \ParseError) {
  55674. $message = 'Parse error: '.$e->getMessage();
  55675. $severity = E_PARSE;
  55676. } elseif ($e instanceof \TypeError) {
  55677. $message = 'Type error: '.$e->getMessage();
  55678. $severity = E_RECOVERABLE_ERROR;
  55679. } else {
  55680. $message = $e->getMessage();
  55681. $severity = E_ERROR;
  55682. }
  55683. \ErrorException::__construct(
  55684. $message,
  55685. $e->getCode(),
  55686. $severity,
  55687. $e->getFile(),
  55688. $e->getLine(),
  55689. $e->getPrevious()
  55690. );
  55691. $this->setTrace($e->getTrace());
  55692. }
  55693. }
  55694. <?php
  55695. namespace Symfony\Component\HttpKernel\Exception;
  55696. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  55697. class FlattenException
  55698. {
  55699. private $handler;
  55700. public static function __callStatic($method, $args)
  55701. {
  55702. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  55703. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  55704. }
  55705. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  55706. }
  55707. public function __call($method, $args)
  55708. {
  55709. if (!isset($this->handler)) {
  55710. $this->handler = new DebugFlattenException();
  55711. }
  55712. if (!method_exists($this->handler, $method)) {
  55713. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  55714. }
  55715. return \call_user_func_array(array($this->handler, $method), $args);
  55716. }
  55717. }
  55718. namespace Symfony\Component\Debug\Exception;
  55719. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  55720. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  55721. class FlattenException extends LegacyFlattenException
  55722. {
  55723. private $message;
  55724. private $code;
  55725. private $previous;
  55726. private $trace;
  55727. private $class;
  55728. private $statusCode;
  55729. private $headers;
  55730. private $file;
  55731. private $line;
  55732. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  55733. {
  55734. $e = new static();
  55735. $e->setMessage($exception->getMessage());
  55736. $e->setCode($exception->getCode());
  55737. if ($exception instanceof HttpExceptionInterface) {
  55738. $statusCode = $exception->getStatusCode();
  55739. $headers = array_merge($headers, $exception->getHeaders());
  55740. }
  55741. if (null === $statusCode) {
  55742. $statusCode = 500;
  55743. }
  55744. $e->setStatusCode($statusCode);
  55745. $e->setHeaders($headers);
  55746. $e->setTraceFromException($exception);
  55747. $e->setClass(\get_class($exception));
  55748. $e->setFile($exception->getFile());
  55749. $e->setLine($exception->getLine());
  55750. $previous = $exception->getPrevious();
  55751. if ($previous instanceof \Exception) {
  55752. $e->setPrevious(static::create($previous));
  55753. } elseif ($previous instanceof \Throwable) {
  55754. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  55755. }
  55756. return $e;
  55757. }
  55758. public function toArray()
  55759. {
  55760. $exceptions = array();
  55761. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  55762. $exceptions[] = array(
  55763. 'message' => $exception->getMessage(),
  55764. 'class' => $exception->getClass(),
  55765. 'trace' => $exception->getTrace(),
  55766. );
  55767. }
  55768. return $exceptions;
  55769. }
  55770. public function getStatusCode()
  55771. {
  55772. return $this->statusCode;
  55773. }
  55774. public function setStatusCode($code)
  55775. {
  55776. $this->statusCode = $code;
  55777. }
  55778. public function getHeaders()
  55779. {
  55780. return $this->headers;
  55781. }
  55782. public function setHeaders(array $headers)
  55783. {
  55784. $this->headers = $headers;
  55785. }
  55786. public function getClass()
  55787. {
  55788. return $this->class;
  55789. }
  55790. public function setClass($class)
  55791. {
  55792. $this->class = $class;
  55793. }
  55794. public function getFile()
  55795. {
  55796. return $this->file;
  55797. }
  55798. public function setFile($file)
  55799. {
  55800. $this->file = $file;
  55801. }
  55802. public function getLine()
  55803. {
  55804. return $this->line;
  55805. }
  55806. public function setLine($line)
  55807. {
  55808. $this->line = $line;
  55809. }
  55810. public function getMessage()
  55811. {
  55812. return $this->message;
  55813. }
  55814. public function setMessage($message)
  55815. {
  55816. $this->message = $message;
  55817. }
  55818. public function getCode()
  55819. {
  55820. return $this->code;
  55821. }
  55822. public function setCode($code)
  55823. {
  55824. $this->code = $code;
  55825. }
  55826. public function getPrevious()
  55827. {
  55828. return $this->previous;
  55829. }
  55830. public function setPrevious(FlattenException $previous)
  55831. {
  55832. $this->previous = $previous;
  55833. }
  55834. public function getAllPrevious()
  55835. {
  55836. $exceptions = array();
  55837. $e = $this;
  55838. while ($e = $e->getPrevious()) {
  55839. $exceptions[] = $e;
  55840. }
  55841. return $exceptions;
  55842. }
  55843. public function getTrace()
  55844. {
  55845. return $this->trace;
  55846. }
  55847. public function setTraceFromException(\Exception $exception)
  55848. {
  55849. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  55850. }
  55851. public function setTrace($trace, $file, $line)
  55852. {
  55853. $this->trace = array();
  55854. $this->trace[] = array(
  55855. 'namespace' => '',
  55856. 'short_class' => '',
  55857. 'class' => '',
  55858. 'type' => '',
  55859. 'function' => '',
  55860. 'file' => $file,
  55861. 'line' => $line,
  55862. 'args' => array(),
  55863. );
  55864. foreach ($trace as $entry) {
  55865. $class = '';
  55866. $namespace = '';
  55867. if (isset($entry['class'])) {
  55868. $parts = explode('\\', $entry['class']);
  55869. $class = array_pop($parts);
  55870. $namespace = implode('\\', $parts);
  55871. }
  55872. $this->trace[] = array(
  55873. 'namespace' => $namespace,
  55874. 'short_class' => $class,
  55875. 'class' => isset($entry['class']) ? $entry['class'] : '',
  55876. 'type' => isset($entry['type']) ? $entry['type'] : '',
  55877. 'function' => isset($entry['function']) ? $entry['function'] : null,
  55878. 'file' => isset($entry['file']) ? $entry['file'] : null,
  55879. 'line' => isset($entry['line']) ? $entry['line'] : null,
  55880. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  55881. );
  55882. }
  55883. }
  55884. private function flattenArgs($args, $level = 0, &$count = 0)
  55885. {
  55886. $result = array();
  55887. foreach ($args as $key => $value) {
  55888. if (++$count > 1e4) {
  55889. return array('array', '*SKIPPED over 10000 entries*');
  55890. }
  55891. if ($value instanceof \__PHP_Incomplete_Class) {
  55892. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  55893. } elseif (\is_object($value)) {
  55894. $result[$key] = array('object', \get_class($value));
  55895. } elseif (\is_array($value)) {
  55896. if ($level > 10) {
  55897. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  55898. } else {
  55899. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  55900. }
  55901. } elseif (null === $value) {
  55902. $result[$key] = array('null', null);
  55903. } elseif (\is_bool($value)) {
  55904. $result[$key] = array('boolean', $value);
  55905. } elseif (\is_resource($value)) {
  55906. $result[$key] = array('resource', get_resource_type($value));
  55907. } else {
  55908. $result[$key] = array('string', (string) $value);
  55909. }
  55910. }
  55911. return $result;
  55912. }
  55913. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  55914. {
  55915. $array = new \ArrayObject($value);
  55916. return $array['__PHP_Incomplete_Class_Name'];
  55917. }
  55918. }
  55919. <?php
  55920. namespace Symfony\Component\Debug\Exception;
  55921. class OutOfMemoryException extends FatalErrorException
  55922. {
  55923. }
  55924. <?php
  55925. namespace Symfony\Component\Debug\Exception;
  55926. class UndefinedFunctionException extends FatalErrorException
  55927. {
  55928. public function __construct($message, \ErrorException $previous)
  55929. {
  55930. parent::__construct(
  55931. $message,
  55932. $previous->getCode(),
  55933. $previous->getSeverity(),
  55934. $previous->getFile(),
  55935. $previous->getLine(),
  55936. null,
  55937. true,
  55938. null,
  55939. $previous->getPrevious()
  55940. );
  55941. $this->setTrace($previous->getTrace());
  55942. }
  55943. }
  55944. <?php
  55945. namespace Symfony\Component\Debug\Exception;
  55946. class UndefinedMethodException extends FatalErrorException
  55947. {
  55948. public function __construct($message, \ErrorException $previous)
  55949. {
  55950. parent::__construct(
  55951. $message,
  55952. $previous->getCode(),
  55953. $previous->getSeverity(),
  55954. $previous->getFile(),
  55955. $previous->getLine(),
  55956. null,
  55957. true,
  55958. null,
  55959. $previous->getPrevious()
  55960. );
  55961. $this->setTrace($previous->getTrace());
  55962. }
  55963. }
  55964. <?php
  55965. namespace Symfony\Component\Debug;
  55966. use Symfony\Component\Debug\Exception\FlattenException;
  55967. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  55968. use Symfony\Component\HttpFoundation\Response;
  55969. class ExceptionHandler
  55970. {
  55971. private $debug;
  55972. private $charset;
  55973. private $handler;
  55974. private $caughtBuffer;
  55975. private $caughtLength;
  55976. private $fileLinkFormat;
  55977. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  55978. {
  55979. if (false !== strpos($charset, '%')) {
  55980. @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);
  55981. $pivot = $fileLinkFormat;
  55982. $fileLinkFormat = $charset;
  55983. $charset = $pivot;
  55984. }
  55985. $this->debug = $debug;
  55986. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  55987. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  55988. }
  55989. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  55990. {
  55991. $handler = new static($debug, $charset, $fileLinkFormat);
  55992. $prev = set_exception_handler(array($handler, 'handle'));
  55993. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  55994. restore_exception_handler();
  55995. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  55996. }
  55997. return $handler;
  55998. }
  55999. public function setHandler($handler)
  56000. {
  56001. if (null !== $handler && !\is_callable($handler)) {
  56002. throw new \LogicException('The exception handler must be a valid PHP callable.');
  56003. }
  56004. $old = $this->handler;
  56005. $this->handler = $handler;
  56006. return $old;
  56007. }
  56008. public function setFileLinkFormat($format)
  56009. {
  56010. $old = $this->fileLinkFormat;
  56011. $this->fileLinkFormat = $format;
  56012. return $old;
  56013. }
  56014. public function handle(\Exception $exception)
  56015. {
  56016. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  56017. $this->failSafeHandle($exception);
  56018. return;
  56019. }
  56020. $caughtLength = $this->caughtLength = 0;
  56021. ob_start(array($this, 'catchOutput'));
  56022. $this->failSafeHandle($exception);
  56023. while (null === $this->caughtBuffer && ob_end_flush()) {
  56024. }
  56025. if (isset($this->caughtBuffer[0])) {
  56026. ob_start(array($this, 'cleanOutput'));
  56027. echo $this->caughtBuffer;
  56028. $caughtLength = ob_get_length();
  56029. }
  56030. $this->caughtBuffer = null;
  56031. try {
  56032. \call_user_func($this->handler, $exception);
  56033. $this->caughtLength = $caughtLength;
  56034. } catch (\Exception $e) {
  56035. if (!$caughtLength) {
  56036. throw $exception;
  56037. }
  56038. }
  56039. }
  56040. private function failSafeHandle(\Exception $exception)
  56041. {
  56042. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  56043. && __CLASS__ !== \get_class($this)
  56044. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  56045. && __CLASS__ !== $reflector->class
  56046. ) {
  56047. $response = $this->createResponse($exception);
  56048. $response->sendHeaders();
  56049. $response->sendContent();
  56050. @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);
  56051. return;
  56052. }
  56053. $this->sendPhpResponse($exception);
  56054. }
  56055. public function sendPhpResponse($exception)
  56056. {
  56057. if (!$exception instanceof FlattenException) {
  56058. $exception = FlattenException::create($exception);
  56059. }
  56060. if (!headers_sent()) {
  56061. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  56062. foreach ($exception->getHeaders() as $name => $value) {
  56063. header($name.': '.$value, false);
  56064. }
  56065. header('Content-Type: text/html; charset='.$this->charset);
  56066. }
  56067. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  56068. }
  56069. public function createResponse($exception)
  56070. {
  56071. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  56072. if (!$exception instanceof FlattenException) {
  56073. $exception = FlattenException::create($exception);
  56074. }
  56075. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  56076. }
  56077. public function getHtml($exception)
  56078. {
  56079. if (!$exception instanceof FlattenException) {
  56080. $exception = FlattenException::create($exception);
  56081. }
  56082. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  56083. }
  56084. public function getContent(FlattenException $exception)
  56085. {
  56086. switch ($exception->getStatusCode()) {
  56087. case 404:
  56088. $title = 'Sorry, the page you are looking for could not be found.';
  56089. break;
  56090. default:
  56091. $title = 'Whoops, looks like something went wrong.';
  56092. }
  56093. $content = '';
  56094. if ($this->debug) {
  56095. try {
  56096. $count = \count($exception->getAllPrevious());
  56097. $total = $count + 1;
  56098. foreach ($exception->toArray() as $position => $e) {
  56099. $ind = $count - $position + 1;
  56100. $class = $this->formatClass($e['class']);
  56101. $message = nl2br($this->escapeHtml($e['message']));
  56102. $content .= sprintf(<<<'EOF'
  56103. <h2 class="block_exception clear_fix">
  56104. <span class="exception_counter">%d/%d</span>
  56105. <span class="exception_title">%s%s:</span>
  56106. <span class="exception_message">%s</span>
  56107. </h2>
  56108. <div class="block">
  56109. <ol class="traces list_exception">
  56110. EOF
  56111. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  56112. foreach ($e['trace'] as $trace) {
  56113. $content .= ' <li>';
  56114. if ($trace['function']) {
  56115. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  56116. }
  56117. if (isset($trace['file']) && isset($trace['line'])) {
  56118. $content .= $this->formatPath($trace['file'], $trace['line']);
  56119. }
  56120. $content .= "</li>\n";
  56121. }
  56122. $content .= " </ol>\n</div>\n";
  56123. }
  56124. } catch (\Exception $e) {
  56125. if ($this->debug) {
  56126. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  56127. } else {
  56128. $title = 'Whoops, looks like something went wrong.';
  56129. }
  56130. }
  56131. }
  56132. return <<<EOF
  56133. <div id="sf-resetcontent" class="sf-reset">
  56134. <h1>$title</h1>
  56135. $content
  56136. </div>
  56137. EOF;
  56138. }
  56139. public function getStylesheet(FlattenException $exception)
  56140. {
  56141. return <<<'EOF'
  56142. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  56143. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  56144. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  56145. .sf-reset .clear_fix { display:inline-block; }
  56146. .sf-reset * html .clear_fix { height:1%; }
  56147. .sf-reset .clear_fix { display:block; }
  56148. .sf-reset, .sf-reset .block { margin: auto }
  56149. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  56150. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  56151. .sf-reset strong { font-weight:bold; }
  56152. .sf-reset a { color:#6c6159; cursor: default; }
  56153. .sf-reset a img { border:none; }
  56154. .sf-reset a:hover { text-decoration:underline; }
  56155. .sf-reset em { font-style:italic; }
  56156. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  56157. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  56158. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  56159. .sf-reset .exception_message { margin-left: 3em; display: block; }
  56160. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  56161. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  56162. -webkit-border-bottom-right-radius: 16px;
  56163. -webkit-border-bottom-left-radius: 16px;
  56164. -moz-border-radius-bottomright: 16px;
  56165. -moz-border-radius-bottomleft: 16px;
  56166. border-bottom-right-radius: 16px;
  56167. border-bottom-left-radius: 16px;
  56168. border-bottom:1px solid #ccc;
  56169. border-right:1px solid #ccc;
  56170. border-left:1px solid #ccc;
  56171. word-wrap: break-word;
  56172. }
  56173. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  56174. -webkit-border-top-left-radius: 16px;
  56175. -webkit-border-top-right-radius: 16px;
  56176. -moz-border-radius-topleft: 16px;
  56177. -moz-border-radius-topright: 16px;
  56178. border-top-left-radius: 16px;
  56179. border-top-right-radius: 16px;
  56180. border-top:1px solid #ccc;
  56181. border-right:1px solid #ccc;
  56182. border-left:1px solid #ccc;
  56183. overflow: hidden;
  56184. word-wrap: break-word;
  56185. }
  56186. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  56187. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  56188. .sf-reset ol { padding: 10px 0; }
  56189. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  56190. -webkit-border-radius: 10px;
  56191. -moz-border-radius: 10px;
  56192. border-radius: 10px;
  56193. border: 1px solid #ccc;
  56194. }
  56195. EOF;
  56196. }
  56197. private function decorate($content, $css)
  56198. {
  56199. return <<<EOF
  56200. <!DOCTYPE html>
  56201. <html>
  56202. <head>
  56203. <meta charset="{$this->charset}" />
  56204. <meta name="robots" content="noindex,nofollow" />
  56205. <style>
  56206. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  56207. 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;}
  56208. html { background: #eee; padding: 10px }
  56209. img { border: 0; }
  56210. #sf-resetcontent { width:970px; margin:0 auto; }
  56211. $css
  56212. </style>
  56213. </head>
  56214. <body>
  56215. $content
  56216. </body>
  56217. </html>
  56218. EOF;
  56219. }
  56220. private function formatClass($class)
  56221. {
  56222. $parts = explode('\\', $class);
  56223. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  56224. }
  56225. private function formatPath($path, $line)
  56226. {
  56227. $path = $this->escapeHtml($path);
  56228. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  56229. if ($linkFormat = $this->fileLinkFormat) {
  56230. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  56231. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  56232. }
  56233. 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);
  56234. }
  56235. private function formatArgs(array $args)
  56236. {
  56237. $result = array();
  56238. foreach ($args as $key => $item) {
  56239. if ('object' === $item[0]) {
  56240. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  56241. } elseif ('array' === $item[0]) {
  56242. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  56243. } elseif ('string' === $item[0]) {
  56244. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  56245. } elseif ('null' === $item[0]) {
  56246. $formattedValue = '<em>null</em>';
  56247. } elseif ('boolean' === $item[0]) {
  56248. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  56249. } elseif ('resource' === $item[0]) {
  56250. $formattedValue = '<em>resource</em>';
  56251. } else {
  56252. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  56253. }
  56254. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  56255. }
  56256. return implode(', ', $result);
  56257. }
  56258. protected static function utf8Htmlize($str)
  56259. {
  56260. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  56261. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  56262. }
  56263. private function escapeHtml($str)
  56264. {
  56265. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  56266. }
  56267. public function catchOutput($buffer)
  56268. {
  56269. $this->caughtBuffer = $buffer;
  56270. return '';
  56271. }
  56272. public function cleanOutput($buffer)
  56273. {
  56274. if ($this->caughtLength) {
  56275. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  56276. if (isset($cleanBuffer[0])) {
  56277. $buffer = $cleanBuffer;
  56278. }
  56279. }
  56280. return $buffer;
  56281. }
  56282. }
  56283. <?php
  56284. namespace Symfony\Component\Debug\FatalErrorHandler;
  56285. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  56286. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  56287. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  56288. use Symfony\Component\Debug\DebugClassLoader;
  56289. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  56290. use Symfony\Component\Debug\Exception\FatalErrorException;
  56291. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  56292. {
  56293. public function handleError(array $error, FatalErrorException $exception)
  56294. {
  56295. $messageLen = \strlen($error['message']);
  56296. $notFoundSuffix = '\' not found';
  56297. $notFoundSuffixLen = \strlen($notFoundSuffix);
  56298. if ($notFoundSuffixLen > $messageLen) {
  56299. return;
  56300. }
  56301. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  56302. return;
  56303. }
  56304. foreach (array('class', 'interface', 'trait') as $typeName) {
  56305. $prefix = ucfirst($typeName).' \'';
  56306. $prefixLen = \strlen($prefix);
  56307. if (0 !== strpos($error['message'], $prefix)) {
  56308. continue;
  56309. }
  56310. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  56311. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  56312. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  56313. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  56314. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  56315. $tail = ' for another namespace?';
  56316. } else {
  56317. $className = $fullyQualifiedClassName;
  56318. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  56319. $tail = '?';
  56320. }
  56321. if ($candidates = $this->getClassCandidates($className)) {
  56322. $tail = array_pop($candidates).'"?';
  56323. if ($candidates) {
  56324. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  56325. } else {
  56326. $tail = ' for "'.$tail;
  56327. }
  56328. }
  56329. $message .= "\nDid you forget a \"use\" statement".$tail;
  56330. return new ClassNotFoundException($message, $exception);
  56331. }
  56332. }
  56333. private function getClassCandidates($class)
  56334. {
  56335. if (!\is_array($functions = spl_autoload_functions())) {
  56336. return array();
  56337. }
  56338. $classes = array();
  56339. foreach ($functions as $function) {
  56340. if (!\is_array($function)) {
  56341. continue;
  56342. }
  56343. if ($function[0] instanceof DebugClassLoader) {
  56344. $function = $function[0]->getClassLoader();
  56345. if (\is_object($function)) {
  56346. $function = array($function);
  56347. }
  56348. if (!\is_array($function)) {
  56349. continue;
  56350. }
  56351. }
  56352. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  56353. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  56354. foreach ($paths as $path) {
  56355. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  56356. }
  56357. }
  56358. }
  56359. if ($function[0] instanceof ComposerClassLoader) {
  56360. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  56361. foreach ($paths as $path) {
  56362. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  56363. }
  56364. }
  56365. }
  56366. }
  56367. return array_unique($classes);
  56368. }
  56369. private function findClassInPath($path, $class, $prefix)
  56370. {
  56371. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  56372. return array();
  56373. }
  56374. $classes = array();
  56375. $filename = $class.'.php';
  56376. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  56377. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  56378. $classes[] = $class;
  56379. }
  56380. }
  56381. return $classes;
  56382. }
  56383. private function convertFileToClass($path, $file, $prefix)
  56384. {
  56385. $candidates = array(
  56386. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  56387. $prefix.$namespacedClass,
  56388. $prefix.'\\'.$namespacedClass,
  56389. str_replace('\\', '_', $namespacedClass),
  56390. str_replace('\\', '_', $prefix.$namespacedClass),
  56391. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  56392. );
  56393. if ($prefix) {
  56394. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  56395. }
  56396. foreach ($candidates as $candidate) {
  56397. if ($this->classExists($candidate)) {
  56398. return $candidate;
  56399. }
  56400. }
  56401. require_once $file;
  56402. foreach ($candidates as $candidate) {
  56403. if ($this->classExists($candidate)) {
  56404. return $candidate;
  56405. }
  56406. }
  56407. }
  56408. private function classExists($class)
  56409. {
  56410. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  56411. }
  56412. }
  56413. <?php
  56414. namespace Symfony\Component\Debug\FatalErrorHandler;
  56415. use Symfony\Component\Debug\Exception\FatalErrorException;
  56416. interface FatalErrorHandlerInterface
  56417. {
  56418. public function handleError(array $error, FatalErrorException $exception);
  56419. }
  56420. <?php
  56421. namespace Symfony\Component\Debug\FatalErrorHandler;
  56422. use Symfony\Component\Debug\Exception\FatalErrorException;
  56423. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  56424. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  56425. {
  56426. public function handleError(array $error, FatalErrorException $exception)
  56427. {
  56428. $messageLen = \strlen($error['message']);
  56429. $notFoundSuffix = '()';
  56430. $notFoundSuffixLen = \strlen($notFoundSuffix);
  56431. if ($notFoundSuffixLen > $messageLen) {
  56432. return;
  56433. }
  56434. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  56435. return;
  56436. }
  56437. $prefix = 'Call to undefined function ';
  56438. $prefixLen = \strlen($prefix);
  56439. if (0 !== strpos($error['message'], $prefix)) {
  56440. return;
  56441. }
  56442. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  56443. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  56444. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  56445. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  56446. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  56447. } else {
  56448. $functionName = $fullyQualifiedFunctionName;
  56449. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  56450. }
  56451. $candidates = array();
  56452. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  56453. foreach ($definedFunctionNames as $definedFunctionName) {
  56454. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  56455. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  56456. } else {
  56457. $definedFunctionNameBasename = $definedFunctionName;
  56458. }
  56459. if ($definedFunctionNameBasename === $functionName) {
  56460. $candidates[] = '\\'.$definedFunctionName;
  56461. }
  56462. }
  56463. }
  56464. if ($candidates) {
  56465. sort($candidates);
  56466. $last = array_pop($candidates).'"?';
  56467. if ($candidates) {
  56468. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  56469. } else {
  56470. $candidates = '"'.$last;
  56471. }
  56472. $message .= "\nDid you mean to call ".$candidates;
  56473. }
  56474. return new UndefinedFunctionException($message, $exception);
  56475. }
  56476. }
  56477. <?php
  56478. namespace Symfony\Component\Debug\FatalErrorHandler;
  56479. use Symfony\Component\Debug\Exception\FatalErrorException;
  56480. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  56481. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  56482. {
  56483. public function handleError(array $error, FatalErrorException $exception)
  56484. {
  56485. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  56486. if (!$matches) {
  56487. return;
  56488. }
  56489. $className = $matches[1];
  56490. $methodName = $matches[2];
  56491. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  56492. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  56493. return new UndefinedMethodException($message, $exception);
  56494. }
  56495. $candidates = array();
  56496. foreach ($methods as $definedMethodName) {
  56497. $lev = levenshtein($methodName, $definedMethodName);
  56498. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  56499. $candidates[] = $definedMethodName;
  56500. }
  56501. }
  56502. if ($candidates) {
  56503. sort($candidates);
  56504. $last = array_pop($candidates).'"?';
  56505. if ($candidates) {
  56506. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  56507. } else {
  56508. $candidates = '"'.$last;
  56509. }
  56510. $message .= "\nDid you mean to call ".$candidates;
  56511. }
  56512. return new UndefinedMethodException($message, $exception);
  56513. }
  56514. }
  56515. Copyright (c) 2004-2018 Fabien Potencier
  56516. Permission is hereby granted, free of charge, to any person obtaining a copy
  56517. of this software and associated documentation files (the "Software"), to deal
  56518. in the Software without restriction, including without limitation the rights
  56519. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56520. copies of the Software, and to permit persons to whom the Software is furnished
  56521. to do so, subject to the following conditions:
  56522. The above copyright notice and this permission notice shall be included in all
  56523. copies or substantial portions of the Software.
  56524. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56525. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56526. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56527. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56528. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56529. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56530. THE SOFTWARE.
  56531. <?php
  56532. namespace Symfony\Component\Filesystem\Exception;
  56533. interface ExceptionInterface
  56534. {
  56535. }
  56536. <?php
  56537. namespace Symfony\Component\Filesystem\Exception;
  56538. class FileNotFoundException extends IOException
  56539. {
  56540. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  56541. {
  56542. if (null === $message) {
  56543. if (null === $path) {
  56544. $message = 'File could not be found.';
  56545. } else {
  56546. $message = sprintf('File "%s" could not be found.', $path);
  56547. }
  56548. }
  56549. parent::__construct($message, $code, $previous, $path);
  56550. }
  56551. }
  56552. <?php
  56553. namespace Symfony\Component\Filesystem\Exception;
  56554. class IOException extends \RuntimeException implements IOExceptionInterface
  56555. {
  56556. private $path;
  56557. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  56558. {
  56559. $this->path = $path;
  56560. parent::__construct($message, $code, $previous);
  56561. }
  56562. public function getPath()
  56563. {
  56564. return $this->path;
  56565. }
  56566. }
  56567. <?php
  56568. namespace Symfony\Component\Filesystem\Exception;
  56569. interface IOExceptionInterface extends ExceptionInterface
  56570. {
  56571. public function getPath();
  56572. }
  56573. <?php
  56574. namespace Symfony\Component\Filesystem;
  56575. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  56576. use Symfony\Component\Filesystem\Exception\IOException;
  56577. class Filesystem
  56578. {
  56579. private static $lastError;
  56580. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  56581. {
  56582. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  56583. if ($originIsLocal && !is_file($originFile)) {
  56584. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  56585. }
  56586. $this->mkdir(\dirname($targetFile));
  56587. $doCopy = true;
  56588. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  56589. $doCopy = filemtime($originFile) > filemtime($targetFile);
  56590. }
  56591. if ($doCopy) {
  56592. if (false === $source = @fopen($originFile, 'r')) {
  56593. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  56594. }
  56595. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  56596. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  56597. }
  56598. $bytesCopied = stream_copy_to_stream($source, $target);
  56599. fclose($source);
  56600. fclose($target);
  56601. unset($source, $target);
  56602. if (!is_file($targetFile)) {
  56603. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  56604. }
  56605. if ($originIsLocal) {
  56606. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  56607. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  56608. 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);
  56609. }
  56610. }
  56611. }
  56612. }
  56613. public function mkdir($dirs, $mode = 0777)
  56614. {
  56615. foreach ($this->toIterator($dirs) as $dir) {
  56616. if (is_dir($dir)) {
  56617. continue;
  56618. }
  56619. if (!self::box('mkdir', $dir, $mode, true)) {
  56620. if (!is_dir($dir)) {
  56621. if (self::$lastError) {
  56622. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  56623. }
  56624. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  56625. }
  56626. }
  56627. }
  56628. }
  56629. public function exists($files)
  56630. {
  56631. $maxPathLength = PHP_MAXPATHLEN - 2;
  56632. foreach ($this->toIterator($files) as $file) {
  56633. if (\strlen($file) > $maxPathLength) {
  56634. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  56635. }
  56636. if (!file_exists($file)) {
  56637. return false;
  56638. }
  56639. }
  56640. return true;
  56641. }
  56642. public function touch($files, $time = null, $atime = null)
  56643. {
  56644. foreach ($this->toIterator($files) as $file) {
  56645. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  56646. if (true !== $touch) {
  56647. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  56648. }
  56649. }
  56650. }
  56651. public function remove($files)
  56652. {
  56653. if ($files instanceof \Traversable) {
  56654. $files = iterator_to_array($files, false);
  56655. } elseif (!\is_array($files)) {
  56656. $files = array($files);
  56657. }
  56658. $files = array_reverse($files);
  56659. foreach ($files as $file) {
  56660. if (is_link($file)) {
  56661. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  56662. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  56663. }
  56664. } elseif (is_dir($file)) {
  56665. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  56666. if (!self::box('rmdir', $file) && file_exists($file)) {
  56667. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  56668. }
  56669. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  56670. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  56671. }
  56672. }
  56673. }
  56674. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  56675. {
  56676. foreach ($this->toIterator($files) as $file) {
  56677. if (true !== @chmod($file, $mode & ~$umask)) {
  56678. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  56679. }
  56680. if ($recursive && is_dir($file) && !is_link($file)) {
  56681. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  56682. }
  56683. }
  56684. }
  56685. public function chown($files, $user, $recursive = false)
  56686. {
  56687. foreach ($this->toIterator($files) as $file) {
  56688. if ($recursive && is_dir($file) && !is_link($file)) {
  56689. $this->chown(new \FilesystemIterator($file), $user, true);
  56690. }
  56691. if (is_link($file) && \function_exists('lchown')) {
  56692. if (true !== @lchown($file, $user)) {
  56693. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56694. }
  56695. } else {
  56696. if (true !== @chown($file, $user)) {
  56697. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56698. }
  56699. }
  56700. }
  56701. }
  56702. public function chgrp($files, $group, $recursive = false)
  56703. {
  56704. foreach ($this->toIterator($files) as $file) {
  56705. if ($recursive && is_dir($file) && !is_link($file)) {
  56706. $this->chgrp(new \FilesystemIterator($file), $group, true);
  56707. }
  56708. if (is_link($file) && \function_exists('lchgrp')) {
  56709. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  56710. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56711. }
  56712. } else {
  56713. if (true !== @chgrp($file, $group)) {
  56714. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56715. }
  56716. }
  56717. }
  56718. }
  56719. public function rename($origin, $target, $overwrite = false)
  56720. {
  56721. if (!$overwrite && $this->isReadable($target)) {
  56722. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  56723. }
  56724. if (true !== @rename($origin, $target)) {
  56725. if (is_dir($origin)) {
  56726. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  56727. $this->remove($origin);
  56728. return;
  56729. }
  56730. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  56731. }
  56732. }
  56733. private function isReadable($filename)
  56734. {
  56735. $maxPathLength = PHP_MAXPATHLEN - 2;
  56736. if (\strlen($filename) > $maxPathLength) {
  56737. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  56738. }
  56739. return is_readable($filename);
  56740. }
  56741. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  56742. {
  56743. if ('\\' === \DIRECTORY_SEPARATOR) {
  56744. $originDir = strtr($originDir, '/', '\\');
  56745. $targetDir = strtr($targetDir, '/', '\\');
  56746. if ($copyOnWindows) {
  56747. $this->mirror($originDir, $targetDir);
  56748. return;
  56749. }
  56750. }
  56751. $this->mkdir(\dirname($targetDir));
  56752. if (is_link($targetDir)) {
  56753. if (readlink($targetDir) === $originDir) {
  56754. return;
  56755. }
  56756. $this->remove($targetDir);
  56757. }
  56758. if (!self::box('symlink', $originDir, $targetDir)) {
  56759. if (null !== self::$lastError) {
  56760. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  56761. 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);
  56762. }
  56763. }
  56764. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  56765. }
  56766. }
  56767. public function makePathRelative($endPath, $startPath)
  56768. {
  56769. if ('\\' === \DIRECTORY_SEPARATOR) {
  56770. $endPath = str_replace('\\', '/', $endPath);
  56771. $startPath = str_replace('\\', '/', $startPath);
  56772. }
  56773. $stripDriveLetter = function ($path) {
  56774. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  56775. return substr($path, 2);
  56776. }
  56777. return $path;
  56778. };
  56779. $endPath = $stripDriveLetter($endPath);
  56780. $startPath = $stripDriveLetter($startPath);
  56781. $startPathArr = explode('/', trim($startPath, '/'));
  56782. $endPathArr = explode('/', trim($endPath, '/'));
  56783. $normalizePathArray = function ($pathSegments, $absolute) {
  56784. $result = array();
  56785. foreach ($pathSegments as $segment) {
  56786. if ('..' === $segment && ($absolute || \count($result))) {
  56787. array_pop($result);
  56788. } elseif ('.' !== $segment) {
  56789. $result[] = $segment;
  56790. }
  56791. }
  56792. return $result;
  56793. };
  56794. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  56795. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  56796. $index = 0;
  56797. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  56798. ++$index;
  56799. }
  56800. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  56801. $depth = 0;
  56802. } else {
  56803. $depth = \count($startPathArr) - $index;
  56804. }
  56805. $traverser = str_repeat('../', $depth);
  56806. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  56807. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  56808. return '' === $relativePath ? './' : $relativePath;
  56809. }
  56810. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  56811. {
  56812. $targetDir = rtrim($targetDir, '/\\');
  56813. $originDir = rtrim($originDir, '/\\');
  56814. $originDirLen = \strlen($originDir);
  56815. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  56816. $deleteIterator = $iterator;
  56817. if (null === $deleteIterator) {
  56818. $flags = \FilesystemIterator::SKIP_DOTS;
  56819. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  56820. }
  56821. $targetDirLen = \strlen($targetDir);
  56822. foreach ($deleteIterator as $file) {
  56823. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  56824. if (!$this->exists($origin)) {
  56825. $this->remove($file);
  56826. }
  56827. }
  56828. }
  56829. $copyOnWindows = false;
  56830. if (isset($options['copy_on_windows'])) {
  56831. $copyOnWindows = $options['copy_on_windows'];
  56832. }
  56833. if (null === $iterator) {
  56834. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  56835. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  56836. }
  56837. if ($this->exists($originDir)) {
  56838. $this->mkdir($targetDir);
  56839. }
  56840. foreach ($iterator as $file) {
  56841. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  56842. if ($copyOnWindows) {
  56843. if (is_file($file)) {
  56844. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56845. } elseif (is_dir($file)) {
  56846. $this->mkdir($target);
  56847. } else {
  56848. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56849. }
  56850. } else {
  56851. if (is_link($file)) {
  56852. $this->symlink($file->getLinkTarget(), $target);
  56853. } elseif (is_dir($file)) {
  56854. $this->mkdir($target);
  56855. } elseif (is_file($file)) {
  56856. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56857. } else {
  56858. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56859. }
  56860. }
  56861. }
  56862. }
  56863. public function isAbsolutePath($file)
  56864. {
  56865. return strspn($file, '/\\', 0, 1)
  56866. || (\strlen($file) > 3 && ctype_alpha($file[0])
  56867. && ':' === substr($file, 1, 1)
  56868. && strspn($file, '/\\', 2, 1)
  56869. )
  56870. || null !== parse_url($file, PHP_URL_SCHEME)
  56871. ;
  56872. }
  56873. public function tempnam($dir, $prefix)
  56874. {
  56875. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  56876. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  56877. $tmpFile = @tempnam($hierarchy, $prefix);
  56878. if (false !== $tmpFile) {
  56879. if (null !== $scheme && 'gs' !== $scheme) {
  56880. return $scheme.'://'.$tmpFile;
  56881. }
  56882. return $tmpFile;
  56883. }
  56884. throw new IOException('A temporary file could not be created.');
  56885. }
  56886. for ($i = 0; $i < 10; ++$i) {
  56887. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  56888. $handle = @fopen($tmpFile, 'x+');
  56889. if (false === $handle) {
  56890. continue;
  56891. }
  56892. @fclose($handle);
  56893. return $tmpFile;
  56894. }
  56895. throw new IOException('A temporary file could not be created.');
  56896. }
  56897. public function dumpFile($filename, $content, $mode = 0666)
  56898. {
  56899. $dir = \dirname($filename);
  56900. if (!is_dir($dir)) {
  56901. $this->mkdir($dir);
  56902. }
  56903. if (!is_writable($dir)) {
  56904. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  56905. }
  56906. $tmpFile = $this->tempnam($dir, basename($filename));
  56907. if (false === @file_put_contents($tmpFile, $content)) {
  56908. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  56909. }
  56910. if (null !== $mode) {
  56911. if (\func_num_args() > 2) {
  56912. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  56913. }
  56914. $this->chmod($tmpFile, $mode);
  56915. } elseif (file_exists($filename)) {
  56916. @chmod($tmpFile, fileperms($filename));
  56917. }
  56918. $this->rename($tmpFile, $filename, true);
  56919. }
  56920. private function toIterator($files)
  56921. {
  56922. if (!$files instanceof \Traversable) {
  56923. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  56924. }
  56925. return $files;
  56926. }
  56927. private function getSchemeAndHierarchy($filename)
  56928. {
  56929. $components = explode('://', $filename, 2);
  56930. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  56931. }
  56932. private static function box($func)
  56933. {
  56934. self::$lastError = null;
  56935. \set_error_handler(__CLASS__.'::handleError');
  56936. try {
  56937. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  56938. \restore_error_handler();
  56939. return $result;
  56940. } catch (\Throwable $e) {
  56941. } catch (\Exception $e) {
  56942. }
  56943. \restore_error_handler();
  56944. throw $e;
  56945. }
  56946. public static function handleError($type, $msg)
  56947. {
  56948. self::$lastError = $msg;
  56949. }
  56950. }
  56951. Copyright (c) 2004-2018 Fabien Potencier
  56952. Permission is hereby granted, free of charge, to any person obtaining a copy
  56953. of this software and associated documentation files (the "Software"), to deal
  56954. in the Software without restriction, including without limitation the rights
  56955. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56956. copies of the Software, and to permit persons to whom the Software is furnished
  56957. to do so, subject to the following conditions:
  56958. The above copyright notice and this permission notice shall be included in all
  56959. copies or substantial portions of the Software.
  56960. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56961. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56962. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56963. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56964. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56965. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56966. THE SOFTWARE.
  56967. <?php
  56968. namespace Symfony\Component\Filesystem;
  56969. use Symfony\Component\Filesystem\Exception\IOException;
  56970. class LockHandler
  56971. {
  56972. private $file;
  56973. private $handle;
  56974. public function __construct($name, $lockPath = null)
  56975. {
  56976. $lockPath = $lockPath ?: sys_get_temp_dir();
  56977. if (!is_dir($lockPath)) {
  56978. $fs = new Filesystem();
  56979. $fs->mkdir($lockPath);
  56980. }
  56981. if (!is_writable($lockPath)) {
  56982. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  56983. }
  56984. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  56985. }
  56986. public function lock($blocking = false)
  56987. {
  56988. if ($this->handle) {
  56989. return true;
  56990. }
  56991. $error = null;
  56992. set_error_handler(function ($errno, $msg) use (&$error) {
  56993. $error = $msg;
  56994. });
  56995. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56996. if ($this->handle = fopen($this->file, 'x')) {
  56997. chmod($this->file, 0666);
  56998. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56999. usleep(100);
  57000. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  57001. }
  57002. }
  57003. restore_error_handler();
  57004. if (!$this->handle) {
  57005. throw new IOException($error, 0, null, $this->file);
  57006. }
  57007. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  57008. fclose($this->handle);
  57009. $this->handle = null;
  57010. return false;
  57011. }
  57012. return true;
  57013. }
  57014. public function release()
  57015. {
  57016. if ($this->handle) {
  57017. flock($this->handle, LOCK_UN | LOCK_NB);
  57018. fclose($this->handle);
  57019. $this->handle = null;
  57020. }
  57021. }
  57022. }
  57023. <?php
  57024. namespace Symfony\Component\Finder\Adapter;
  57025. @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);
  57026. abstract class AbstractAdapter implements AdapterInterface
  57027. {
  57028. protected $followLinks = false;
  57029. protected $mode = 0;
  57030. protected $minDepth = 0;
  57031. protected $maxDepth = PHP_INT_MAX;
  57032. protected $exclude = array();
  57033. protected $names = array();
  57034. protected $notNames = array();
  57035. protected $contains = array();
  57036. protected $notContains = array();
  57037. protected $sizes = array();
  57038. protected $dates = array();
  57039. protected $filters = array();
  57040. protected $sort = false;
  57041. protected $paths = array();
  57042. protected $notPaths = array();
  57043. protected $ignoreUnreadableDirs = false;
  57044. private static $areSupported = array();
  57045. public function isSupported()
  57046. {
  57047. $name = $this->getName();
  57048. if (!array_key_exists($name, self::$areSupported)) {
  57049. self::$areSupported[$name] = $this->canBeUsed();
  57050. }
  57051. return self::$areSupported[$name];
  57052. }
  57053. public function setFollowLinks($followLinks)
  57054. {
  57055. $this->followLinks = $followLinks;
  57056. return $this;
  57057. }
  57058. public function setMode($mode)
  57059. {
  57060. $this->mode = $mode;
  57061. return $this;
  57062. }
  57063. public function setDepths(array $depths)
  57064. {
  57065. $this->minDepth = 0;
  57066. $this->maxDepth = PHP_INT_MAX;
  57067. foreach ($depths as $comparator) {
  57068. switch ($comparator->getOperator()) {
  57069. case '>':
  57070. $this->minDepth = $comparator->getTarget() + 1;
  57071. break;
  57072. case '>=':
  57073. $this->minDepth = $comparator->getTarget();
  57074. break;
  57075. case '<':
  57076. $this->maxDepth = $comparator->getTarget() - 1;
  57077. break;
  57078. case '<=':
  57079. $this->maxDepth = $comparator->getTarget();
  57080. break;
  57081. default:
  57082. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  57083. }
  57084. }
  57085. return $this;
  57086. }
  57087. public function setExclude(array $exclude)
  57088. {
  57089. $this->exclude = $exclude;
  57090. return $this;
  57091. }
  57092. public function setNames(array $names)
  57093. {
  57094. $this->names = $names;
  57095. return $this;
  57096. }
  57097. public function setNotNames(array $notNames)
  57098. {
  57099. $this->notNames = $notNames;
  57100. return $this;
  57101. }
  57102. public function setContains(array $contains)
  57103. {
  57104. $this->contains = $contains;
  57105. return $this;
  57106. }
  57107. public function setNotContains(array $notContains)
  57108. {
  57109. $this->notContains = $notContains;
  57110. return $this;
  57111. }
  57112. public function setSizes(array $sizes)
  57113. {
  57114. $this->sizes = $sizes;
  57115. return $this;
  57116. }
  57117. public function setDates(array $dates)
  57118. {
  57119. $this->dates = $dates;
  57120. return $this;
  57121. }
  57122. public function setFilters(array $filters)
  57123. {
  57124. $this->filters = $filters;
  57125. return $this;
  57126. }
  57127. public function setSort($sort)
  57128. {
  57129. $this->sort = $sort;
  57130. return $this;
  57131. }
  57132. public function setPath(array $paths)
  57133. {
  57134. $this->paths = $paths;
  57135. return $this;
  57136. }
  57137. public function setNotPath(array $notPaths)
  57138. {
  57139. $this->notPaths = $notPaths;
  57140. return $this;
  57141. }
  57142. public function ignoreUnreadableDirs($ignore = true)
  57143. {
  57144. $this->ignoreUnreadableDirs = (bool) $ignore;
  57145. return $this;
  57146. }
  57147. abstract protected function canBeUsed();
  57148. }
  57149. <?php
  57150. namespace Symfony\Component\Finder\Adapter;
  57151. @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);
  57152. use Symfony\Component\Finder\Comparator\DateComparator;
  57153. use Symfony\Component\Finder\Comparator\NumberComparator;
  57154. use Symfony\Component\Finder\Exception\AccessDeniedException;
  57155. use Symfony\Component\Finder\Expression\Expression;
  57156. use Symfony\Component\Finder\Iterator;
  57157. use Symfony\Component\Finder\Shell\Command;
  57158. use Symfony\Component\Finder\Shell\Shell;
  57159. abstract class AbstractFindAdapter extends AbstractAdapter
  57160. {
  57161. protected $shell;
  57162. public function __construct()
  57163. {
  57164. $this->shell = new Shell();
  57165. }
  57166. public function searchInDirectory($dir)
  57167. {
  57168. $dir = realpath($dir);
  57169. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  57170. return new Iterator\FilePathsIterator(array(), $dir);
  57171. }
  57172. $command = Command::create();
  57173. $find = $this->buildFindCommand($command, $dir);
  57174. if ($this->followLinks) {
  57175. $find->add('-follow');
  57176. }
  57177. $find->add('-mindepth')->add($this->minDepth + 1);
  57178. if (PHP_INT_MAX !== $this->maxDepth) {
  57179. $find->add('-maxdepth')->add($this->maxDepth + 1);
  57180. }
  57181. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  57182. $find->add('-type d');
  57183. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  57184. $find->add('-type f');
  57185. }
  57186. $this->buildNamesFiltering($find, $this->names);
  57187. $this->buildNamesFiltering($find, $this->notNames, true);
  57188. $this->buildPathsFiltering($find, $dir, $this->paths);
  57189. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  57190. $this->buildSizesFiltering($find, $this->sizes);
  57191. $this->buildDatesFiltering($find, $this->dates);
  57192. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  57193. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  57194. if ($useGrep && ($this->contains || $this->notContains)) {
  57195. $grep = $command->ins('grep');
  57196. $this->buildContentFiltering($grep, $this->contains);
  57197. $this->buildContentFiltering($grep, $this->notContains, true);
  57198. }
  57199. if ($useSort) {
  57200. $this->buildSorting($command, $this->sort);
  57201. }
  57202. $command->setErrorHandler(
  57203. $this->ignoreUnreadableDirs
  57204. ? function ($stderr) { }
  57205. : function ($stderr) { throw new AccessDeniedException($stderr); }
  57206. );
  57207. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  57208. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  57209. if ($this->exclude) {
  57210. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  57211. }
  57212. if (!$useGrep && ($this->contains || $this->notContains)) {
  57213. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  57214. }
  57215. if ($this->filters) {
  57216. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  57217. }
  57218. if (!$useSort && $this->sort) {
  57219. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  57220. $iterator = $iteratorAggregate->getIterator();
  57221. }
  57222. return $iterator;
  57223. }
  57224. protected function canBeUsed()
  57225. {
  57226. return $this->shell->testCommand('find');
  57227. }
  57228. protected function buildFindCommand(Command $command, $dir)
  57229. {
  57230. return $command
  57231. ->ins('find')
  57232. ->add('find ')
  57233. ->arg($dir)
  57234. ->add('-noleaf');
  57235. }
  57236. private function buildNamesFiltering(Command $command, array $names, $not = false)
  57237. {
  57238. if (0 === \count($names)) {
  57239. return;
  57240. }
  57241. $command->add($not ? '-not' : null)->cmd('(');
  57242. foreach ($names as $i => $name) {
  57243. $expr = Expression::create($name);
  57244. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  57245. $expr = Expression::create($expr->getGlob()->toRegex(false));
  57246. }
  57247. if ($expr->isRegex()) {
  57248. $regex = $expr->getRegex();
  57249. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  57250. ->setStartFlag(false)
  57251. ->setStartJoker(true)
  57252. ->replaceJokers('[^/]');
  57253. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  57254. $regex->setEndJoker(false)->append('[^/]*');
  57255. }
  57256. }
  57257. $command
  57258. ->add($i > 0 ? '-or' : null)
  57259. ->add($expr->isRegex()
  57260. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  57261. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  57262. )
  57263. ->arg($expr->renderPattern());
  57264. }
  57265. $command->cmd(')');
  57266. }
  57267. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  57268. {
  57269. if (0 === \count($paths)) {
  57270. return;
  57271. }
  57272. $command->add($not ? '-not' : null)->cmd('(');
  57273. foreach ($paths as $i => $path) {
  57274. $expr = Expression::create($path);
  57275. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  57276. $expr = Expression::create($expr->getGlob()->toRegex(false));
  57277. }
  57278. if ($expr->isRegex()) {
  57279. $regex = $expr->getRegex();
  57280. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  57281. } else {
  57282. $expr->prepend('*')->append('*');
  57283. }
  57284. $command
  57285. ->add($i > 0 ? '-or' : null)
  57286. ->add($expr->isRegex()
  57287. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  57288. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  57289. )
  57290. ->arg($expr->renderPattern());
  57291. }
  57292. $command->cmd(')');
  57293. }
  57294. private function buildSizesFiltering(Command $command, array $sizes)
  57295. {
  57296. foreach ($sizes as $i => $size) {
  57297. $command->add($i > 0 ? '-and' : null);
  57298. switch ($size->getOperator()) {
  57299. case '<=':
  57300. $command->add('-size -'.($size->getTarget() + 1).'c');
  57301. break;
  57302. case '>=':
  57303. $command->add('-size +'.($size->getTarget() - 1).'c');
  57304. break;
  57305. case '>':
  57306. $command->add('-size +'.$size->getTarget().'c');
  57307. break;
  57308. case '!=':
  57309. $command->add('-size -'.$size->getTarget().'c');
  57310. $command->add('-size +'.$size->getTarget().'c');
  57311. break;
  57312. case '<':
  57313. default:
  57314. $command->add('-size -'.$size->getTarget().'c');
  57315. }
  57316. }
  57317. }
  57318. private function buildDatesFiltering(Command $command, array $dates)
  57319. {
  57320. foreach ($dates as $i => $date) {
  57321. $command->add($i > 0 ? '-and' : null);
  57322. $mins = (int) round((time() - $date->getTarget()) / 60);
  57323. if (0 > $mins) {
  57324. $command->add(' -mmin -0');
  57325. return;
  57326. }
  57327. switch ($date->getOperator()) {
  57328. case '<=':
  57329. $command->add('-mmin +'.($mins - 1));
  57330. break;
  57331. case '>=':
  57332. $command->add('-mmin -'.($mins + 1));
  57333. break;
  57334. case '>':
  57335. $command->add('-mmin -'.$mins);
  57336. break;
  57337. case '!=':
  57338. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  57339. break;
  57340. case '<':
  57341. default:
  57342. $command->add('-mmin +'.$mins);
  57343. }
  57344. }
  57345. }
  57346. private function buildSorting(Command $command, $sort)
  57347. {
  57348. $this->buildFormatSorting($command, $sort);
  57349. }
  57350. abstract protected function buildFormatSorting(Command $command, $sort);
  57351. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  57352. }
  57353. <?php
  57354. namespace Symfony\Component\Finder\Adapter;
  57355. interface AdapterInterface
  57356. {
  57357. public function setFollowLinks($followLinks);
  57358. public function setMode($mode);
  57359. public function setExclude(array $exclude);
  57360. public function setDepths(array $depths);
  57361. public function setNames(array $names);
  57362. public function setNotNames(array $notNames);
  57363. public function setContains(array $contains);
  57364. public function setNotContains(array $notContains);
  57365. public function setSizes(array $sizes);
  57366. public function setDates(array $dates);
  57367. public function setFilters(array $filters);
  57368. public function setSort($sort);
  57369. public function setPath(array $paths);
  57370. public function setNotPath(array $notPaths);
  57371. public function ignoreUnreadableDirs($ignore = true);
  57372. public function searchInDirectory($dir);
  57373. public function isSupported();
  57374. public function getName();
  57375. }
  57376. <?php
  57377. namespace Symfony\Component\Finder\Adapter;
  57378. @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);
  57379. use Symfony\Component\Finder\Expression\Expression;
  57380. use Symfony\Component\Finder\Iterator\SortableIterator;
  57381. use Symfony\Component\Finder\Shell\Command;
  57382. use Symfony\Component\Finder\Shell\Shell;
  57383. class BsdFindAdapter extends AbstractFindAdapter
  57384. {
  57385. public function getName()
  57386. {
  57387. return 'bsd_find';
  57388. }
  57389. protected function canBeUsed()
  57390. {
  57391. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  57392. }
  57393. protected function buildFormatSorting(Command $command, $sort)
  57394. {
  57395. switch ($sort) {
  57396. case SortableIterator::SORT_BY_NAME:
  57397. $command->ins('sort')->add('| sort');
  57398. return;
  57399. case SortableIterator::SORT_BY_TYPE:
  57400. $format = '%HT';
  57401. break;
  57402. case SortableIterator::SORT_BY_ACCESSED_TIME:
  57403. $format = '%a';
  57404. break;
  57405. case SortableIterator::SORT_BY_CHANGED_TIME:
  57406. $format = '%c';
  57407. break;
  57408. case SortableIterator::SORT_BY_MODIFIED_TIME:
  57409. $format = '%m';
  57410. break;
  57411. default:
  57412. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  57413. }
  57414. $command
  57415. ->add('-print0 | xargs -0 stat -f')
  57416. ->arg($format.'%t%N')
  57417. ->add('| sort | cut -f 2');
  57418. }
  57419. protected function buildFindCommand(Command $command, $dir)
  57420. {
  57421. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  57422. return $command;
  57423. }
  57424. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  57425. {
  57426. foreach ($contains as $contain) {
  57427. $expr = Expression::create($contain);
  57428. $command
  57429. ->add('| grep -v \'^$\'')
  57430. ->add('| xargs -I{} grep -I')
  57431. ->add($expr->isCaseSensitive() ? null : '-i')
  57432. ->add($not ? '-L' : '-l')
  57433. ->add('-Ee')->arg($expr->renderPattern())
  57434. ->add('{}')
  57435. ;
  57436. }
  57437. }
  57438. }
  57439. <?php
  57440. namespace Symfony\Component\Finder\Adapter;
  57441. @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);
  57442. use Symfony\Component\Finder\Expression\Expression;
  57443. use Symfony\Component\Finder\Iterator\SortableIterator;
  57444. use Symfony\Component\Finder\Shell\Command;
  57445. use Symfony\Component\Finder\Shell\Shell;
  57446. class GnuFindAdapter extends AbstractFindAdapter
  57447. {
  57448. public function getName()
  57449. {
  57450. return 'gnu_find';
  57451. }
  57452. protected function buildFormatSorting(Command $command, $sort)
  57453. {
  57454. switch ($sort) {
  57455. case SortableIterator::SORT_BY_NAME:
  57456. $command->ins('sort')->add('| sort');
  57457. return;
  57458. case SortableIterator::SORT_BY_TYPE:
  57459. $format = '%y';
  57460. break;
  57461. case SortableIterator::SORT_BY_ACCESSED_TIME:
  57462. $format = '%A@';
  57463. break;
  57464. case SortableIterator::SORT_BY_CHANGED_TIME:
  57465. $format = '%C@';
  57466. break;
  57467. case SortableIterator::SORT_BY_MODIFIED_TIME:
  57468. $format = '%T@';
  57469. break;
  57470. default:
  57471. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  57472. }
  57473. $command
  57474. ->get('find')
  57475. ->add('-printf')
  57476. ->arg($format.' %h/%f\\n')
  57477. ->add('| sort | cut')
  57478. ->arg('-d ')
  57479. ->arg('-f2-')
  57480. ;
  57481. }
  57482. protected function canBeUsed()
  57483. {
  57484. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  57485. }
  57486. protected function buildFindCommand(Command $command, $dir)
  57487. {
  57488. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  57489. }
  57490. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  57491. {
  57492. foreach ($contains as $contain) {
  57493. $expr = Expression::create($contain);
  57494. $command
  57495. ->add('| xargs -I{} -r grep -I')
  57496. ->add($expr->isCaseSensitive() ? null : '-i')
  57497. ->add($not ? '-L' : '-l')
  57498. ->add('-Ee')->arg($expr->renderPattern())
  57499. ->add('{}')
  57500. ;
  57501. }
  57502. }
  57503. }
  57504. <?php
  57505. namespace Symfony\Component\Finder\Adapter;
  57506. @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);
  57507. use Symfony\Component\Finder\Iterator;
  57508. class PhpAdapter extends AbstractAdapter
  57509. {
  57510. public function searchInDirectory($dir)
  57511. {
  57512. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  57513. if ($this->followLinks) {
  57514. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  57515. }
  57516. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  57517. if ($this->exclude) {
  57518. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  57519. }
  57520. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  57521. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  57522. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  57523. }
  57524. if ($this->mode) {
  57525. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  57526. }
  57527. if ($this->names || $this->notNames) {
  57528. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  57529. }
  57530. if ($this->contains || $this->notContains) {
  57531. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  57532. }
  57533. if ($this->sizes) {
  57534. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  57535. }
  57536. if ($this->dates) {
  57537. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  57538. }
  57539. if ($this->filters) {
  57540. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  57541. }
  57542. if ($this->paths || $this->notPaths) {
  57543. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  57544. }
  57545. if ($this->sort) {
  57546. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  57547. $iterator = $iteratorAggregate->getIterator();
  57548. }
  57549. return $iterator;
  57550. }
  57551. public function getName()
  57552. {
  57553. return 'php';
  57554. }
  57555. protected function canBeUsed()
  57556. {
  57557. return true;
  57558. }
  57559. }
  57560. <?php
  57561. namespace Symfony\Component\Finder\Comparator;
  57562. class Comparator
  57563. {
  57564. private $target;
  57565. private $operator = '==';
  57566. public function getTarget()
  57567. {
  57568. return $this->target;
  57569. }
  57570. public function setTarget($target)
  57571. {
  57572. $this->target = $target;
  57573. }
  57574. public function getOperator()
  57575. {
  57576. return $this->operator;
  57577. }
  57578. public function setOperator($operator)
  57579. {
  57580. if (!$operator) {
  57581. $operator = '==';
  57582. }
  57583. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  57584. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  57585. }
  57586. $this->operator = $operator;
  57587. }
  57588. public function test($test)
  57589. {
  57590. switch ($this->operator) {
  57591. case '>':
  57592. return $test > $this->target;
  57593. case '>=':
  57594. return $test >= $this->target;
  57595. case '<':
  57596. return $test < $this->target;
  57597. case '<=':
  57598. return $test <= $this->target;
  57599. case '!=':
  57600. return $test != $this->target;
  57601. }
  57602. return $test == $this->target;
  57603. }
  57604. }
  57605. <?php
  57606. namespace Symfony\Component\Finder\Comparator;
  57607. class DateComparator extends Comparator
  57608. {
  57609. public function __construct($test)
  57610. {
  57611. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  57612. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  57613. }
  57614. try {
  57615. $date = new \DateTime($matches[2]);
  57616. $target = $date->format('U');
  57617. } catch (\Exception $e) {
  57618. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  57619. }
  57620. $operator = isset($matches[1]) ? $matches[1] : '==';
  57621. if ('since' === $operator || 'after' === $operator) {
  57622. $operator = '>';
  57623. }
  57624. if ('until' === $operator || 'before' === $operator) {
  57625. $operator = '<';
  57626. }
  57627. $this->setOperator($operator);
  57628. $this->setTarget($target);
  57629. }
  57630. }
  57631. <?php
  57632. namespace Symfony\Component\Finder\Comparator;
  57633. class NumberComparator extends Comparator
  57634. {
  57635. public function __construct($test)
  57636. {
  57637. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  57638. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  57639. }
  57640. $target = $matches[2];
  57641. if (!is_numeric($target)) {
  57642. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  57643. }
  57644. if (isset($matches[3])) {
  57645. switch (strtolower($matches[3])) {
  57646. case 'k':
  57647. $target *= 1000;
  57648. break;
  57649. case 'ki':
  57650. $target *= 1024;
  57651. break;
  57652. case 'm':
  57653. $target *= 1000000;
  57654. break;
  57655. case 'mi':
  57656. $target *= 1024 * 1024;
  57657. break;
  57658. case 'g':
  57659. $target *= 1000000000;
  57660. break;
  57661. case 'gi':
  57662. $target *= 1024 * 1024 * 1024;
  57663. break;
  57664. }
  57665. }
  57666. $this->setTarget($target);
  57667. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  57668. }
  57669. }
  57670. <?php
  57671. namespace Symfony\Component\Finder\Exception;
  57672. class AccessDeniedException extends \UnexpectedValueException
  57673. {
  57674. }
  57675. <?php
  57676. namespace Symfony\Component\Finder\Exception;
  57677. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57678. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57679. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  57680. {
  57681. private $adapter;
  57682. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  57683. {
  57684. $this->adapter = $adapter;
  57685. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  57686. }
  57687. public function getAdapter()
  57688. {
  57689. return $this->adapter;
  57690. }
  57691. }
  57692. <?php
  57693. namespace Symfony\Component\Finder\Exception;
  57694. interface ExceptionInterface
  57695. {
  57696. public function getAdapter();
  57697. }
  57698. <?php
  57699. namespace Symfony\Component\Finder\Exception;
  57700. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57701. class OperationNotPermitedException extends AdapterFailureException
  57702. {
  57703. }
  57704. <?php
  57705. namespace Symfony\Component\Finder\Exception;
  57706. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57707. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57708. use Symfony\Component\Finder\Shell\Command;
  57709. class ShellCommandFailureException extends AdapterFailureException
  57710. {
  57711. private $command;
  57712. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  57713. {
  57714. $this->command = $command;
  57715. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  57716. }
  57717. public function getCommand()
  57718. {
  57719. return $this->command;
  57720. }
  57721. }
  57722. <?php
  57723. namespace Symfony\Component\Finder\Expression;
  57724. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57725. class Expression implements ValueInterface
  57726. {
  57727. const TYPE_REGEX = 1;
  57728. const TYPE_GLOB = 2;
  57729. private $value;
  57730. public static function create($expr)
  57731. {
  57732. return new self($expr);
  57733. }
  57734. public function __construct($expr)
  57735. {
  57736. try {
  57737. $this->value = Regex::create($expr);
  57738. } catch (\InvalidArgumentException $e) {
  57739. $this->value = new Glob($expr);
  57740. }
  57741. }
  57742. public function __toString()
  57743. {
  57744. return $this->render();
  57745. }
  57746. public function render()
  57747. {
  57748. return $this->value->render();
  57749. }
  57750. public function renderPattern()
  57751. {
  57752. return $this->value->renderPattern();
  57753. }
  57754. public function isCaseSensitive()
  57755. {
  57756. return $this->value->isCaseSensitive();
  57757. }
  57758. public function getType()
  57759. {
  57760. return $this->value->getType();
  57761. }
  57762. public function prepend($expr)
  57763. {
  57764. $this->value->prepend($expr);
  57765. return $this;
  57766. }
  57767. public function append($expr)
  57768. {
  57769. $this->value->append($expr);
  57770. return $this;
  57771. }
  57772. public function isRegex()
  57773. {
  57774. return self::TYPE_REGEX === $this->value->getType();
  57775. }
  57776. public function isGlob()
  57777. {
  57778. return self::TYPE_GLOB === $this->value->getType();
  57779. }
  57780. public function getGlob()
  57781. {
  57782. if (self::TYPE_GLOB !== $this->value->getType()) {
  57783. throw new \LogicException('Regex can\'t be transformed to glob.');
  57784. }
  57785. return $this->value;
  57786. }
  57787. public function getRegex()
  57788. {
  57789. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  57790. }
  57791. }
  57792. <?php
  57793. namespace Symfony\Component\Finder\Expression;
  57794. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57795. use Symfony\Component\Finder\Glob as FinderGlob;
  57796. class Glob implements ValueInterface
  57797. {
  57798. private $pattern;
  57799. public function __construct($pattern)
  57800. {
  57801. $this->pattern = $pattern;
  57802. }
  57803. public function render()
  57804. {
  57805. return $this->pattern;
  57806. }
  57807. public function renderPattern()
  57808. {
  57809. return $this->pattern;
  57810. }
  57811. public function getType()
  57812. {
  57813. return Expression::TYPE_GLOB;
  57814. }
  57815. public function isCaseSensitive()
  57816. {
  57817. return true;
  57818. }
  57819. public function prepend($expr)
  57820. {
  57821. $this->pattern = $expr.$this->pattern;
  57822. return $this;
  57823. }
  57824. public function append($expr)
  57825. {
  57826. $this->pattern .= $expr;
  57827. return $this;
  57828. }
  57829. public function isExpandable()
  57830. {
  57831. return false !== strpos($this->pattern, '{')
  57832. && false !== strpos($this->pattern, '}');
  57833. }
  57834. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  57835. {
  57836. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  57837. return new Regex($regex);
  57838. }
  57839. }
  57840. <?php
  57841. namespace Symfony\Component\Finder\Expression;
  57842. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57843. class Regex implements ValueInterface
  57844. {
  57845. const START_FLAG = '^';
  57846. const END_FLAG = '$';
  57847. const BOUNDARY = '~';
  57848. const JOKER = '.*';
  57849. const ESCAPING = '\\';
  57850. private $pattern;
  57851. private $options;
  57852. private $startFlag;
  57853. private $endFlag;
  57854. private $startJoker;
  57855. private $endJoker;
  57856. public static function create($expr)
  57857. {
  57858. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  57859. $start = substr($m[1], 0, 1);
  57860. $end = substr($m[1], -1);
  57861. if (
  57862. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  57863. || ('{' === $start && '}' === $end)
  57864. || ('(' === $start && ')' === $end)
  57865. ) {
  57866. return new self(substr($m[1], 1, -1), $m[2], $end);
  57867. }
  57868. }
  57869. throw new \InvalidArgumentException('Given expression is not a regex.');
  57870. }
  57871. public function __construct($pattern, $options = '', $delimiter = null)
  57872. {
  57873. if (null !== $delimiter) {
  57874. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  57875. }
  57876. $this->parsePattern($pattern);
  57877. $this->options = $options;
  57878. }
  57879. public function __toString()
  57880. {
  57881. return $this->render();
  57882. }
  57883. public function render()
  57884. {
  57885. return self::BOUNDARY
  57886. .$this->renderPattern()
  57887. .self::BOUNDARY
  57888. .$this->options;
  57889. }
  57890. public function renderPattern()
  57891. {
  57892. return ($this->startFlag ? self::START_FLAG : '')
  57893. .($this->startJoker ? self::JOKER : '')
  57894. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  57895. .($this->endJoker ? self::JOKER : '')
  57896. .($this->endFlag ? self::END_FLAG : '');
  57897. }
  57898. public function isCaseSensitive()
  57899. {
  57900. return !$this->hasOption('i');
  57901. }
  57902. public function getType()
  57903. {
  57904. return Expression::TYPE_REGEX;
  57905. }
  57906. public function prepend($expr)
  57907. {
  57908. $this->pattern = $expr.$this->pattern;
  57909. return $this;
  57910. }
  57911. public function append($expr)
  57912. {
  57913. $this->pattern .= $expr;
  57914. return $this;
  57915. }
  57916. public function hasOption($option)
  57917. {
  57918. return false !== strpos($this->options, $option);
  57919. }
  57920. public function addOption($option)
  57921. {
  57922. if (!$this->hasOption($option)) {
  57923. $this->options .= $option;
  57924. }
  57925. return $this;
  57926. }
  57927. public function removeOption($option)
  57928. {
  57929. $this->options = str_replace($option, '', $this->options);
  57930. return $this;
  57931. }
  57932. public function setStartFlag($startFlag)
  57933. {
  57934. $this->startFlag = $startFlag;
  57935. return $this;
  57936. }
  57937. public function hasStartFlag()
  57938. {
  57939. return $this->startFlag;
  57940. }
  57941. public function setEndFlag($endFlag)
  57942. {
  57943. $this->endFlag = (bool) $endFlag;
  57944. return $this;
  57945. }
  57946. public function hasEndFlag()
  57947. {
  57948. return $this->endFlag;
  57949. }
  57950. public function setStartJoker($startJoker)
  57951. {
  57952. $this->startJoker = $startJoker;
  57953. return $this;
  57954. }
  57955. public function hasStartJoker()
  57956. {
  57957. return $this->startJoker;
  57958. }
  57959. public function setEndJoker($endJoker)
  57960. {
  57961. $this->endJoker = (bool) $endJoker;
  57962. return $this;
  57963. }
  57964. public function hasEndJoker()
  57965. {
  57966. return $this->endJoker;
  57967. }
  57968. public function replaceJokers($replacement)
  57969. {
  57970. $replace = function ($subject) use ($replacement) {
  57971. $subject = $subject[0];
  57972. $replace = 0 === substr_count($subject, '\\') % 2;
  57973. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  57974. };
  57975. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  57976. return $this;
  57977. }
  57978. private function parsePattern($pattern)
  57979. {
  57980. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  57981. $pattern = substr($pattern, 1);
  57982. }
  57983. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  57984. $pattern = substr($pattern, 2);
  57985. }
  57986. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  57987. $pattern = substr($pattern, 0, -1);
  57988. }
  57989. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  57990. $pattern = substr($pattern, 0, -2);
  57991. }
  57992. $this->pattern = $pattern;
  57993. }
  57994. }
  57995. <?php
  57996. namespace Symfony\Component\Finder\Expression;
  57997. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57998. interface ValueInterface
  57999. {
  58000. public function render();
  58001. public function renderPattern();
  58002. public function isCaseSensitive();
  58003. public function getType();
  58004. public function prepend($expr);
  58005. public function append($expr);
  58006. }
  58007. <?php
  58008. namespace Symfony\Component\Finder;
  58009. use Symfony\Component\Finder\Adapter\AdapterInterface;
  58010. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  58011. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  58012. use Symfony\Component\Finder\Adapter\PhpAdapter;
  58013. use Symfony\Component\Finder\Comparator\DateComparator;
  58014. use Symfony\Component\Finder\Comparator\NumberComparator;
  58015. use Symfony\Component\Finder\Exception\ExceptionInterface;
  58016. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  58017. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  58018. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  58019. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  58020. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  58021. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  58022. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  58023. use Symfony\Component\Finder\Iterator\SortableIterator;
  58024. class Finder implements \IteratorAggregate, \Countable
  58025. {
  58026. const IGNORE_VCS_FILES = 1;
  58027. const IGNORE_DOT_FILES = 2;
  58028. private $mode = 0;
  58029. private $names = array();
  58030. private $notNames = array();
  58031. private $exclude = array();
  58032. private $filters = array();
  58033. private $depths = array();
  58034. private $sizes = array();
  58035. private $followLinks = false;
  58036. private $sort = false;
  58037. private $ignore = 0;
  58038. private $dirs = array();
  58039. private $dates = array();
  58040. private $iterators = array();
  58041. private $contains = array();
  58042. private $notContains = array();
  58043. private $adapters = null;
  58044. private $paths = array();
  58045. private $notPaths = array();
  58046. private $ignoreUnreadableDirs = false;
  58047. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  58048. public function __construct()
  58049. {
  58050. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  58051. }
  58052. public static function create()
  58053. {
  58054. return new static();
  58055. }
  58056. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  58057. {
  58058. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58059. $this->initDefaultAdapters();
  58060. $this->adapters[$adapter->getName()] = array(
  58061. 'adapter' => $adapter,
  58062. 'priority' => $priority,
  58063. 'selected' => false,
  58064. );
  58065. return $this->sortAdapters();
  58066. }
  58067. public function useBestAdapter()
  58068. {
  58069. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58070. $this->initDefaultAdapters();
  58071. $this->resetAdapterSelection();
  58072. return $this->sortAdapters();
  58073. }
  58074. public function setAdapter($name)
  58075. {
  58076. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58077. $this->initDefaultAdapters();
  58078. if (!isset($this->adapters[$name])) {
  58079. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  58080. }
  58081. $this->resetAdapterSelection();
  58082. $this->adapters[$name]['selected'] = true;
  58083. return $this->sortAdapters();
  58084. }
  58085. public function removeAdapters()
  58086. {
  58087. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58088. $this->adapters = array();
  58089. return $this;
  58090. }
  58091. public function getAdapters()
  58092. {
  58093. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58094. $this->initDefaultAdapters();
  58095. return array_values(array_map(function (array $adapter) {
  58096. return $adapter['adapter'];
  58097. }, $this->adapters));
  58098. }
  58099. public function directories()
  58100. {
  58101. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  58102. return $this;
  58103. }
  58104. public function files()
  58105. {
  58106. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  58107. return $this;
  58108. }
  58109. public function depth($level)
  58110. {
  58111. $this->depths[] = new Comparator\NumberComparator($level);
  58112. return $this;
  58113. }
  58114. public function date($date)
  58115. {
  58116. $this->dates[] = new Comparator\DateComparator($date);
  58117. return $this;
  58118. }
  58119. public function name($pattern)
  58120. {
  58121. $this->names[] = $pattern;
  58122. return $this;
  58123. }
  58124. public function notName($pattern)
  58125. {
  58126. $this->notNames[] = $pattern;
  58127. return $this;
  58128. }
  58129. public function contains($pattern)
  58130. {
  58131. $this->contains[] = $pattern;
  58132. return $this;
  58133. }
  58134. public function notContains($pattern)
  58135. {
  58136. $this->notContains[] = $pattern;
  58137. return $this;
  58138. }
  58139. public function path($pattern)
  58140. {
  58141. $this->paths[] = $pattern;
  58142. return $this;
  58143. }
  58144. public function notPath($pattern)
  58145. {
  58146. $this->notPaths[] = $pattern;
  58147. return $this;
  58148. }
  58149. public function size($size)
  58150. {
  58151. $this->sizes[] = new Comparator\NumberComparator($size);
  58152. return $this;
  58153. }
  58154. public function exclude($dirs)
  58155. {
  58156. $this->exclude = array_merge($this->exclude, (array) $dirs);
  58157. return $this;
  58158. }
  58159. public function ignoreDotFiles($ignoreDotFiles)
  58160. {
  58161. if ($ignoreDotFiles) {
  58162. $this->ignore |= static::IGNORE_DOT_FILES;
  58163. } else {
  58164. $this->ignore &= ~static::IGNORE_DOT_FILES;
  58165. }
  58166. return $this;
  58167. }
  58168. public function ignoreVCS($ignoreVCS)
  58169. {
  58170. if ($ignoreVCS) {
  58171. $this->ignore |= static::IGNORE_VCS_FILES;
  58172. } else {
  58173. $this->ignore &= ~static::IGNORE_VCS_FILES;
  58174. }
  58175. return $this;
  58176. }
  58177. public static function addVCSPattern($pattern)
  58178. {
  58179. foreach ((array) $pattern as $p) {
  58180. self::$vcsPatterns[] = $p;
  58181. }
  58182. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  58183. }
  58184. public function sort(\Closure $closure)
  58185. {
  58186. $this->sort = $closure;
  58187. return $this;
  58188. }
  58189. public function sortByName()
  58190. {
  58191. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  58192. return $this;
  58193. }
  58194. public function sortByType()
  58195. {
  58196. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  58197. return $this;
  58198. }
  58199. public function sortByAccessedTime()
  58200. {
  58201. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  58202. return $this;
  58203. }
  58204. public function sortByChangedTime()
  58205. {
  58206. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  58207. return $this;
  58208. }
  58209. public function sortByModifiedTime()
  58210. {
  58211. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  58212. return $this;
  58213. }
  58214. public function filter(\Closure $closure)
  58215. {
  58216. $this->filters[] = $closure;
  58217. return $this;
  58218. }
  58219. public function followLinks()
  58220. {
  58221. $this->followLinks = true;
  58222. return $this;
  58223. }
  58224. public function ignoreUnreadableDirs($ignore = true)
  58225. {
  58226. $this->ignoreUnreadableDirs = (bool) $ignore;
  58227. return $this;
  58228. }
  58229. public function in($dirs)
  58230. {
  58231. $resolvedDirs = array();
  58232. foreach ((array) $dirs as $dir) {
  58233. if (is_dir($dir)) {
  58234. $resolvedDirs[] = $this->normalizeDir($dir);
  58235. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  58236. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  58237. } else {
  58238. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  58239. }
  58240. }
  58241. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  58242. return $this;
  58243. }
  58244. public function getIterator()
  58245. {
  58246. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  58247. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  58248. }
  58249. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  58250. return $this->searchInDirectory($this->dirs[0]);
  58251. }
  58252. $iterator = new \AppendIterator();
  58253. foreach ($this->dirs as $dir) {
  58254. $iterator->append($this->searchInDirectory($dir));
  58255. }
  58256. foreach ($this->iterators as $it) {
  58257. $iterator->append($it);
  58258. }
  58259. return $iterator;
  58260. }
  58261. public function append($iterator)
  58262. {
  58263. if ($iterator instanceof \IteratorAggregate) {
  58264. $this->iterators[] = $iterator->getIterator();
  58265. } elseif ($iterator instanceof \Iterator) {
  58266. $this->iterators[] = $iterator;
  58267. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  58268. $it = new \ArrayIterator();
  58269. foreach ($iterator as $file) {
  58270. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  58271. }
  58272. $this->iterators[] = $it;
  58273. } else {
  58274. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  58275. }
  58276. return $this;
  58277. }
  58278. public function count()
  58279. {
  58280. return iterator_count($this->getIterator());
  58281. }
  58282. private function sortAdapters()
  58283. {
  58284. uasort($this->adapters, function (array $a, array $b) {
  58285. if ($a['selected'] || $b['selected']) {
  58286. return $a['selected'] ? -1 : 1;
  58287. }
  58288. return $a['priority'] > $b['priority'] ? -1 : 1;
  58289. });
  58290. return $this;
  58291. }
  58292. private function searchInDirectory($dir)
  58293. {
  58294. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  58295. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  58296. }
  58297. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  58298. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  58299. }
  58300. if ($this->adapters) {
  58301. foreach ($this->adapters as $adapter) {
  58302. if ($adapter['adapter']->isSupported()) {
  58303. try {
  58304. return $this
  58305. ->buildAdapter($adapter['adapter'])
  58306. ->searchInDirectory($dir);
  58307. } catch (ExceptionInterface $e) {
  58308. }
  58309. }
  58310. }
  58311. }
  58312. $minDepth = 0;
  58313. $maxDepth = PHP_INT_MAX;
  58314. foreach ($this->depths as $comparator) {
  58315. switch ($comparator->getOperator()) {
  58316. case '>':
  58317. $minDepth = $comparator->getTarget() + 1;
  58318. break;
  58319. case '>=':
  58320. $minDepth = $comparator->getTarget();
  58321. break;
  58322. case '<':
  58323. $maxDepth = $comparator->getTarget() - 1;
  58324. break;
  58325. case '<=':
  58326. $maxDepth = $comparator->getTarget();
  58327. break;
  58328. default:
  58329. $minDepth = $maxDepth = $comparator->getTarget();
  58330. }
  58331. }
  58332. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  58333. if ($this->followLinks) {
  58334. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  58335. }
  58336. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  58337. if ($this->exclude) {
  58338. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  58339. }
  58340. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  58341. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  58342. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  58343. }
  58344. if ($this->mode) {
  58345. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  58346. }
  58347. if ($this->names || $this->notNames) {
  58348. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  58349. }
  58350. if ($this->contains || $this->notContains) {
  58351. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  58352. }
  58353. if ($this->sizes) {
  58354. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  58355. }
  58356. if ($this->dates) {
  58357. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  58358. }
  58359. if ($this->filters) {
  58360. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  58361. }
  58362. if ($this->paths || $this->notPaths) {
  58363. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  58364. }
  58365. if ($this->sort) {
  58366. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  58367. $iterator = $iteratorAggregate->getIterator();
  58368. }
  58369. return $iterator;
  58370. }
  58371. private function buildAdapter(AdapterInterface $adapter)
  58372. {
  58373. return $adapter
  58374. ->setFollowLinks($this->followLinks)
  58375. ->setDepths($this->depths)
  58376. ->setMode($this->mode)
  58377. ->setExclude($this->exclude)
  58378. ->setNames($this->names)
  58379. ->setNotNames($this->notNames)
  58380. ->setContains($this->contains)
  58381. ->setNotContains($this->notContains)
  58382. ->setSizes($this->sizes)
  58383. ->setDates($this->dates)
  58384. ->setFilters($this->filters)
  58385. ->setSort($this->sort)
  58386. ->setPath($this->paths)
  58387. ->setNotPath($this->notPaths)
  58388. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  58389. }
  58390. private function resetAdapterSelection()
  58391. {
  58392. $this->adapters = array_map(function (array $properties) {
  58393. $properties['selected'] = false;
  58394. return $properties;
  58395. }, $this->adapters);
  58396. }
  58397. private function initDefaultAdapters()
  58398. {
  58399. if (null === $this->adapters) {
  58400. $this->adapters = array();
  58401. $this
  58402. ->addAdapter(new GnuFindAdapter())
  58403. ->addAdapter(new BsdFindAdapter())
  58404. ->addAdapter(new PhpAdapter(), -50)
  58405. ->setAdapter('php')
  58406. ;
  58407. }
  58408. }
  58409. private function normalizeDir($dir)
  58410. {
  58411. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  58412. }
  58413. }
  58414. <?php
  58415. namespace Symfony\Component\Finder;
  58416. class Glob
  58417. {
  58418. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  58419. {
  58420. $firstByte = true;
  58421. $escaping = false;
  58422. $inCurlies = 0;
  58423. $regex = '';
  58424. $sizeGlob = \strlen($glob);
  58425. for ($i = 0; $i < $sizeGlob; ++$i) {
  58426. $car = $glob[$i];
  58427. if ($firstByte) {
  58428. if ($strictLeadingDot && '.' !== $car) {
  58429. $regex .= '(?=[^\.])';
  58430. }
  58431. $firstByte = false;
  58432. }
  58433. if ('/' === $car) {
  58434. $firstByte = true;
  58435. }
  58436. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  58437. $regex .= "\\$car";
  58438. } elseif ('*' === $car) {
  58439. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  58440. } elseif ('?' === $car) {
  58441. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  58442. } elseif ('{' === $car) {
  58443. $regex .= $escaping ? '\\{' : '(';
  58444. if (!$escaping) {
  58445. ++$inCurlies;
  58446. }
  58447. } elseif ('}' === $car && $inCurlies) {
  58448. $regex .= $escaping ? '}' : ')';
  58449. if (!$escaping) {
  58450. --$inCurlies;
  58451. }
  58452. } elseif (',' === $car && $inCurlies) {
  58453. $regex .= $escaping ? ',' : '|';
  58454. } elseif ('\\' === $car) {
  58455. if ($escaping) {
  58456. $regex .= '\\\\';
  58457. $escaping = false;
  58458. } else {
  58459. $escaping = true;
  58460. }
  58461. continue;
  58462. } else {
  58463. $regex .= $car;
  58464. }
  58465. $escaping = false;
  58466. }
  58467. return $delimiter.'^'.$regex.'$'.$delimiter;
  58468. }
  58469. }
  58470. <?php
  58471. namespace Symfony\Component\Finder\Iterator;
  58472. class CustomFilterIterator extends FilterIterator
  58473. {
  58474. private $filters = array();
  58475. public function __construct(\Iterator $iterator, array $filters)
  58476. {
  58477. foreach ($filters as $filter) {
  58478. if (!\is_callable($filter)) {
  58479. throw new \InvalidArgumentException('Invalid PHP callback.');
  58480. }
  58481. }
  58482. $this->filters = $filters;
  58483. parent::__construct($iterator);
  58484. }
  58485. public function accept()
  58486. {
  58487. $fileinfo = $this->current();
  58488. foreach ($this->filters as $filter) {
  58489. if (false === \call_user_func($filter, $fileinfo)) {
  58490. return false;
  58491. }
  58492. }
  58493. return true;
  58494. }
  58495. }
  58496. <?php
  58497. namespace Symfony\Component\Finder\Iterator;
  58498. use Symfony\Component\Finder\Comparator\DateComparator;
  58499. class DateRangeFilterIterator extends FilterIterator
  58500. {
  58501. private $comparators = array();
  58502. public function __construct(\Iterator $iterator, array $comparators)
  58503. {
  58504. $this->comparators = $comparators;
  58505. parent::__construct($iterator);
  58506. }
  58507. public function accept()
  58508. {
  58509. $fileinfo = $this->current();
  58510. if (!file_exists($fileinfo->getPathname())) {
  58511. return false;
  58512. }
  58513. $filedate = $fileinfo->getMTime();
  58514. foreach ($this->comparators as $compare) {
  58515. if (!$compare->test($filedate)) {
  58516. return false;
  58517. }
  58518. }
  58519. return true;
  58520. }
  58521. }
  58522. <?php
  58523. namespace Symfony\Component\Finder\Iterator;
  58524. class DepthRangeFilterIterator extends FilterIterator
  58525. {
  58526. private $minDepth = 0;
  58527. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  58528. {
  58529. $this->minDepth = $minDepth;
  58530. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  58531. parent::__construct($iterator);
  58532. }
  58533. public function accept()
  58534. {
  58535. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  58536. }
  58537. }
  58538. <?php
  58539. namespace Symfony\Component\Finder\Iterator;
  58540. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  58541. {
  58542. private $iterator;
  58543. private $isRecursive;
  58544. private $excludedDirs = array();
  58545. private $excludedPattern;
  58546. public function __construct(\Iterator $iterator, array $directories)
  58547. {
  58548. $this->iterator = $iterator;
  58549. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  58550. $patterns = array();
  58551. foreach ($directories as $directory) {
  58552. $directory = rtrim($directory, '/');
  58553. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  58554. $patterns[] = preg_quote($directory, '#');
  58555. } else {
  58556. $this->excludedDirs[$directory] = true;
  58557. }
  58558. }
  58559. if ($patterns) {
  58560. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  58561. }
  58562. parent::__construct($iterator);
  58563. }
  58564. public function accept()
  58565. {
  58566. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  58567. return false;
  58568. }
  58569. if ($this->excludedPattern) {
  58570. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  58571. $path = str_replace('\\', '/', $path);
  58572. return !preg_match($this->excludedPattern, $path);
  58573. }
  58574. return true;
  58575. }
  58576. public function hasChildren()
  58577. {
  58578. return $this->isRecursive && $this->iterator->hasChildren();
  58579. }
  58580. public function getChildren()
  58581. {
  58582. $children = new self($this->iterator->getChildren(), array());
  58583. $children->excludedDirs = $this->excludedDirs;
  58584. $children->excludedPattern = $this->excludedPattern;
  58585. return $children;
  58586. }
  58587. }
  58588. <?php
  58589. namespace Symfony\Component\Finder\Iterator;
  58590. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58591. use Symfony\Component\Finder\SplFileInfo;
  58592. class FilePathsIterator extends \ArrayIterator
  58593. {
  58594. private $baseDir;
  58595. private $baseDirLength;
  58596. private $subPath;
  58597. private $subPathname;
  58598. private $current;
  58599. public function __construct(array $paths, $baseDir)
  58600. {
  58601. $this->baseDir = $baseDir;
  58602. $this->baseDirLength = \strlen($baseDir);
  58603. parent::__construct($paths);
  58604. }
  58605. public function __call($name, array $arguments)
  58606. {
  58607. return \call_user_func_array(array($this->current(), $name), $arguments);
  58608. }
  58609. public function current()
  58610. {
  58611. return $this->current;
  58612. }
  58613. public function key()
  58614. {
  58615. return $this->current->getPathname();
  58616. }
  58617. public function next()
  58618. {
  58619. parent::next();
  58620. $this->buildProperties();
  58621. }
  58622. public function rewind()
  58623. {
  58624. parent::rewind();
  58625. $this->buildProperties();
  58626. }
  58627. public function getSubPath()
  58628. {
  58629. return $this->subPath;
  58630. }
  58631. public function getSubPathname()
  58632. {
  58633. return $this->subPathname;
  58634. }
  58635. private function buildProperties()
  58636. {
  58637. $absolutePath = parent::current();
  58638. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  58639. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  58640. $dir = \dirname($this->subPathname);
  58641. $this->subPath = '.' === $dir ? '' : $dir;
  58642. } else {
  58643. $this->subPath = $this->subPathname = '';
  58644. }
  58645. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  58646. }
  58647. }
  58648. <?php
  58649. namespace Symfony\Component\Finder\Iterator;
  58650. class FileTypeFilterIterator extends FilterIterator
  58651. {
  58652. const ONLY_FILES = 1;
  58653. const ONLY_DIRECTORIES = 2;
  58654. private $mode;
  58655. public function __construct(\Iterator $iterator, $mode)
  58656. {
  58657. $this->mode = $mode;
  58658. parent::__construct($iterator);
  58659. }
  58660. public function accept()
  58661. {
  58662. $fileinfo = $this->current();
  58663. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  58664. return false;
  58665. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  58666. return false;
  58667. }
  58668. return true;
  58669. }
  58670. }
  58671. <?php
  58672. namespace Symfony\Component\Finder\Iterator;
  58673. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  58674. {
  58675. public function accept()
  58676. {
  58677. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  58678. return true;
  58679. }
  58680. $fileinfo = $this->current();
  58681. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  58682. return false;
  58683. }
  58684. $content = $fileinfo->getContents();
  58685. if (!$content) {
  58686. return false;
  58687. }
  58688. return $this->isAccepted($content);
  58689. }
  58690. protected function toRegex($str)
  58691. {
  58692. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58693. }
  58694. }
  58695. <?php
  58696. namespace Symfony\Component\Finder\Iterator;
  58697. use Symfony\Component\Finder\Glob;
  58698. class FilenameFilterIterator extends MultiplePcreFilterIterator
  58699. {
  58700. public function accept()
  58701. {
  58702. return $this->isAccepted($this->current()->getFilename());
  58703. }
  58704. protected function toRegex($str)
  58705. {
  58706. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  58707. }
  58708. }
  58709. <?php
  58710. namespace Symfony\Component\Finder\Iterator;
  58711. abstract class FilterIterator extends \FilterIterator
  58712. {
  58713. public function rewind()
  58714. {
  58715. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  58716. parent::rewind();
  58717. return;
  58718. }
  58719. $iterator = $this;
  58720. while ($iterator instanceof \OuterIterator) {
  58721. $innerIterator = $iterator->getInnerIterator();
  58722. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  58723. if ($innerIterator->isRewindable()) {
  58724. $innerIterator->next();
  58725. $innerIterator->rewind();
  58726. }
  58727. } elseif ($innerIterator instanceof \FilesystemIterator) {
  58728. $innerIterator->next();
  58729. $innerIterator->rewind();
  58730. }
  58731. $iterator = $innerIterator;
  58732. }
  58733. parent::rewind();
  58734. }
  58735. }
  58736. <?php
  58737. namespace Symfony\Component\Finder\Iterator;
  58738. abstract class MultiplePcreFilterIterator extends FilterIterator
  58739. {
  58740. protected $matchRegexps = array();
  58741. protected $noMatchRegexps = array();
  58742. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  58743. {
  58744. foreach ($matchPatterns as $pattern) {
  58745. $this->matchRegexps[] = $this->toRegex($pattern);
  58746. }
  58747. foreach ($noMatchPatterns as $pattern) {
  58748. $this->noMatchRegexps[] = $this->toRegex($pattern);
  58749. }
  58750. parent::__construct($iterator);
  58751. }
  58752. protected function isAccepted($string)
  58753. {
  58754. foreach ($this->noMatchRegexps as $regex) {
  58755. if (preg_match($regex, $string)) {
  58756. return false;
  58757. }
  58758. }
  58759. if ($this->matchRegexps) {
  58760. foreach ($this->matchRegexps as $regex) {
  58761. if (preg_match($regex, $string)) {
  58762. return true;
  58763. }
  58764. }
  58765. return false;
  58766. }
  58767. return true;
  58768. }
  58769. protected function isRegex($str)
  58770. {
  58771. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  58772. $start = substr($m[1], 0, 1);
  58773. $end = substr($m[1], -1);
  58774. if ($start === $end) {
  58775. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  58776. }
  58777. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  58778. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  58779. return true;
  58780. }
  58781. }
  58782. }
  58783. return false;
  58784. }
  58785. abstract protected function toRegex($str);
  58786. }
  58787. <?php
  58788. namespace Symfony\Component\Finder\Iterator;
  58789. class PathFilterIterator extends MultiplePcreFilterIterator
  58790. {
  58791. public function accept()
  58792. {
  58793. $filename = $this->current()->getRelativePathname();
  58794. if ('\\' === \DIRECTORY_SEPARATOR) {
  58795. $filename = str_replace('\\', '/', $filename);
  58796. }
  58797. return $this->isAccepted($filename);
  58798. }
  58799. protected function toRegex($str)
  58800. {
  58801. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58802. }
  58803. }
  58804. <?php
  58805. namespace Symfony\Component\Finder\Iterator;
  58806. use Symfony\Component\Finder\Exception\AccessDeniedException;
  58807. use Symfony\Component\Finder\SplFileInfo;
  58808. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  58809. {
  58810. private $ignoreUnreadableDirs;
  58811. private $rewindable;
  58812. private $rootPath;
  58813. private $subPath;
  58814. private $directorySeparator = '/';
  58815. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  58816. {
  58817. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  58818. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  58819. }
  58820. parent::__construct($path, $flags);
  58821. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  58822. $this->rootPath = (string) $path;
  58823. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  58824. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  58825. }
  58826. }
  58827. public function current()
  58828. {
  58829. if (null === $subPathname = $this->subPath) {
  58830. $subPathname = $this->subPath = (string) $this->getSubPath();
  58831. }
  58832. if ('' !== $subPathname) {
  58833. $subPathname .= $this->directorySeparator;
  58834. }
  58835. $subPathname .= $this->getFilename();
  58836. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  58837. }
  58838. public function getChildren()
  58839. {
  58840. try {
  58841. $children = parent::getChildren();
  58842. if ($children instanceof self) {
  58843. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  58844. $children->rewindable = &$this->rewindable;
  58845. $children->rootPath = $this->rootPath;
  58846. }
  58847. return $children;
  58848. } catch (\UnexpectedValueException $e) {
  58849. if ($this->ignoreUnreadableDirs) {
  58850. return new \RecursiveArrayIterator(array());
  58851. } else {
  58852. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  58853. }
  58854. }
  58855. }
  58856. public function rewind()
  58857. {
  58858. if (false === $this->isRewindable()) {
  58859. return;
  58860. }
  58861. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  58862. parent::next();
  58863. }
  58864. parent::rewind();
  58865. }
  58866. public function isRewindable()
  58867. {
  58868. if (null !== $this->rewindable) {
  58869. return $this->rewindable;
  58870. }
  58871. if ('' === $this->getPath()) {
  58872. return $this->rewindable = false;
  58873. }
  58874. if (false !== $stream = @opendir($this->getPath())) {
  58875. $infos = stream_get_meta_data($stream);
  58876. closedir($stream);
  58877. if ($infos['seekable']) {
  58878. return $this->rewindable = true;
  58879. }
  58880. }
  58881. return $this->rewindable = false;
  58882. }
  58883. }
  58884. <?php
  58885. namespace Symfony\Component\Finder\Iterator;
  58886. use Symfony\Component\Finder\Comparator\NumberComparator;
  58887. class SizeRangeFilterIterator extends FilterIterator
  58888. {
  58889. private $comparators = array();
  58890. public function __construct(\Iterator $iterator, array $comparators)
  58891. {
  58892. $this->comparators = $comparators;
  58893. parent::__construct($iterator);
  58894. }
  58895. public function accept()
  58896. {
  58897. $fileinfo = $this->current();
  58898. if (!$fileinfo->isFile()) {
  58899. return true;
  58900. }
  58901. $filesize = $fileinfo->getSize();
  58902. foreach ($this->comparators as $compare) {
  58903. if (!$compare->test($filesize)) {
  58904. return false;
  58905. }
  58906. }
  58907. return true;
  58908. }
  58909. }
  58910. <?php
  58911. namespace Symfony\Component\Finder\Iterator;
  58912. class SortableIterator implements \IteratorAggregate
  58913. {
  58914. const SORT_BY_NAME = 1;
  58915. const SORT_BY_TYPE = 2;
  58916. const SORT_BY_ACCESSED_TIME = 3;
  58917. const SORT_BY_CHANGED_TIME = 4;
  58918. const SORT_BY_MODIFIED_TIME = 5;
  58919. private $iterator;
  58920. private $sort;
  58921. public function __construct(\Traversable $iterator, $sort)
  58922. {
  58923. $this->iterator = $iterator;
  58924. if (self::SORT_BY_NAME === $sort) {
  58925. $this->sort = function ($a, $b) {
  58926. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58927. };
  58928. } elseif (self::SORT_BY_TYPE === $sort) {
  58929. $this->sort = function ($a, $b) {
  58930. if ($a->isDir() && $b->isFile()) {
  58931. return -1;
  58932. } elseif ($a->isFile() && $b->isDir()) {
  58933. return 1;
  58934. }
  58935. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58936. };
  58937. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  58938. $this->sort = function ($a, $b) {
  58939. return $a->getATime() - $b->getATime();
  58940. };
  58941. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  58942. $this->sort = function ($a, $b) {
  58943. return $a->getCTime() - $b->getCTime();
  58944. };
  58945. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  58946. $this->sort = function ($a, $b) {
  58947. return $a->getMTime() - $b->getMTime();
  58948. };
  58949. } elseif (\is_callable($sort)) {
  58950. $this->sort = $sort;
  58951. } else {
  58952. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  58953. }
  58954. }
  58955. public function getIterator()
  58956. {
  58957. $array = iterator_to_array($this->iterator, true);
  58958. uasort($array, $this->sort);
  58959. return new \ArrayIterator($array);
  58960. }
  58961. }
  58962. Copyright (c) 2004-2018 Fabien Potencier
  58963. Permission is hereby granted, free of charge, to any person obtaining a copy
  58964. of this software and associated documentation files (the "Software"), to deal
  58965. in the Software without restriction, including without limitation the rights
  58966. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58967. copies of the Software, and to permit persons to whom the Software is furnished
  58968. to do so, subject to the following conditions:
  58969. The above copyright notice and this permission notice shall be included in all
  58970. copies or substantial portions of the Software.
  58971. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58972. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58973. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58974. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58975. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58976. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58977. THE SOFTWARE.
  58978. <?php
  58979. namespace Symfony\Component\Finder\Shell;
  58980. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58981. class Command
  58982. {
  58983. private $parent;
  58984. private $bits = array();
  58985. private $labels = array();
  58986. private $errorHandler;
  58987. public function __construct(Command $parent = null)
  58988. {
  58989. $this->parent = $parent;
  58990. }
  58991. public function __toString()
  58992. {
  58993. return $this->join();
  58994. }
  58995. public static function create(Command $parent = null)
  58996. {
  58997. return new self($parent);
  58998. }
  58999. public static function escape($input)
  59000. {
  59001. return escapeshellcmd($input);
  59002. }
  59003. public static function quote($input)
  59004. {
  59005. return escapeshellarg($input);
  59006. }
  59007. public function add($bit)
  59008. {
  59009. $this->bits[] = $bit;
  59010. return $this;
  59011. }
  59012. public function top($bit)
  59013. {
  59014. array_unshift($this->bits, $bit);
  59015. foreach ($this->labels as $label => $index) {
  59016. ++$this->labels[$label];
  59017. }
  59018. return $this;
  59019. }
  59020. public function arg($arg)
  59021. {
  59022. $this->bits[] = self::quote($arg);
  59023. return $this;
  59024. }
  59025. public function cmd($esc)
  59026. {
  59027. $this->bits[] = self::escape($esc);
  59028. return $this;
  59029. }
  59030. public function ins($label)
  59031. {
  59032. if (isset($this->labels[$label])) {
  59033. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  59034. }
  59035. $this->bits[] = self::create($this);
  59036. $this->labels[$label] = \count($this->bits) - 1;
  59037. return $this->bits[$this->labels[$label]];
  59038. }
  59039. public function get($label)
  59040. {
  59041. if (!isset($this->labels[$label])) {
  59042. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  59043. }
  59044. return $this->bits[$this->labels[$label]];
  59045. }
  59046. public function end()
  59047. {
  59048. if (null === $this->parent) {
  59049. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  59050. }
  59051. return $this->parent;
  59052. }
  59053. public function length()
  59054. {
  59055. return \count($this->bits);
  59056. }
  59057. public function setErrorHandler(\Closure $errorHandler)
  59058. {
  59059. $this->errorHandler = $errorHandler;
  59060. return $this;
  59061. }
  59062. public function getErrorHandler()
  59063. {
  59064. return $this->errorHandler;
  59065. }
  59066. public function execute()
  59067. {
  59068. if (null === $errorHandler = $this->errorHandler) {
  59069. exec($this->join(), $output);
  59070. } else {
  59071. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  59072. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  59073. if ($error = stream_get_contents($pipes[2])) {
  59074. $errorHandler($error);
  59075. }
  59076. proc_close($process);
  59077. }
  59078. return $output ?: array();
  59079. }
  59080. public function join()
  59081. {
  59082. return implode(' ', array_filter(
  59083. array_map(function ($bit) {
  59084. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  59085. }, $this->bits),
  59086. function ($bit) { return null !== $bit; }
  59087. ));
  59088. }
  59089. public function addAtIndex($bit, $index)
  59090. {
  59091. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  59092. return $this;
  59093. }
  59094. }
  59095. <?php
  59096. namespace Symfony\Component\Finder\Shell;
  59097. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  59098. class Shell
  59099. {
  59100. const TYPE_UNIX = 1;
  59101. const TYPE_DARWIN = 2;
  59102. const TYPE_CYGWIN = 3;
  59103. const TYPE_WINDOWS = 4;
  59104. const TYPE_BSD = 5;
  59105. private $type;
  59106. public function getType()
  59107. {
  59108. if (null === $this->type) {
  59109. $this->type = $this->guessType();
  59110. }
  59111. return $this->type;
  59112. }
  59113. public function testCommand($command)
  59114. {
  59115. if (!\function_exists('exec')) {
  59116. return false;
  59117. }
  59118. $testCommand = 'which ';
  59119. if (self::TYPE_WINDOWS === $this->type) {
  59120. $testCommand = 'where ';
  59121. }
  59122. $command = escapeshellcmd($command);
  59123. exec($testCommand.$command, $output, $code);
  59124. return 0 === $code && \count($output) > 0;
  59125. }
  59126. private function guessType()
  59127. {
  59128. $os = strtolower(PHP_OS);
  59129. if (false !== strpos($os, 'cygwin')) {
  59130. return self::TYPE_CYGWIN;
  59131. }
  59132. if (false !== strpos($os, 'darwin')) {
  59133. return self::TYPE_DARWIN;
  59134. }
  59135. if (false !== strpos($os, 'bsd')) {
  59136. return self::TYPE_BSD;
  59137. }
  59138. if (0 === strpos($os, 'win')) {
  59139. return self::TYPE_WINDOWS;
  59140. }
  59141. return self::TYPE_UNIX;
  59142. }
  59143. }
  59144. <?php
  59145. namespace Symfony\Component\Finder;
  59146. class SplFileInfo extends \SplFileInfo
  59147. {
  59148. private $relativePath;
  59149. private $relativePathname;
  59150. public function __construct($file, $relativePath, $relativePathname)
  59151. {
  59152. parent::__construct($file);
  59153. $this->relativePath = $relativePath;
  59154. $this->relativePathname = $relativePathname;
  59155. }
  59156. public function getRelativePath()
  59157. {
  59158. return $this->relativePath;
  59159. }
  59160. public function getRelativePathname()
  59161. {
  59162. return $this->relativePathname;
  59163. }
  59164. public function getContents()
  59165. {
  59166. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  59167. $content = file_get_contents($this->getPathname());
  59168. restore_error_handler();
  59169. if (false === $content) {
  59170. throw new \RuntimeException($error);
  59171. }
  59172. return $content;
  59173. }
  59174. }
  59175. <?php
  59176. namespace Symfony\Polyfill\Ctype;
  59177. final class Ctype
  59178. {
  59179. public static function ctype_alnum($text)
  59180. {
  59181. $text = self::convert_int_to_char_for_ctype($text);
  59182. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  59183. }
  59184. public static function ctype_alpha($text)
  59185. {
  59186. $text = self::convert_int_to_char_for_ctype($text);
  59187. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  59188. }
  59189. public static function ctype_cntrl($text)
  59190. {
  59191. $text = self::convert_int_to_char_for_ctype($text);
  59192. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  59193. }
  59194. public static function ctype_digit($text)
  59195. {
  59196. $text = self::convert_int_to_char_for_ctype($text);
  59197. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  59198. }
  59199. public static function ctype_graph($text)
  59200. {
  59201. $text = self::convert_int_to_char_for_ctype($text);
  59202. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  59203. }
  59204. public static function ctype_lower($text)
  59205. {
  59206. $text = self::convert_int_to_char_for_ctype($text);
  59207. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  59208. }
  59209. public static function ctype_print($text)
  59210. {
  59211. $text = self::convert_int_to_char_for_ctype($text);
  59212. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  59213. }
  59214. public static function ctype_punct($text)
  59215. {
  59216. $text = self::convert_int_to_char_for_ctype($text);
  59217. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  59218. }
  59219. public static function ctype_space($text)
  59220. {
  59221. $text = self::convert_int_to_char_for_ctype($text);
  59222. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  59223. }
  59224. public static function ctype_upper($text)
  59225. {
  59226. $text = self::convert_int_to_char_for_ctype($text);
  59227. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  59228. }
  59229. public static function ctype_xdigit($text)
  59230. {
  59231. $text = self::convert_int_to_char_for_ctype($text);
  59232. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  59233. }
  59234. private static function convert_int_to_char_for_ctype($int)
  59235. {
  59236. if (!\is_int($int)) {
  59237. return $int;
  59238. }
  59239. if ($int < -128 || $int > 255) {
  59240. return (string) $int;
  59241. }
  59242. if ($int < 0) {
  59243. $int += 256;
  59244. }
  59245. return \chr($int);
  59246. }
  59247. }
  59248. Copyright (c) 2018-2019 Fabien Potencier
  59249. Permission is hereby granted, free of charge, to any person obtaining a copy
  59250. of this software and associated documentation files (the "Software"), to deal
  59251. in the Software without restriction, including without limitation the rights
  59252. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59253. copies of the Software, and to permit persons to whom the Software is furnished
  59254. to do so, subject to the following conditions:
  59255. The above copyright notice and this permission notice shall be included in all
  59256. copies or substantial portions of the Software.
  59257. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  59258. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59259. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59260. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59261. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  59262. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  59263. THE SOFTWARE.
  59264. <?php
  59265. use Symfony\Polyfill\Ctype as p;
  59266. if (!function_exists('ctype_alnum')) {
  59267. function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); }
  59268. }
  59269. if (!function_exists('ctype_alpha')) {
  59270. function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); }
  59271. }
  59272. if (!function_exists('ctype_cntrl')) {
  59273. function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); }
  59274. }
  59275. if (!function_exists('ctype_digit')) {
  59276. function ctype_digit($input) { return p\Ctype::ctype_digit($input); }
  59277. }
  59278. if (!function_exists('ctype_graph')) {
  59279. function ctype_graph($input) { return p\Ctype::ctype_graph($input); }
  59280. }
  59281. if (!function_exists('ctype_lower')) {
  59282. function ctype_lower($input) { return p\Ctype::ctype_lower($input); }
  59283. }
  59284. if (!function_exists('ctype_print')) {
  59285. function ctype_print($input) { return p\Ctype::ctype_print($input); }
  59286. }
  59287. if (!function_exists('ctype_punct')) {
  59288. function ctype_punct($input) { return p\Ctype::ctype_punct($input); }
  59289. }
  59290. if (!function_exists('ctype_space')) {
  59291. function ctype_space($input) { return p\Ctype::ctype_space($input); }
  59292. }
  59293. if (!function_exists('ctype_upper')) {
  59294. function ctype_upper($input) { return p\Ctype::ctype_upper($input); }
  59295. }
  59296. if (!function_exists('ctype_xdigit')) {
  59297. function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); }
  59298. }
  59299. Copyright (c) 2015-2019 Fabien Potencier
  59300. Permission is hereby granted, free of charge, to any person obtaining a copy
  59301. of this software and associated documentation files (the "Software"), to deal
  59302. in the Software without restriction, including without limitation the rights
  59303. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59304. copies of the Software, and to permit persons to whom the Software is furnished
  59305. to do so, subject to the following conditions:
  59306. The above copyright notice and this permission notice shall be included in all
  59307. copies or substantial portions of the Software.
  59308. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  59309. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59310. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59311. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59312. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  59313. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  59314. THE SOFTWARE.
  59315. <?php
  59316. namespace Symfony\Polyfill\Mbstring;
  59317. final class Mbstring
  59318. {
  59319. const MB_CASE_FOLD = PHP_INT_MAX;
  59320. private static $encodingList = array('ASCII', 'UTF-8');
  59321. private static $language = 'neutral';
  59322. private static $internalEncoding = 'UTF-8';
  59323. private static $caseFold = array(
  59324. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  59325. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  59326. );
  59327. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  59328. {
  59329. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  59330. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  59331. } else {
  59332. $fromEncoding = self::getEncoding($fromEncoding);
  59333. }
  59334. $toEncoding = self::getEncoding($toEncoding);
  59335. if ('BASE64' === $fromEncoding) {
  59336. $s = base64_decode($s);
  59337. $fromEncoding = $toEncoding;
  59338. }
  59339. if ('BASE64' === $toEncoding) {
  59340. return base64_encode($s);
  59341. }
  59342. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  59343. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  59344. $fromEncoding = 'Windows-1252';
  59345. }
  59346. if ('UTF-8' !== $fromEncoding) {
  59347. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  59348. }
  59349. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  59350. }
  59351. if ('HTML-ENTITIES' === $fromEncoding) {
  59352. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  59353. $fromEncoding = 'UTF-8';
  59354. }
  59355. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  59356. }
  59357. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  59358. {
  59359. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  59360. $ok = true;
  59361. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  59362. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  59363. $ok = false;
  59364. }
  59365. });
  59366. return $ok ? $fromEncoding : false;
  59367. }
  59368. public static function mb_decode_mimeheader($s)
  59369. {
  59370. return iconv_mime_decode($s, 2, self::$internalEncoding);
  59371. }
  59372. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  59373. {
  59374. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  59375. }
  59376. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  59377. {
  59378. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  59379. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59380. return null;
  59381. }
  59382. if (!\is_array($convmap) || !$convmap) {
  59383. return false;
  59384. }
  59385. if (null !== $encoding && !\is_scalar($encoding)) {
  59386. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59387. return '';
  59388. }
  59389. $s = (string) $s;
  59390. if ('' === $s) {
  59391. return '';
  59392. }
  59393. $encoding = self::getEncoding($encoding);
  59394. if ('UTF-8' === $encoding) {
  59395. $encoding = null;
  59396. if (!preg_match('//u', $s)) {
  59397. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59398. }
  59399. } else {
  59400. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59401. }
  59402. $cnt = floor(\count($convmap) / 4) * 4;
  59403. for ($i = 0; $i < $cnt; $i += 4) {
  59404. $convmap[$i] += $convmap[$i + 2];
  59405. $convmap[$i + 1] += $convmap[$i + 2];
  59406. }
  59407. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  59408. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  59409. for ($i = 0; $i < $cnt; $i += 4) {
  59410. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  59411. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  59412. }
  59413. }
  59414. return $m[0];
  59415. }, $s);
  59416. if (null === $encoding) {
  59417. return $s;
  59418. }
  59419. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  59420. }
  59421. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  59422. {
  59423. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  59424. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59425. return null;
  59426. }
  59427. if (!\is_array($convmap) || !$convmap) {
  59428. return false;
  59429. }
  59430. if (null !== $encoding && !\is_scalar($encoding)) {
  59431. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59432. return null;
  59433. }
  59434. if (null !== $is_hex && !\is_scalar($is_hex)) {
  59435. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  59436. return null;
  59437. }
  59438. $s = (string) $s;
  59439. if ('' === $s) {
  59440. return '';
  59441. }
  59442. $encoding = self::getEncoding($encoding);
  59443. if ('UTF-8' === $encoding) {
  59444. $encoding = null;
  59445. if (!preg_match('//u', $s)) {
  59446. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59447. }
  59448. } else {
  59449. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59450. }
  59451. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  59452. $cnt = floor(\count($convmap) / 4) * 4;
  59453. $i = 0;
  59454. $len = \strlen($s);
  59455. $result = '';
  59456. while ($i < $len) {
  59457. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  59458. $uchr = substr($s, $i, $ulen);
  59459. $i += $ulen;
  59460. $c = self::mb_ord($uchr);
  59461. for ($j = 0; $j < $cnt; $j += 4) {
  59462. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  59463. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  59464. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  59465. continue 2;
  59466. }
  59467. }
  59468. $result .= $uchr;
  59469. }
  59470. if (null === $encoding) {
  59471. return $result;
  59472. }
  59473. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  59474. }
  59475. public static function mb_convert_case($s, $mode, $encoding = null)
  59476. {
  59477. $s = (string) $s;
  59478. if ('' === $s) {
  59479. return '';
  59480. }
  59481. $encoding = self::getEncoding($encoding);
  59482. if ('UTF-8' === $encoding) {
  59483. $encoding = null;
  59484. if (!preg_match('//u', $s)) {
  59485. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59486. }
  59487. } else {
  59488. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59489. }
  59490. if (MB_CASE_TITLE == $mode) {
  59491. static $titleRegexp = null;
  59492. if (null === $titleRegexp) {
  59493. $titleRegexp = self::getData('titleCaseRegexp');
  59494. }
  59495. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  59496. } else {
  59497. if (MB_CASE_UPPER == $mode) {
  59498. static $upper = null;
  59499. if (null === $upper) {
  59500. $upper = self::getData('upperCase');
  59501. }
  59502. $map = $upper;
  59503. } else {
  59504. if (self::MB_CASE_FOLD === $mode) {
  59505. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  59506. }
  59507. static $lower = null;
  59508. if (null === $lower) {
  59509. $lower = self::getData('lowerCase');
  59510. }
  59511. $map = $lower;
  59512. }
  59513. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  59514. $i = 0;
  59515. $len = \strlen($s);
  59516. while ($i < $len) {
  59517. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  59518. $uchr = substr($s, $i, $ulen);
  59519. $i += $ulen;
  59520. if (isset($map[$uchr])) {
  59521. $uchr = $map[$uchr];
  59522. $nlen = \strlen($uchr);
  59523. if ($nlen == $ulen) {
  59524. $nlen = $i;
  59525. do {
  59526. $s[--$nlen] = $uchr[--$ulen];
  59527. } while ($ulen);
  59528. } else {
  59529. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  59530. $len += $nlen - $ulen;
  59531. $i += $nlen - $ulen;
  59532. }
  59533. }
  59534. }
  59535. }
  59536. if (null === $encoding) {
  59537. return $s;
  59538. }
  59539. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  59540. }
  59541. public static function mb_internal_encoding($encoding = null)
  59542. {
  59543. if (null === $encoding) {
  59544. return self::$internalEncoding;
  59545. }
  59546. $encoding = self::getEncoding($encoding);
  59547. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  59548. self::$internalEncoding = $encoding;
  59549. return true;
  59550. }
  59551. return false;
  59552. }
  59553. public static function mb_language($lang = null)
  59554. {
  59555. if (null === $lang) {
  59556. return self::$language;
  59557. }
  59558. switch ($lang = strtolower($lang)) {
  59559. case 'uni':
  59560. case 'neutral':
  59561. self::$language = $lang;
  59562. return true;
  59563. }
  59564. return false;
  59565. }
  59566. public static function mb_list_encodings()
  59567. {
  59568. return array('UTF-8');
  59569. }
  59570. public static function mb_encoding_aliases($encoding)
  59571. {
  59572. switch (strtoupper($encoding)) {
  59573. case 'UTF8':
  59574. case 'UTF-8':
  59575. return array('utf8');
  59576. }
  59577. return false;
  59578. }
  59579. public static function mb_check_encoding($var = null, $encoding = null)
  59580. {
  59581. if (null === $encoding) {
  59582. if (null === $var) {
  59583. return false;
  59584. }
  59585. $encoding = self::$internalEncoding;
  59586. }
  59587. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  59588. }
  59589. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  59590. {
  59591. if (null === $encodingList) {
  59592. $encodingList = self::$encodingList;
  59593. } else {
  59594. if (!\is_array($encodingList)) {
  59595. $encodingList = array_map('trim', explode(',', $encodingList));
  59596. }
  59597. $encodingList = array_map('strtoupper', $encodingList);
  59598. }
  59599. foreach ($encodingList as $enc) {
  59600. switch ($enc) {
  59601. case 'ASCII':
  59602. if (!preg_match('/[\x80-\xFF]/', $str)) {
  59603. return $enc;
  59604. }
  59605. break;
  59606. case 'UTF8':
  59607. case 'UTF-8':
  59608. if (preg_match('//u', $str)) {
  59609. return 'UTF-8';
  59610. }
  59611. break;
  59612. default:
  59613. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  59614. return $enc;
  59615. }
  59616. }
  59617. }
  59618. return false;
  59619. }
  59620. public static function mb_detect_order($encodingList = null)
  59621. {
  59622. if (null === $encodingList) {
  59623. return self::$encodingList;
  59624. }
  59625. if (!\is_array($encodingList)) {
  59626. $encodingList = array_map('trim', explode(',', $encodingList));
  59627. }
  59628. $encodingList = array_map('strtoupper', $encodingList);
  59629. foreach ($encodingList as $enc) {
  59630. switch ($enc) {
  59631. default:
  59632. if (strncmp($enc, 'ISO-8859-', 9)) {
  59633. return false;
  59634. }
  59635. case 'ASCII':
  59636. case 'UTF8':
  59637. case 'UTF-8':
  59638. }
  59639. }
  59640. self::$encodingList = $encodingList;
  59641. return true;
  59642. }
  59643. public static function mb_strlen($s, $encoding = null)
  59644. {
  59645. $encoding = self::getEncoding($encoding);
  59646. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59647. return \strlen($s);
  59648. }
  59649. return @iconv_strlen($s, $encoding);
  59650. }
  59651. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  59652. {
  59653. $encoding = self::getEncoding($encoding);
  59654. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59655. return strpos($haystack, $needle, $offset);
  59656. }
  59657. $needle = (string) $needle;
  59658. if ('' === $needle) {
  59659. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  59660. return false;
  59661. }
  59662. return iconv_strpos($haystack, $needle, $offset, $encoding);
  59663. }
  59664. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  59665. {
  59666. $encoding = self::getEncoding($encoding);
  59667. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59668. return strrpos($haystack, $needle, $offset);
  59669. }
  59670. if ($offset != (int) $offset) {
  59671. $offset = 0;
  59672. } elseif ($offset = (int) $offset) {
  59673. if ($offset < 0) {
  59674. if (0 > $offset += self::mb_strlen($needle)) {
  59675. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  59676. }
  59677. $offset = 0;
  59678. } else {
  59679. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  59680. }
  59681. }
  59682. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59683. return false !== $pos ? $offset + $pos : false;
  59684. }
  59685. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  59686. {
  59687. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
  59688. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
  59689. return null;
  59690. }
  59691. if (1 > $split_length = (int) $split_length) {
  59692. trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
  59693. return false;
  59694. }
  59695. if (null === $encoding) {
  59696. $encoding = mb_internal_encoding();
  59697. }
  59698. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  59699. $rx = '/(';
  59700. while (65535 < $split_length) {
  59701. $rx .= '.{65535}';
  59702. $split_length -= 65535;
  59703. }
  59704. $rx .= '.{'.$split_length.'})/us';
  59705. return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  59706. }
  59707. $result = array();
  59708. $length = mb_strlen($string, $encoding);
  59709. for ($i = 0; $i < $length; $i += $split_length) {
  59710. $result[] = mb_substr($string, $i, $split_length, $encoding);
  59711. }
  59712. return $result;
  59713. }
  59714. public static function mb_strtolower($s, $encoding = null)
  59715. {
  59716. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  59717. }
  59718. public static function mb_strtoupper($s, $encoding = null)
  59719. {
  59720. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  59721. }
  59722. public static function mb_substitute_character($c = null)
  59723. {
  59724. if (0 === strcasecmp($c, 'none')) {
  59725. return true;
  59726. }
  59727. return null !== $c ? false : 'none';
  59728. }
  59729. public static function mb_substr($s, $start, $length = null, $encoding = null)
  59730. {
  59731. $encoding = self::getEncoding($encoding);
  59732. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59733. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  59734. }
  59735. if ($start < 0) {
  59736. $start = iconv_strlen($s, $encoding) + $start;
  59737. if ($start < 0) {
  59738. $start = 0;
  59739. }
  59740. }
  59741. if (null === $length) {
  59742. $length = 2147483647;
  59743. } elseif ($length < 0) {
  59744. $length = iconv_strlen($s, $encoding) + $length - $start;
  59745. if ($length < 0) {
  59746. return '';
  59747. }
  59748. }
  59749. return (string) iconv_substr($s, $start, $length, $encoding);
  59750. }
  59751. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  59752. {
  59753. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59754. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59755. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  59756. }
  59757. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  59758. {
  59759. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  59760. return self::getSubpart($pos, $part, $haystack, $encoding);
  59761. }
  59762. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  59763. {
  59764. $encoding = self::getEncoding($encoding);
  59765. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59766. $pos = strrpos($haystack, $needle);
  59767. } else {
  59768. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59769. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59770. }
  59771. return self::getSubpart($pos, $part, $haystack, $encoding);
  59772. }
  59773. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  59774. {
  59775. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59776. $pos = self::mb_strripos($haystack, $needle, $encoding);
  59777. return self::getSubpart($pos, $part, $haystack, $encoding);
  59778. }
  59779. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  59780. {
  59781. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59782. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59783. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  59784. }
  59785. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  59786. {
  59787. $pos = strpos($haystack, $needle);
  59788. if (false === $pos) {
  59789. return false;
  59790. }
  59791. if ($part) {
  59792. return substr($haystack, 0, $pos);
  59793. }
  59794. return substr($haystack, $pos);
  59795. }
  59796. public static function mb_get_info($type = 'all')
  59797. {
  59798. $info = array(
  59799. 'internal_encoding' => self::$internalEncoding,
  59800. 'http_output' => 'pass',
  59801. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  59802. 'func_overload' => 0,
  59803. 'func_overload_list' => 'no overload',
  59804. 'mail_charset' => 'UTF-8',
  59805. 'mail_header_encoding' => 'BASE64',
  59806. 'mail_body_encoding' => 'BASE64',
  59807. 'illegal_chars' => 0,
  59808. 'encoding_translation' => 'Off',
  59809. 'language' => self::$language,
  59810. 'detect_order' => self::$encodingList,
  59811. 'substitute_character' => 'none',
  59812. 'strict_detection' => 'Off',
  59813. );
  59814. if ('all' === $type) {
  59815. return $info;
  59816. }
  59817. if (isset($info[$type])) {
  59818. return $info[$type];
  59819. }
  59820. return false;
  59821. }
  59822. public static function mb_http_input($type = '')
  59823. {
  59824. return false;
  59825. }
  59826. public static function mb_http_output($encoding = null)
  59827. {
  59828. return null !== $encoding ? 'pass' === $encoding : 'pass';
  59829. }
  59830. public static function mb_strwidth($s, $encoding = null)
  59831. {
  59832. $encoding = self::getEncoding($encoding);
  59833. if ('UTF-8' !== $encoding) {
  59834. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59835. }
  59836. $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);
  59837. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  59838. }
  59839. public static function mb_substr_count($haystack, $needle, $encoding = null)
  59840. {
  59841. return substr_count($haystack, $needle);
  59842. }
  59843. public static function mb_output_handler($contents, $status)
  59844. {
  59845. return $contents;
  59846. }
  59847. public static function mb_chr($code, $encoding = null)
  59848. {
  59849. if (0x80 > $code %= 0x200000) {
  59850. $s = \chr($code);
  59851. } elseif (0x800 > $code) {
  59852. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  59853. } elseif (0x10000 > $code) {
  59854. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59855. } else {
  59856. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59857. }
  59858. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59859. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  59860. }
  59861. return $s;
  59862. }
  59863. public static function mb_ord($s, $encoding = null)
  59864. {
  59865. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59866. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  59867. }
  59868. if (1 === \strlen($s)) {
  59869. return \ord($s);
  59870. }
  59871. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  59872. if (0xF0 <= $code) {
  59873. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  59874. }
  59875. if (0xE0 <= $code) {
  59876. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  59877. }
  59878. if (0xC0 <= $code) {
  59879. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  59880. }
  59881. return $code;
  59882. }
  59883. private static function getSubpart($pos, $part, $haystack, $encoding)
  59884. {
  59885. if (false === $pos) {
  59886. return false;
  59887. }
  59888. if ($part) {
  59889. return self::mb_substr($haystack, 0, $pos, $encoding);
  59890. }
  59891. return self::mb_substr($haystack, $pos, null, $encoding);
  59892. }
  59893. private static function html_encoding_callback(array $m)
  59894. {
  59895. $i = 1;
  59896. $entities = '';
  59897. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  59898. while (isset($m[$i])) {
  59899. if (0x80 > $m[$i]) {
  59900. $entities .= \chr($m[$i++]);
  59901. continue;
  59902. }
  59903. if (0xF0 <= $m[$i]) {
  59904. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59905. } elseif (0xE0 <= $m[$i]) {
  59906. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59907. } else {
  59908. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  59909. }
  59910. $entities .= '&#'.$c.';';
  59911. }
  59912. return $entities;
  59913. }
  59914. private static function title_case(array $s)
  59915. {
  59916. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  59917. }
  59918. private static function getData($file)
  59919. {
  59920. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  59921. return require $file;
  59922. }
  59923. return false;
  59924. }
  59925. private static function getEncoding($encoding)
  59926. {
  59927. if (null === $encoding) {
  59928. return self::$internalEncoding;
  59929. }
  59930. if ('UTF-8' === $encoding) {
  59931. return 'UTF-8';
  59932. }
  59933. $encoding = strtoupper($encoding);
  59934. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  59935. return 'CP850';
  59936. }
  59937. if ('UTF8' === $encoding) {
  59938. return 'UTF-8';
  59939. }
  59940. return $encoding;
  59941. }
  59942. }
  59943. <?php
  59944. use Symfony\Polyfill\Mbstring as p;
  59945. if (!function_exists('mb_convert_variables')) {
  59946. function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
  59947. {
  59948. $vars = [&$var, ...$vars];
  59949. $ok = true;
  59950. array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
  59951. if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
  59952. $ok = false;
  59953. }
  59954. });
  59955. return $ok ? $from_encoding : false;
  59956. }
  59957. }
  59958. <?php
  59959. return array (
  59960. 'A' => 'a',
  59961. 'B' => 'b',
  59962. 'C' => 'c',
  59963. 'D' => 'd',
  59964. 'E' => 'e',
  59965. 'F' => 'f',
  59966. 'G' => 'g',
  59967. 'H' => 'h',
  59968. 'I' => 'i',
  59969. 'J' => 'j',
  59970. 'K' => 'k',
  59971. 'L' => 'l',
  59972. 'M' => 'm',
  59973. 'N' => 'n',
  59974. 'O' => 'o',
  59975. 'P' => 'p',
  59976. 'Q' => 'q',
  59977. 'R' => 'r',
  59978. 'S' => 's',
  59979. 'T' => 't',
  59980. 'U' => 'u',
  59981. 'V' => 'v',
  59982. 'W' => 'w',
  59983. 'X' => 'x',
  59984. 'Y' => 'y',
  59985. 'Z' => 'z',
  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. 'Ä°' => 'i',
  60041. 'IJ' => 'ij',
  60042. 'Ĵ' => 'ĵ',
  60043. 'Ķ' => 'ķ',
  60044. 'Ĺ' => 'ĺ',
  60045. 'Ļ' => 'ļ',
  60046. 'Ľ' => 'ľ',
  60047. 'Ä¿' => 'Å€',
  60048. '�' => 'ł',
  60049. 'Ń' => 'ń',
  60050. 'Ņ' => 'ņ',
  60051. 'Ň' => 'ň',
  60052. 'ÅŠ' => 'Å‹',
  60053. 'Ō' => '�',
  60054. 'Ŏ' => '�',
  60055. '�' => 'ő',
  60056. 'Å’' => 'Å“',
  60057. 'Å”' => 'Å•',
  60058. 'Å–' => 'Å—',
  60059. 'Ř' => 'ř',
  60060. 'Åš' => 'Å›',
  60061. 'Ŝ' => '�',
  60062. 'Åž' => 'ÅŸ',
  60063. 'Å ' => 'Å¡',
  60064. 'Å¢' => 'Å£',
  60065. 'Ť' => 'ť',
  60066. 'Ŧ' => 'ŧ',
  60067. 'Ũ' => 'ũ',
  60068. 'Ū' => 'ū',
  60069. 'Ŭ' => 'ŭ',
  60070. 'Ů' => 'ů',
  60071. 'Ű' => 'ű',
  60072. 'Ų' => 'ų',
  60073. 'Ŵ' => 'ŵ',
  60074. 'Ŷ' => 'ŷ',
  60075. 'Ÿ' => 'ÿ',
  60076. 'Ź' => 'ź',
  60077. 'Ż' => 'ż',
  60078. 'Ž' => 'ž',
  60079. '�' => 'ɓ',
  60080. 'Ƃ' => 'ƃ',
  60081. 'Æ„' => 'Æ…',
  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. 'DŽ' => 'dž',
  60116. 'Dž' => 'dž',
  60117. 'LJ' => 'lj',
  60118. 'Lj' => 'lj',
  60119. 'NJ' => 'nj',
  60120. 'Nj' => 'nj',
  60121. '�' => 'ǎ',
  60122. '�' => '�',
  60123. 'Ç‘' => 'Ç’',
  60124. 'Ç“' => 'Ç”',
  60125. 'Ç•' => 'Ç–',
  60126. 'Ǘ' => 'ǘ',
  60127. 'Ç™' => 'Çš',
  60128. 'Ǜ' => 'ǜ',
  60129. 'Çž' => 'ÇŸ',
  60130. 'Ç ' => 'Ç¡',
  60131. 'Ç¢' => 'Ç£',
  60132. 'Ǥ' => 'ǥ',
  60133. 'Ǧ' => 'ǧ',
  60134. 'Ǩ' => 'ǩ',
  60135. 'Ǫ' => 'ǫ',
  60136. 'Ǭ' => 'ǭ',
  60137. 'Ǯ' => 'ǯ',
  60138. 'DZ' => 'dz',
  60139. 'Dz' => 'dz',
  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. 'Ὗ' => 'ὗ',
  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. 'K' => 'k',
  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. '�' => '�',
  61045. '�' => '�',
  61046. '�' => '�',
  61047. '�' => '�',
  61048. '�' => '�',
  61049. '�' => '�',
  61050. '�' => '�',
  61051. '�' => '�',
  61052. '�' => '�',
  61053. '�' => '�',
  61054. '�' => '�',
  61055. '�' => '�',
  61056. '�' => '�',
  61057. '�' => '�',
  61058. '�' => '�',
  61059. '�' => '�',
  61060. '�' => 'ᵹ',
  61061. '�' => '�',
  61062. 'Ꞁ' => '�',
  61063. 'Ꞃ' => 'ꞃ',
  61064. 'êž„' => 'êž…',
  61065. 'Ꞇ' => 'ꞇ',
  61066. 'Ꞌ' => 'ꞌ',
  61067. '�' => 'ɥ',
  61068. '�' => 'ꞑ',
  61069. 'êž’' => 'êž“',
  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. 'A' => '�',
  61103. 'B' => 'b',
  61104. 'C' => 'c',
  61105. 'D' => 'd',
  61106. 'ï¼¥' => 'ï½…',
  61107. 'F' => 'f',
  61108. 'G' => 'g',
  61109. 'H' => 'h',
  61110. 'I' => 'i',
  61111. 'J' => 'j',
  61112. 'K' => 'k',
  61113. 'L' => 'l',
  61114. 'M' => '�',
  61115. 'N' => 'n',
  61116. 'O' => '�',
  61117. 'P' => '�',
  61118. 'Q' => 'q',
  61119. 'ï¼²' => 'ï½’',
  61120. 'S' => 's',
  61121. 'ï¼´' => 'ï½”',
  61122. 'U' => 'u',
  61123. 'V' => 'v',
  61124. 'ï¼·' => 'ï½—',
  61125. 'X' => 'x',
  61126. 'ï¼¹' => 'ï½™',
  61127. 'Z' => 'z',
  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. '𖹉' => '𖹩',
  61297. '𖹊' => '𖹪',
  61298. '𖹋' => '𖹫',
  61299. '𖹌' => '𖹬',
  61300. '�' => '𖹭',
  61301. '𖹎' => '𖹮',
  61302. '�' => '𖹯',
  61303. '�' => '𖹰',
  61304. '𖹑' => '𖹱',
  61305. 'ð–¹’' => 'ð–¹²',
  61306. '𖹓' => '𖹳',
  61307. 'ð–¹”' => 'ð–¹´',
  61308. '𖹕' => '𖹵',
  61309. '𖹖' => '𖹶',
  61310. 'ð–¹—' => 'ð–¹·',
  61311. '𖹘' => '𖹸',
  61312. 'ð–¹™' => 'ð–¹¹',
  61313. '𖹚' => '𖹺',
  61314. 'ð–¹›' => 'ð–¹»',
  61315. '𖹜' => '𖹼',
  61316. '�' => '𖹽',
  61317. '𖹞' => '𖹾',
  61318. '𖹟' => '𖹿',
  61319. '𞤀' => '𞤢',
  61320. '�' => '𞤣',
  61321. '𞤂' => '𞤤',
  61322. '𞤃' => '𞤥',
  61323. '𞤄' => '𞤦',
  61324. '𞤅' => '𞤧',
  61325. '𞤆' => '𞤨',
  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. <?php
  61355. 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';
  61356. <?php
  61357. return array (
  61358. 'a' => 'A',
  61359. 'b' => 'B',
  61360. 'c' => 'C',
  61361. 'd' => 'D',
  61362. 'e' => 'E',
  61363. 'f' => 'F',
  61364. 'g' => 'G',
  61365. 'h' => 'H',
  61366. 'i' => 'I',
  61367. 'j' => 'J',
  61368. 'k' => 'K',
  61369. 'l' => 'L',
  61370. 'm' => 'M',
  61371. 'n' => 'N',
  61372. 'o' => 'O',
  61373. 'p' => 'P',
  61374. 'q' => 'Q',
  61375. 'r' => 'R',
  61376. 's' => 'S',
  61377. 't' => 'T',
  61378. 'u' => 'U',
  61379. 'v' => 'V',
  61380. 'w' => 'W',
  61381. 'x' => 'X',
  61382. 'y' => 'Y',
  61383. 'z' => 'Z',
  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. 'ĉ' => 'Ĉ',
  61421. 'Ä‹' => 'ÄŠ',
  61422. '�' => 'Č',
  61423. '�' => 'Ď',
  61424. 'đ' => '�',
  61425. 'Ä“' => 'Ä’',
  61426. 'Ä•' => 'Ä”',
  61427. 'Ä—' => 'Ä–',
  61428. 'ę' => 'Ę',
  61429. 'Ä›' => 'Äš',
  61430. '�' => 'Ĝ',
  61431. 'ÄŸ' => 'Äž',
  61432. 'Ä¡' => 'Ä ',
  61433. 'Ä£' => 'Ä¢',
  61434. 'ĥ' => 'Ĥ',
  61435. 'ħ' => 'Ħ',
  61436. 'ĩ' => 'Ĩ',
  61437. 'ī' => 'Ī',
  61438. 'ĭ' => 'Ĭ',
  61439. 'į' => 'Į',
  61440. 'ı' => 'I',
  61441. 'ij' => 'IJ',
  61442. 'ĵ' => 'Ĵ',
  61443. 'ķ' => 'Ķ',
  61444. 'ĺ' => 'Ĺ',
  61445. 'ļ' => 'Ļ',
  61446. 'ľ' => 'Ľ',
  61447. 'Å€' => 'Ä¿',
  61448. 'ł' => '�',
  61449. 'ń' => 'Ń',
  61450. 'ņ' => 'Ņ',
  61451. 'ň' => 'Ň',
  61452. 'Å‹' => 'ÅŠ',
  61453. '�' => 'Ō',
  61454. '�' => 'Ŏ',
  61455. 'ő' => '�',
  61456. 'Å“' => 'Å’',
  61457. 'Å•' => 'Å”',
  61458. 'Å—' => 'Å–',
  61459. 'ř' => 'Ř',
  61460. 'Å›' => 'Åš',
  61461. '�' => 'Ŝ',
  61462. 'ÅŸ' => 'Åž',
  61463. 'Å¡' => 'Å ',
  61464. 'Å£' => 'Å¢',
  61465. 'ť' => 'Ť',
  61466. 'ŧ' => 'Ŧ',
  61467. 'ũ' => 'Ũ',
  61468. 'ū' => 'Ū',
  61469. 'ŭ' => 'Ŭ',
  61470. 'ů' => 'Ů',
  61471. 'ű' => 'Ű',
  61472. 'ų' => 'Ų',
  61473. 'ŵ' => 'Ŵ',
  61474. 'ŷ' => 'Ŷ',
  61475. 'ź' => 'Ź',
  61476. 'ż' => 'Ż',
  61477. 'ž' => 'Ž',
  61478. 'Å¿' => 'S',
  61479. 'ƀ' => 'Ƀ',
  61480. 'ƃ' => 'Ƃ',
  61481. 'Æ…' => 'Æ„',
  61482. 'ƈ' => 'Ƈ',
  61483. 'ƌ' => 'Ƌ',
  61484. 'Æ’' => 'Æ‘',
  61485. 'ƕ' => 'Ƕ',
  61486. 'ƙ' => 'Ƙ',
  61487. 'ƚ' => 'Ƚ',
  61488. 'Æž' => 'È ',
  61489. 'Æ¡' => 'Æ ',
  61490. 'Æ£' => 'Æ¢',
  61491. 'ƥ' => 'Ƥ',
  61492. 'ƨ' => 'Ƨ',
  61493. 'ƭ' => 'Ƭ',
  61494. 'ư' => 'Ư',
  61495. 'ƴ' => 'Ƴ',
  61496. 'ƶ' => 'Ƶ',
  61497. 'ƹ' => 'Ƹ',
  61498. 'ƽ' => 'Ƽ',
  61499. 'Æ¿' => 'Ç·',
  61500. 'Ç…' => 'Ç„',
  61501. 'dž' => 'DŽ',
  61502. 'Lj' => 'LJ',
  61503. 'lj' => 'LJ',
  61504. 'Ç‹' => 'ÇŠ',
  61505. 'nj' => 'NJ',
  61506. 'ǎ' => '�',
  61507. '�' => '�',
  61508. 'Ç’' => 'Ç‘',
  61509. 'Ç”' => 'Ç“',
  61510. 'Ç–' => 'Ç•',
  61511. 'ǘ' => 'Ǘ',
  61512. 'Çš' => 'Ç™',
  61513. 'ǜ' => 'Ǜ',
  61514. '�' => 'Ǝ',
  61515. 'ÇŸ' => 'Çž',
  61516. 'Ç¡' => 'Ç ',
  61517. 'Ç£' => 'Ç¢',
  61518. 'ǥ' => 'Ǥ',
  61519. 'ǧ' => 'Ǧ',
  61520. 'ǩ' => 'Ǩ',
  61521. 'ǫ' => 'Ǫ',
  61522. 'ǭ' => 'Ǭ',
  61523. 'ǯ' => 'Ǯ',
  61524. 'Dz' => 'DZ',
  61525. 'dz' => 'DZ',
  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. 'ꮆ' => 'Ꮆ',
  62460. 'ꮇ' => 'Ꮇ',
  62461. 'ꮈ' => 'Ꮈ',
  62462. 'ꮉ' => 'Ꮉ',
  62463. 'ꮊ' => 'Ꮊ',
  62464. 'ꮋ' => 'Ꮋ',
  62465. 'ꮌ' => 'Ꮌ',
  62466. '�' => 'Ꮍ',
  62467. 'ꮎ' => 'Ꮎ',
  62468. '�' => 'Ꮏ',
  62469. '�' => '�',
  62470. 'ꮑ' => '�',
  62471. 'ꮒ' => '�',
  62472. 'ꮓ' => '�',
  62473. 'ꮔ' => '�',
  62474. 'ꮕ' => '�',
  62475. 'ꮖ' => '�',
  62476. 'ꮗ' => '�',
  62477. 'ꮘ' => '�',
  62478. 'ꮙ' => '�',
  62479. 'ꮚ' => '�',
  62480. 'ꮛ' => '�',
  62481. 'ꮜ' => '�',
  62482. '�' => '�',
  62483. 'ꮞ' => '�',
  62484. 'ꮟ' => '�',
  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. '�' => 'A',
  62518. 'b' => 'B',
  62519. 'c' => 'C',
  62520. 'd' => 'D',
  62521. 'ï½…' => 'ï¼¥',
  62522. 'f' => 'F',
  62523. 'g' => 'G',
  62524. 'h' => 'H',
  62525. 'i' => 'I',
  62526. 'j' => 'J',
  62527. 'k' => 'K',
  62528. 'l' => 'L',
  62529. '�' => 'M',
  62530. 'n' => 'N',
  62531. '�' => 'O',
  62532. '�' => 'P',
  62533. 'q' => 'Q',
  62534. 'ï½’' => 'ï¼²',
  62535. 's' => 'S',
  62536. 'ï½”' => 'ï¼´',
  62537. 'u' => 'U',
  62538. 'v' => 'V',
  62539. 'ï½—' => 'ï¼·',
  62540. 'x' => 'X',
  62541. 'ï½™' => 'ï¼¹',
  62542. 'z' => 'Z',
  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. '𖹩' => '𖹉',
  62712. '𖹪' => '𖹊',
  62713. '𖹫' => '𖹋',
  62714. '𖹬' => '𖹌',
  62715. '𖹭' => '�',
  62716. '𖹮' => '𖹎',
  62717. '𖹯' => '�',
  62718. '𖹰' => '�',
  62719. '𖹱' => '𖹑',
  62720. 'ð–¹²' => 'ð–¹’',
  62721. '𖹳' => '𖹓',
  62722. 'ð–¹´' => 'ð–¹”',
  62723. '𖹵' => '𖹕',
  62724. '𖹶' => '𖹖',
  62725. 'ð–¹·' => 'ð–¹—',
  62726. '𖹸' => '𖹘',
  62727. 'ð–¹¹' => 'ð–¹™',
  62728. '𖹺' => '𖹚',
  62729. 'ð–¹»' => 'ð–¹›',
  62730. '𖹼' => '𖹜',
  62731. '𖹽' => '�',
  62732. '𖹾' => '𖹞',
  62733. '𖹿' => '𖹟',
  62734. '𞤢' => '𞤀',
  62735. '𞤣' => '�',
  62736. '𞤤' => '𞤂',
  62737. '𞤥' => '𞤃',
  62738. '𞤦' => '𞤄',
  62739. '𞤧' => '𞤅',
  62740. '𞤨' => '𞤆',
  62741. '𞤩' => '𞤇',
  62742. '𞤪' => '𞤈',
  62743. '𞤫' => '𞤉',
  62744. '𞤬' => '𞤊',
  62745. '𞤭' => '𞤋',
  62746. '𞤮' => '𞤌',
  62747. '𞤯' => '�',
  62748. '𞤰' => '𞤎',
  62749. '𞤱' => '�',
  62750. '𞤲' => '�',
  62751. '𞤳' => '𞤑',
  62752. '𞤴' => '𞤒',
  62753. '𞤵' => '𞤓',
  62754. '𞤶' => '𞤔',
  62755. '𞤷' => '𞤕',
  62756. '𞤸' => '𞤖',
  62757. '𞤹' => '𞤗',
  62758. '𞤺' => '𞤘',
  62759. '𞤻' => '𞤙',
  62760. '𞤼' => '𞤚',
  62761. '𞤽' => '𞤛',
  62762. '𞤾' => '𞤜',
  62763. '𞤿' => '�',
  62764. '𞥀' => '𞤞',
  62765. '�' => '𞤟',
  62766. '𞥂' => '𞤠',
  62767. '𞥃' => '𞤡',
  62768. );
  62769. <?php
  62770. use Symfony\Polyfill\Mbstring as p;
  62771. if (!function_exists('mb_convert_encoding')) {
  62772. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  62773. }
  62774. if (!function_exists('mb_decode_mimeheader')) {
  62775. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  62776. }
  62777. if (!function_exists('mb_encode_mimeheader')) {
  62778. 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); }
  62779. }
  62780. if (!function_exists('mb_decode_numericentity')) {
  62781. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  62782. }
  62783. if (!function_exists('mb_encode_numericentity')) {
  62784. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  62785. }
  62786. if (!function_exists('mb_convert_case')) {
  62787. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  62788. }
  62789. if (!function_exists('mb_internal_encoding')) {
  62790. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  62791. }
  62792. if (!function_exists('mb_language')) {
  62793. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  62794. }
  62795. if (!function_exists('mb_list_encodings')) {
  62796. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  62797. }
  62798. if (!function_exists('mb_encoding_aliases')) {
  62799. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  62800. }
  62801. if (!function_exists('mb_check_encoding')) {
  62802. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  62803. }
  62804. if (!function_exists('mb_detect_encoding')) {
  62805. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  62806. }
  62807. if (!function_exists('mb_detect_order')) {
  62808. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  62809. }
  62810. if (!function_exists('mb_parse_str')) {
  62811. function mb_parse_str($string, &$result = array()) { parse_str($string, $result); }
  62812. }
  62813. if (!function_exists('mb_strlen')) {
  62814. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  62815. }
  62816. if (!function_exists('mb_strpos')) {
  62817. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  62818. }
  62819. if (!function_exists('mb_strtolower')) {
  62820. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  62821. }
  62822. if (!function_exists('mb_strtoupper')) {
  62823. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  62824. }
  62825. if (!function_exists('mb_substitute_character')) {
  62826. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  62827. }
  62828. if (!function_exists('mb_substr')) {
  62829. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  62830. }
  62831. if (!function_exists('mb_stripos')) {
  62832. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  62833. }
  62834. if (!function_exists('mb_stristr')) {
  62835. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  62836. }
  62837. if (!function_exists('mb_strrchr')) {
  62838. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  62839. }
  62840. if (!function_exists('mb_strrichr')) {
  62841. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  62842. }
  62843. if (!function_exists('mb_strripos')) {
  62844. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  62845. }
  62846. if (!function_exists('mb_strrpos')) {
  62847. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  62848. }
  62849. if (!function_exists('mb_strstr')) {
  62850. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  62851. }
  62852. if (!function_exists('mb_get_info')) {
  62853. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  62854. }
  62855. if (!function_exists('mb_http_output')) {
  62856. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  62857. }
  62858. if (!function_exists('mb_strwidth')) {
  62859. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  62860. }
  62861. if (!function_exists('mb_substr_count')) {
  62862. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  62863. }
  62864. if (!function_exists('mb_output_handler')) {
  62865. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  62866. }
  62867. if (!function_exists('mb_http_input')) {
  62868. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  62869. }
  62870. if (PHP_VERSION_ID >= 80000) {
  62871. require_once __DIR__.'/Resources/mb_convert_variables.php8';
  62872. } elseif (!function_exists('mb_convert_variables')) {
  62873. 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); }
  62874. }
  62875. if (!function_exists('mb_ord')) {
  62876. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  62877. }
  62878. if (!function_exists('mb_chr')) {
  62879. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  62880. }
  62881. if (!function_exists('mb_scrub')) {
  62882. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  62883. }
  62884. if (!function_exists('mb_str_split')) {
  62885. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  62886. }
  62887. if (extension_loaded('mbstring')) {
  62888. return;
  62889. }
  62890. if (!defined('MB_CASE_UPPER')) {
  62891. define('MB_CASE_UPPER', 0);
  62892. }
  62893. if (!defined('MB_CASE_LOWER')) {
  62894. define('MB_CASE_LOWER', 1);
  62895. }
  62896. if (!defined('MB_CASE_TITLE')) {
  62897. define('MB_CASE_TITLE', 2);
  62898. }
  62899. <?php
  62900. namespace Symfony\Component\Process\Exception;
  62901. interface ExceptionInterface
  62902. {
  62903. }
  62904. <?php
  62905. namespace Symfony\Component\Process\Exception;
  62906. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  62907. {
  62908. }
  62909. <?php
  62910. namespace Symfony\Component\Process\Exception;
  62911. class LogicException extends \LogicException implements ExceptionInterface
  62912. {
  62913. }
  62914. <?php
  62915. namespace Symfony\Component\Process\Exception;
  62916. use Symfony\Component\Process\Process;
  62917. class ProcessFailedException extends RuntimeException
  62918. {
  62919. private $process;
  62920. public function __construct(Process $process)
  62921. {
  62922. if ($process->isSuccessful()) {
  62923. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  62924. }
  62925. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  62926. $process->getCommandLine(),
  62927. $process->getExitCode(),
  62928. $process->getExitCodeText(),
  62929. $process->getWorkingDirectory()
  62930. );
  62931. if (!$process->isOutputDisabled()) {
  62932. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  62933. $process->getOutput(),
  62934. $process->getErrorOutput()
  62935. );
  62936. }
  62937. parent::__construct($error);
  62938. $this->process = $process;
  62939. }
  62940. public function getProcess()
  62941. {
  62942. return $this->process;
  62943. }
  62944. }
  62945. <?php
  62946. namespace Symfony\Component\Process\Exception;
  62947. use Symfony\Component\Process\Process;
  62948. class ProcessTimedOutException extends RuntimeException
  62949. {
  62950. const TYPE_GENERAL = 1;
  62951. const TYPE_IDLE = 2;
  62952. private $process;
  62953. private $timeoutType;
  62954. public function __construct(Process $process, $timeoutType)
  62955. {
  62956. $this->process = $process;
  62957. $this->timeoutType = $timeoutType;
  62958. parent::__construct(sprintf(
  62959. 'The process "%s" exceeded the timeout of %s seconds.',
  62960. $process->getCommandLine(),
  62961. $this->getExceededTimeout()
  62962. ));
  62963. }
  62964. public function getProcess()
  62965. {
  62966. return $this->process;
  62967. }
  62968. public function isGeneralTimeout()
  62969. {
  62970. return self::TYPE_GENERAL === $this->timeoutType;
  62971. }
  62972. public function isIdleTimeout()
  62973. {
  62974. return self::TYPE_IDLE === $this->timeoutType;
  62975. }
  62976. public function getExceededTimeout()
  62977. {
  62978. switch ($this->timeoutType) {
  62979. case self::TYPE_GENERAL:
  62980. return $this->process->getTimeout();
  62981. case self::TYPE_IDLE:
  62982. return $this->process->getIdleTimeout();
  62983. default:
  62984. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  62985. }
  62986. }
  62987. }
  62988. <?php
  62989. namespace Symfony\Component\Process\Exception;
  62990. class RuntimeException extends \RuntimeException implements ExceptionInterface
  62991. {
  62992. }
  62993. <?php
  62994. namespace Symfony\Component\Process;
  62995. class ExecutableFinder
  62996. {
  62997. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  62998. public function setSuffixes(array $suffixes)
  62999. {
  63000. $this->suffixes = $suffixes;
  63001. }
  63002. public function addSuffix($suffix)
  63003. {
  63004. $this->suffixes[] = $suffix;
  63005. }
  63006. public function find($name, $default = null, array $extraDirs = array())
  63007. {
  63008. if (ini_get('open_basedir')) {
  63009. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  63010. $dirs = array();
  63011. foreach ($searchPath as $path) {
  63012. if (@is_dir($path)) {
  63013. $dirs[] = $path;
  63014. } else {
  63015. if (basename($path) == $name && @is_executable($path)) {
  63016. return $path;
  63017. }
  63018. }
  63019. }
  63020. } else {
  63021. $dirs = array_merge(
  63022. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  63023. $extraDirs
  63024. );
  63025. }
  63026. $suffixes = array('');
  63027. if ('\\' === \DIRECTORY_SEPARATOR) {
  63028. $pathExt = getenv('PATHEXT');
  63029. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  63030. }
  63031. foreach ($suffixes as $suffix) {
  63032. foreach ($dirs as $dir) {
  63033. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  63034. return $file;
  63035. }
  63036. }
  63037. }
  63038. return $default;
  63039. }
  63040. }
  63041. Copyright (c) 2004-2018 Fabien Potencier
  63042. Permission is hereby granted, free of charge, to any person obtaining a copy
  63043. of this software and associated documentation files (the "Software"), to deal
  63044. in the Software without restriction, including without limitation the rights
  63045. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63046. copies of the Software, and to permit persons to whom the Software is furnished
  63047. to do so, subject to the following conditions:
  63048. The above copyright notice and this permission notice shall be included in all
  63049. copies or substantial portions of the Software.
  63050. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63051. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63052. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63053. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63054. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63055. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63056. THE SOFTWARE.
  63057. <?php
  63058. namespace Symfony\Component\Process;
  63059. class PhpExecutableFinder
  63060. {
  63061. private $executableFinder;
  63062. public function __construct()
  63063. {
  63064. $this->executableFinder = new ExecutableFinder();
  63065. }
  63066. public function find($includeArgs = true)
  63067. {
  63068. $args = $this->findArguments();
  63069. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  63070. if (\defined('HHVM_VERSION')) {
  63071. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  63072. }
  63073. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  63074. return PHP_BINARY.$args;
  63075. }
  63076. if ($php = getenv('PHP_PATH')) {
  63077. if (!@is_executable($php)) {
  63078. return false;
  63079. }
  63080. return $php;
  63081. }
  63082. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  63083. if (@is_executable($php)) {
  63084. return $php;
  63085. }
  63086. }
  63087. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  63088. return $php;
  63089. }
  63090. $dirs = array(PHP_BINDIR);
  63091. if ('\\' === \DIRECTORY_SEPARATOR) {
  63092. $dirs[] = 'C:\xampp\php\\';
  63093. }
  63094. return $this->executableFinder->find('php', false, $dirs);
  63095. }
  63096. public function findArguments()
  63097. {
  63098. $arguments = array();
  63099. if (\defined('HHVM_VERSION')) {
  63100. $arguments[] = '--php';
  63101. } elseif ('phpdbg' === \PHP_SAPI) {
  63102. $arguments[] = '-qrr';
  63103. }
  63104. return $arguments;
  63105. }
  63106. }
  63107. <?php
  63108. namespace Symfony\Component\Process;
  63109. use Symfony\Component\Process\Exception\RuntimeException;
  63110. class PhpProcess extends Process
  63111. {
  63112. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  63113. {
  63114. $executableFinder = new PhpExecutableFinder();
  63115. if (false === $php = $executableFinder->find()) {
  63116. $php = null;
  63117. }
  63118. if ('phpdbg' === \PHP_SAPI) {
  63119. $file = tempnam(sys_get_temp_dir(), 'dbg');
  63120. file_put_contents($file, $script);
  63121. register_shutdown_function('unlink', $file);
  63122. $php .= ' '.ProcessUtils::escapeArgument($file);
  63123. $script = null;
  63124. }
  63125. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  63126. $php = 'exec '.$php;
  63127. }
  63128. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  63129. }
  63130. public function setPhpBinary($php)
  63131. {
  63132. $this->setCommandLine($php);
  63133. }
  63134. public function start($callback = null)
  63135. {
  63136. if (null === $this->getCommandLine()) {
  63137. throw new RuntimeException('Unable to find the PHP executable.');
  63138. }
  63139. parent::start($callback);
  63140. }
  63141. }
  63142. <?php
  63143. namespace Symfony\Component\Process\Pipes;
  63144. abstract class AbstractPipes implements PipesInterface
  63145. {
  63146. public $pipes = array();
  63147. private $inputBuffer = '';
  63148. private $input;
  63149. private $blocked = true;
  63150. private $lastError;
  63151. public function __construct($input)
  63152. {
  63153. if (\is_resource($input)) {
  63154. $this->input = $input;
  63155. } elseif (\is_string($input)) {
  63156. $this->inputBuffer = $input;
  63157. } else {
  63158. $this->inputBuffer = (string) $input;
  63159. }
  63160. }
  63161. public function close()
  63162. {
  63163. foreach ($this->pipes as $pipe) {
  63164. fclose($pipe);
  63165. }
  63166. $this->pipes = array();
  63167. }
  63168. protected function hasSystemCallBeenInterrupted()
  63169. {
  63170. $lastError = $this->lastError;
  63171. $this->lastError = null;
  63172. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  63173. }
  63174. protected function unblock()
  63175. {
  63176. if (!$this->blocked) {
  63177. return;
  63178. }
  63179. foreach ($this->pipes as $pipe) {
  63180. stream_set_blocking($pipe, 0);
  63181. }
  63182. if (null !== $this->input) {
  63183. stream_set_blocking($this->input, 0);
  63184. }
  63185. $this->blocked = false;
  63186. }
  63187. protected function write()
  63188. {
  63189. if (!isset($this->pipes[0])) {
  63190. return;
  63191. }
  63192. $input = $this->input;
  63193. $r = $e = array();
  63194. $w = array($this->pipes[0]);
  63195. if (false === @stream_select($r, $w, $e, 0, 0)) {
  63196. return;
  63197. }
  63198. foreach ($w as $stdin) {
  63199. if (isset($this->inputBuffer[0])) {
  63200. $written = fwrite($stdin, $this->inputBuffer);
  63201. $this->inputBuffer = substr($this->inputBuffer, $written);
  63202. if (isset($this->inputBuffer[0])) {
  63203. return array($this->pipes[0]);
  63204. }
  63205. }
  63206. if ($input) {
  63207. for (;;) {
  63208. $data = fread($input, self::CHUNK_SIZE);
  63209. if (!isset($data[0])) {
  63210. break;
  63211. }
  63212. $written = fwrite($stdin, $data);
  63213. $data = substr($data, $written);
  63214. if (isset($data[0])) {
  63215. $this->inputBuffer = $data;
  63216. return array($this->pipes[0]);
  63217. }
  63218. }
  63219. if (feof($input)) {
  63220. $this->input = null;
  63221. }
  63222. }
  63223. }
  63224. if (null === $this->input && !isset($this->inputBuffer[0])) {
  63225. fclose($this->pipes[0]);
  63226. unset($this->pipes[0]);
  63227. } elseif (!$w) {
  63228. return array($this->pipes[0]);
  63229. }
  63230. }
  63231. public function handleError($type, $msg)
  63232. {
  63233. $this->lastError = $msg;
  63234. }
  63235. }
  63236. <?php
  63237. namespace Symfony\Component\Process\Pipes;
  63238. interface PipesInterface
  63239. {
  63240. const CHUNK_SIZE = 16384;
  63241. public function getDescriptors();
  63242. public function getFiles();
  63243. public function readAndWrite($blocking, $close = false);
  63244. public function areOpen();
  63245. public function close();
  63246. }
  63247. <?php
  63248. namespace Symfony\Component\Process\Pipes;
  63249. use Symfony\Component\Process\Process;
  63250. class UnixPipes extends AbstractPipes
  63251. {
  63252. private $ttyMode;
  63253. private $ptyMode;
  63254. private $disableOutput;
  63255. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  63256. {
  63257. $this->ttyMode = (bool) $ttyMode;
  63258. $this->ptyMode = (bool) $ptyMode;
  63259. $this->disableOutput = (bool) $disableOutput;
  63260. parent::__construct($input);
  63261. }
  63262. public function __destruct()
  63263. {
  63264. $this->close();
  63265. }
  63266. public function getDescriptors()
  63267. {
  63268. if ($this->disableOutput) {
  63269. $nullstream = fopen('/dev/null', 'c');
  63270. return array(
  63271. array('pipe', 'r'),
  63272. $nullstream,
  63273. $nullstream,
  63274. );
  63275. }
  63276. if ($this->ttyMode) {
  63277. return array(
  63278. array('file', '/dev/tty', 'r'),
  63279. array('file', '/dev/tty', 'w'),
  63280. array('file', '/dev/tty', 'w'),
  63281. );
  63282. }
  63283. if ($this->ptyMode && Process::isPtySupported()) {
  63284. return array(
  63285. array('pty'),
  63286. array('pty'),
  63287. array('pty'),
  63288. );
  63289. }
  63290. return array(
  63291. array('pipe', 'r'),
  63292. array('pipe', 'w'),
  63293. array('pipe', 'w'),
  63294. );
  63295. }
  63296. public function getFiles()
  63297. {
  63298. return array();
  63299. }
  63300. public function readAndWrite($blocking, $close = false)
  63301. {
  63302. $this->unblock();
  63303. $w = $this->write();
  63304. $read = $e = array();
  63305. $r = $this->pipes;
  63306. unset($r[0]);
  63307. set_error_handler(array($this, 'handleError'));
  63308. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  63309. restore_error_handler();
  63310. if (!$this->hasSystemCallBeenInterrupted()) {
  63311. $this->pipes = array();
  63312. }
  63313. return $read;
  63314. }
  63315. restore_error_handler();
  63316. foreach ($r as $pipe) {
  63317. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  63318. do {
  63319. $data = fread($pipe, self::CHUNK_SIZE);
  63320. $read[$type] .= $data;
  63321. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  63322. if (!isset($read[$type][0])) {
  63323. unset($read[$type]);
  63324. }
  63325. if ($close && feof($pipe)) {
  63326. fclose($pipe);
  63327. unset($this->pipes[$type]);
  63328. }
  63329. }
  63330. return $read;
  63331. }
  63332. public function areOpen()
  63333. {
  63334. return (bool) $this->pipes;
  63335. }
  63336. public static function create(Process $process, $input)
  63337. {
  63338. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  63339. }
  63340. }
  63341. <?php
  63342. namespace Symfony\Component\Process\Pipes;
  63343. use Symfony\Component\Process\Exception\RuntimeException;
  63344. use Symfony\Component\Process\Process;
  63345. class WindowsPipes extends AbstractPipes
  63346. {
  63347. private $files = array();
  63348. private $fileHandles = array();
  63349. private $lockHandles = array();
  63350. private $readBytes = array(
  63351. Process::STDOUT => 0,
  63352. Process::STDERR => 0,
  63353. );
  63354. private $disableOutput;
  63355. public function __construct($disableOutput, $input)
  63356. {
  63357. $this->disableOutput = (bool) $disableOutput;
  63358. if (!$this->disableOutput) {
  63359. $pipes = array(
  63360. Process::STDOUT => Process::OUT,
  63361. Process::STDERR => Process::ERR,
  63362. );
  63363. $tmpDir = sys_get_temp_dir();
  63364. $lastError = 'unknown reason';
  63365. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  63366. for ($i = 0;; ++$i) {
  63367. foreach ($pipes as $pipe => $name) {
  63368. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  63369. if (!$h = fopen($file.'.lock', 'w')) {
  63370. restore_error_handler();
  63371. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  63372. }
  63373. if (!flock($h, LOCK_EX | LOCK_NB)) {
  63374. continue 2;
  63375. }
  63376. if (isset($this->lockHandles[$pipe])) {
  63377. flock($this->lockHandles[$pipe], LOCK_UN);
  63378. fclose($this->lockHandles[$pipe]);
  63379. }
  63380. $this->lockHandles[$pipe] = $h;
  63381. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  63382. flock($this->lockHandles[$pipe], LOCK_UN);
  63383. fclose($this->lockHandles[$pipe]);
  63384. unset($this->lockHandles[$pipe]);
  63385. continue 2;
  63386. }
  63387. $this->fileHandles[$pipe] = $h;
  63388. $this->files[$pipe] = $file;
  63389. }
  63390. break;
  63391. }
  63392. restore_error_handler();
  63393. }
  63394. parent::__construct($input);
  63395. }
  63396. public function __destruct()
  63397. {
  63398. $this->close();
  63399. }
  63400. public function getDescriptors()
  63401. {
  63402. if ($this->disableOutput) {
  63403. $nullstream = fopen('NUL', 'c');
  63404. return array(
  63405. array('pipe', 'r'),
  63406. $nullstream,
  63407. $nullstream,
  63408. );
  63409. }
  63410. return array(
  63411. array('pipe', 'r'),
  63412. array('file', 'NUL', 'w'),
  63413. array('file', 'NUL', 'w'),
  63414. );
  63415. }
  63416. public function getFiles()
  63417. {
  63418. return $this->files;
  63419. }
  63420. public function readAndWrite($blocking, $close = false)
  63421. {
  63422. $this->unblock();
  63423. $w = $this->write();
  63424. $read = $r = $e = array();
  63425. if ($blocking) {
  63426. if ($w) {
  63427. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  63428. } elseif ($this->fileHandles) {
  63429. usleep(Process::TIMEOUT_PRECISION * 1E6);
  63430. }
  63431. }
  63432. foreach ($this->fileHandles as $type => $fileHandle) {
  63433. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  63434. if (isset($data[0])) {
  63435. $this->readBytes[$type] += \strlen($data);
  63436. $read[$type] = $data;
  63437. }
  63438. if ($close) {
  63439. ftruncate($fileHandle, 0);
  63440. fclose($fileHandle);
  63441. flock($this->lockHandles[$type], LOCK_UN);
  63442. fclose($this->lockHandles[$type]);
  63443. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  63444. }
  63445. }
  63446. return $read;
  63447. }
  63448. public function areOpen()
  63449. {
  63450. return $this->pipes && $this->fileHandles;
  63451. }
  63452. public function close()
  63453. {
  63454. parent::close();
  63455. foreach ($this->fileHandles as $type => $handle) {
  63456. ftruncate($handle, 0);
  63457. fclose($handle);
  63458. flock($this->lockHandles[$type], LOCK_UN);
  63459. fclose($this->lockHandles[$type]);
  63460. }
  63461. $this->fileHandles = $this->lockHandles = array();
  63462. }
  63463. public static function create(Process $process, $input)
  63464. {
  63465. return new static($process->isOutputDisabled(), $input);
  63466. }
  63467. }
  63468. <?php
  63469. namespace Symfony\Component\Process;
  63470. use Symfony\Component\Process\Exception\InvalidArgumentException;
  63471. use Symfony\Component\Process\Exception\LogicException;
  63472. use Symfony\Component\Process\Exception\ProcessFailedException;
  63473. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  63474. use Symfony\Component\Process\Exception\RuntimeException;
  63475. use Symfony\Component\Process\Pipes\PipesInterface;
  63476. use Symfony\Component\Process\Pipes\UnixPipes;
  63477. use Symfony\Component\Process\Pipes\WindowsPipes;
  63478. class Process
  63479. {
  63480. const ERR = 'err';
  63481. const OUT = 'out';
  63482. const STATUS_READY = 'ready';
  63483. const STATUS_STARTED = 'started';
  63484. const STATUS_TERMINATED = 'terminated';
  63485. const STDIN = 0;
  63486. const STDOUT = 1;
  63487. const STDERR = 2;
  63488. const TIMEOUT_PRECISION = 0.2;
  63489. private $callback;
  63490. private $commandline;
  63491. private $cwd;
  63492. private $env;
  63493. private $input;
  63494. private $starttime;
  63495. private $lastOutputTime;
  63496. private $timeout;
  63497. private $idleTimeout;
  63498. private $options;
  63499. private $exitcode;
  63500. private $fallbackStatus = array();
  63501. private $processInformation;
  63502. private $outputDisabled = false;
  63503. private $stdout;
  63504. private $stderr;
  63505. private $enhanceWindowsCompatibility = true;
  63506. private $enhanceSigchildCompatibility;
  63507. private $process;
  63508. private $status = self::STATUS_READY;
  63509. private $incrementalOutputOffset = 0;
  63510. private $incrementalErrorOutputOffset = 0;
  63511. private $tty;
  63512. private $pty;
  63513. private $useFileHandles = false;
  63514. private $processPipes;
  63515. private $latestSignal;
  63516. private static $sigchild;
  63517. public static $exitCodes = array(
  63518. 0 => 'OK',
  63519. 1 => 'General error',
  63520. 2 => 'Misuse of shell builtins',
  63521. 126 => 'Invoked command cannot execute',
  63522. 127 => 'Command not found',
  63523. 128 => 'Invalid exit argument',
  63524. 129 => 'Hangup',
  63525. 130 => 'Interrupt',
  63526. 131 => 'Quit and dump core',
  63527. 132 => 'Illegal instruction',
  63528. 133 => 'Trace/breakpoint trap',
  63529. 134 => 'Process aborted',
  63530. 135 => 'Bus error: "access to undefined portion of memory object"',
  63531. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  63532. 137 => 'Kill (terminate immediately)',
  63533. 138 => 'User-defined 1',
  63534. 139 => 'Segmentation violation',
  63535. 140 => 'User-defined 2',
  63536. 141 => 'Write to pipe with no one reading',
  63537. 142 => 'Signal raised by alarm',
  63538. 143 => 'Termination (request to terminate)',
  63539. 145 => 'Child process terminated, stopped (or continued*)',
  63540. 146 => 'Continue if stopped',
  63541. 147 => 'Stop executing temporarily',
  63542. 148 => 'Terminal stop signal',
  63543. 149 => 'Background process attempting to read from tty ("in")',
  63544. 150 => 'Background process attempting to write to tty ("out")',
  63545. 151 => 'Urgent data available on socket',
  63546. 152 => 'CPU time limit exceeded',
  63547. 153 => 'File size limit exceeded',
  63548. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  63549. 155 => 'Profiling timer expired',
  63550. 157 => 'Pollable event',
  63551. 159 => 'Bad syscall',
  63552. );
  63553. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  63554. {
  63555. if (!\function_exists('proc_open')) {
  63556. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  63557. }
  63558. $this->commandline = $commandline;
  63559. $this->cwd = $cwd;
  63560. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  63561. $this->cwd = getcwd();
  63562. }
  63563. if (null !== $env) {
  63564. $this->setEnv($env);
  63565. }
  63566. $this->setInput($input);
  63567. $this->setTimeout($timeout);
  63568. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  63569. $this->pty = false;
  63570. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  63571. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  63572. }
  63573. public function __destruct()
  63574. {
  63575. $this->stop(0);
  63576. }
  63577. public function __clone()
  63578. {
  63579. $this->resetProcessData();
  63580. }
  63581. public function run($callback = null)
  63582. {
  63583. $this->start($callback);
  63584. return $this->wait();
  63585. }
  63586. public function mustRun($callback = null)
  63587. {
  63588. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63589. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  63590. }
  63591. if (0 !== $this->run($callback)) {
  63592. throw new ProcessFailedException($this);
  63593. }
  63594. return $this;
  63595. }
  63596. public function start($callback = null)
  63597. {
  63598. if ($this->isRunning()) {
  63599. throw new RuntimeException('Process is already running');
  63600. }
  63601. if ($this->outputDisabled && null !== $callback) {
  63602. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  63603. }
  63604. $this->resetProcessData();
  63605. $this->starttime = $this->lastOutputTime = microtime(true);
  63606. $this->callback = $this->buildCallback($callback);
  63607. $descriptors = $this->getDescriptors();
  63608. $commandline = $this->commandline;
  63609. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  63610. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  63611. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  63612. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  63613. }
  63614. $commandline .= '"';
  63615. if (!isset($this->options['bypass_shell'])) {
  63616. $this->options['bypass_shell'] = true;
  63617. }
  63618. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63619. $descriptors[3] = array('pipe', 'w');
  63620. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  63621. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  63622. $ptsWorkaround = fopen(__FILE__, 'r');
  63623. }
  63624. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  63625. if (!\is_resource($this->process)) {
  63626. throw new RuntimeException('Unable to launch a new process.');
  63627. }
  63628. $this->status = self::STATUS_STARTED;
  63629. if (isset($descriptors[3])) {
  63630. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  63631. }
  63632. if ($this->tty) {
  63633. return;
  63634. }
  63635. $this->updateStatus(false);
  63636. $this->checkTimeout();
  63637. }
  63638. public function restart($callback = null)
  63639. {
  63640. if ($this->isRunning()) {
  63641. throw new RuntimeException('Process is already running');
  63642. }
  63643. $process = clone $this;
  63644. $process->start($callback);
  63645. return $process;
  63646. }
  63647. public function wait($callback = null)
  63648. {
  63649. $this->requireProcessIsStarted(__FUNCTION__);
  63650. $this->updateStatus(false);
  63651. if (null !== $callback) {
  63652. $this->callback = $this->buildCallback($callback);
  63653. }
  63654. do {
  63655. $this->checkTimeout();
  63656. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  63657. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  63658. } while ($running);
  63659. while ($this->isRunning()) {
  63660. usleep(1000);
  63661. }
  63662. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  63663. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  63664. }
  63665. return $this->exitcode;
  63666. }
  63667. public function getPid()
  63668. {
  63669. return $this->isRunning() ? $this->processInformation['pid'] : null;
  63670. }
  63671. public function signal($signal)
  63672. {
  63673. $this->doSignal($signal, true);
  63674. return $this;
  63675. }
  63676. public function disableOutput()
  63677. {
  63678. if ($this->isRunning()) {
  63679. throw new RuntimeException('Disabling output while the process is running is not possible.');
  63680. }
  63681. if (null !== $this->idleTimeout) {
  63682. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  63683. }
  63684. $this->outputDisabled = true;
  63685. return $this;
  63686. }
  63687. public function enableOutput()
  63688. {
  63689. if ($this->isRunning()) {
  63690. throw new RuntimeException('Enabling output while the process is running is not possible.');
  63691. }
  63692. $this->outputDisabled = false;
  63693. return $this;
  63694. }
  63695. public function isOutputDisabled()
  63696. {
  63697. return $this->outputDisabled;
  63698. }
  63699. public function getOutput()
  63700. {
  63701. $this->readPipesForOutput(__FUNCTION__);
  63702. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  63703. return '';
  63704. }
  63705. return $ret;
  63706. }
  63707. public function getIncrementalOutput()
  63708. {
  63709. $this->readPipesForOutput(__FUNCTION__);
  63710. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  63711. $this->incrementalOutputOffset = ftell($this->stdout);
  63712. if (false === $latest) {
  63713. return '';
  63714. }
  63715. return $latest;
  63716. }
  63717. public function clearOutput()
  63718. {
  63719. ftruncate($this->stdout, 0);
  63720. fseek($this->stdout, 0);
  63721. $this->incrementalOutputOffset = 0;
  63722. return $this;
  63723. }
  63724. public function getErrorOutput()
  63725. {
  63726. $this->readPipesForOutput(__FUNCTION__);
  63727. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  63728. return '';
  63729. }
  63730. return $ret;
  63731. }
  63732. public function getIncrementalErrorOutput()
  63733. {
  63734. $this->readPipesForOutput(__FUNCTION__);
  63735. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  63736. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  63737. if (false === $latest) {
  63738. return '';
  63739. }
  63740. return $latest;
  63741. }
  63742. public function clearErrorOutput()
  63743. {
  63744. ftruncate($this->stderr, 0);
  63745. fseek($this->stderr, 0);
  63746. $this->incrementalErrorOutputOffset = 0;
  63747. return $this;
  63748. }
  63749. public function getExitCode()
  63750. {
  63751. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63752. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  63753. }
  63754. $this->updateStatus(false);
  63755. return $this->exitcode;
  63756. }
  63757. public function getExitCodeText()
  63758. {
  63759. if (null === $exitcode = $this->getExitCode()) {
  63760. return;
  63761. }
  63762. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  63763. }
  63764. public function isSuccessful()
  63765. {
  63766. return 0 === $this->getExitCode();
  63767. }
  63768. public function hasBeenSignaled()
  63769. {
  63770. $this->requireProcessIsTerminated(__FUNCTION__);
  63771. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63772. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63773. }
  63774. return $this->processInformation['signaled'];
  63775. }
  63776. public function getTermSignal()
  63777. {
  63778. $this->requireProcessIsTerminated(__FUNCTION__);
  63779. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  63780. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63781. }
  63782. return $this->processInformation['termsig'];
  63783. }
  63784. public function hasBeenStopped()
  63785. {
  63786. $this->requireProcessIsTerminated(__FUNCTION__);
  63787. return $this->processInformation['stopped'];
  63788. }
  63789. public function getStopSignal()
  63790. {
  63791. $this->requireProcessIsTerminated(__FUNCTION__);
  63792. return $this->processInformation['stopsig'];
  63793. }
  63794. public function isRunning()
  63795. {
  63796. if (self::STATUS_STARTED !== $this->status) {
  63797. return false;
  63798. }
  63799. $this->updateStatus(false);
  63800. return $this->processInformation['running'];
  63801. }
  63802. public function isStarted()
  63803. {
  63804. return self::STATUS_READY != $this->status;
  63805. }
  63806. public function isTerminated()
  63807. {
  63808. $this->updateStatus(false);
  63809. return self::STATUS_TERMINATED == $this->status;
  63810. }
  63811. public function getStatus()
  63812. {
  63813. $this->updateStatus(false);
  63814. return $this->status;
  63815. }
  63816. public function stop($timeout = 10, $signal = null)
  63817. {
  63818. $timeoutMicro = microtime(true) + $timeout;
  63819. if ($this->isRunning()) {
  63820. $this->doSignal(15, false);
  63821. do {
  63822. usleep(1000);
  63823. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  63824. if ($this->isRunning()) {
  63825. $this->doSignal($signal ?: 9, false);
  63826. }
  63827. }
  63828. if ($this->isRunning()) {
  63829. if (isset($this->fallbackStatus['pid'])) {
  63830. unset($this->fallbackStatus['pid']);
  63831. return $this->stop(0, $signal);
  63832. }
  63833. $this->close();
  63834. }
  63835. return $this->exitcode;
  63836. }
  63837. public function addOutput($line)
  63838. {
  63839. $this->lastOutputTime = microtime(true);
  63840. fseek($this->stdout, 0, SEEK_END);
  63841. fwrite($this->stdout, $line);
  63842. fseek($this->stdout, $this->incrementalOutputOffset);
  63843. }
  63844. public function addErrorOutput($line)
  63845. {
  63846. $this->lastOutputTime = microtime(true);
  63847. fseek($this->stderr, 0, SEEK_END);
  63848. fwrite($this->stderr, $line);
  63849. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  63850. }
  63851. public function getCommandLine()
  63852. {
  63853. return $this->commandline;
  63854. }
  63855. public function setCommandLine($commandline)
  63856. {
  63857. $this->commandline = $commandline;
  63858. return $this;
  63859. }
  63860. public function getTimeout()
  63861. {
  63862. return $this->timeout;
  63863. }
  63864. public function getIdleTimeout()
  63865. {
  63866. return $this->idleTimeout;
  63867. }
  63868. public function setTimeout($timeout)
  63869. {
  63870. $this->timeout = $this->validateTimeout($timeout);
  63871. return $this;
  63872. }
  63873. public function setIdleTimeout($timeout)
  63874. {
  63875. if (null !== $timeout && $this->outputDisabled) {
  63876. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  63877. }
  63878. $this->idleTimeout = $this->validateTimeout($timeout);
  63879. return $this;
  63880. }
  63881. public function setTty($tty)
  63882. {
  63883. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  63884. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  63885. }
  63886. if ($tty) {
  63887. static $isTtySupported;
  63888. if (null === $isTtySupported) {
  63889. $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);
  63890. }
  63891. if (!$isTtySupported) {
  63892. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  63893. }
  63894. }
  63895. $this->tty = (bool) $tty;
  63896. return $this;
  63897. }
  63898. public function isTty()
  63899. {
  63900. return $this->tty;
  63901. }
  63902. public function setPty($bool)
  63903. {
  63904. $this->pty = (bool) $bool;
  63905. return $this;
  63906. }
  63907. public function isPty()
  63908. {
  63909. return $this->pty;
  63910. }
  63911. public function getWorkingDirectory()
  63912. {
  63913. if (null === $this->cwd) {
  63914. return getcwd() ?: null;
  63915. }
  63916. return $this->cwd;
  63917. }
  63918. public function setWorkingDirectory($cwd)
  63919. {
  63920. $this->cwd = $cwd;
  63921. return $this;
  63922. }
  63923. public function getEnv()
  63924. {
  63925. return $this->env;
  63926. }
  63927. public function setEnv(array $env)
  63928. {
  63929. $env = array_filter($env, function ($value) {
  63930. return !\is_array($value);
  63931. });
  63932. $this->env = array();
  63933. foreach ($env as $key => $value) {
  63934. $this->env[$key] = (string) $value;
  63935. }
  63936. return $this;
  63937. }
  63938. public function getStdin()
  63939. {
  63940. @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);
  63941. return $this->getInput();
  63942. }
  63943. public function getInput()
  63944. {
  63945. return $this->input;
  63946. }
  63947. public function setStdin($stdin)
  63948. {
  63949. @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);
  63950. return $this->setInput($stdin);
  63951. }
  63952. public function setInput($input)
  63953. {
  63954. if ($this->isRunning()) {
  63955. throw new LogicException('Input can not be set while the process is running.');
  63956. }
  63957. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  63958. return $this;
  63959. }
  63960. public function getOptions()
  63961. {
  63962. return $this->options;
  63963. }
  63964. public function setOptions(array $options)
  63965. {
  63966. $this->options = $options;
  63967. return $this;
  63968. }
  63969. public function getEnhanceWindowsCompatibility()
  63970. {
  63971. return $this->enhanceWindowsCompatibility;
  63972. }
  63973. public function setEnhanceWindowsCompatibility($enhance)
  63974. {
  63975. $this->enhanceWindowsCompatibility = (bool) $enhance;
  63976. return $this;
  63977. }
  63978. public function getEnhanceSigchildCompatibility()
  63979. {
  63980. return $this->enhanceSigchildCompatibility;
  63981. }
  63982. public function setEnhanceSigchildCompatibility($enhance)
  63983. {
  63984. $this->enhanceSigchildCompatibility = (bool) $enhance;
  63985. return $this;
  63986. }
  63987. public function checkTimeout()
  63988. {
  63989. if (self::STATUS_STARTED !== $this->status) {
  63990. return;
  63991. }
  63992. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  63993. $this->stop(0);
  63994. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  63995. }
  63996. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  63997. $this->stop(0);
  63998. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  63999. }
  64000. }
  64001. public static function isPtySupported()
  64002. {
  64003. static $result;
  64004. if (null !== $result) {
  64005. return $result;
  64006. }
  64007. if ('\\' === \DIRECTORY_SEPARATOR) {
  64008. return $result = false;
  64009. }
  64010. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  64011. }
  64012. private function getDescriptors()
  64013. {
  64014. if ('\\' === \DIRECTORY_SEPARATOR) {
  64015. $this->processPipes = WindowsPipes::create($this, $this->input);
  64016. } else {
  64017. $this->processPipes = UnixPipes::create($this, $this->input);
  64018. }
  64019. return $this->processPipes->getDescriptors();
  64020. }
  64021. protected function buildCallback($callback)
  64022. {
  64023. $that = $this;
  64024. $out = self::OUT;
  64025. $callback = function ($type, $data) use ($that, $callback, $out) {
  64026. if ($out == $type) {
  64027. $that->addOutput($data);
  64028. } else {
  64029. $that->addErrorOutput($data);
  64030. }
  64031. if (null !== $callback) {
  64032. \call_user_func($callback, $type, $data);
  64033. }
  64034. };
  64035. return $callback;
  64036. }
  64037. protected function updateStatus($blocking)
  64038. {
  64039. if (self::STATUS_STARTED !== $this->status) {
  64040. return;
  64041. }
  64042. $this->processInformation = proc_get_status($this->process);
  64043. $running = $this->processInformation['running'];
  64044. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  64045. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  64046. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  64047. }
  64048. if (!$running) {
  64049. $this->close();
  64050. }
  64051. }
  64052. protected function isSigchildEnabled()
  64053. {
  64054. if (null !== self::$sigchild) {
  64055. return self::$sigchild;
  64056. }
  64057. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  64058. return self::$sigchild = false;
  64059. }
  64060. ob_start();
  64061. phpinfo(INFO_GENERAL);
  64062. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  64063. }
  64064. private function readPipesForOutput($caller)
  64065. {
  64066. if ($this->outputDisabled) {
  64067. throw new LogicException('Output has been disabled.');
  64068. }
  64069. $this->requireProcessIsStarted($caller);
  64070. $this->updateStatus(false);
  64071. }
  64072. private function validateTimeout($timeout)
  64073. {
  64074. $timeout = (float) $timeout;
  64075. if (0.0 === $timeout) {
  64076. $timeout = null;
  64077. } elseif ($timeout < 0) {
  64078. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  64079. }
  64080. return $timeout;
  64081. }
  64082. private function readPipes($blocking, $close)
  64083. {
  64084. $result = $this->processPipes->readAndWrite($blocking, $close);
  64085. $callback = $this->callback;
  64086. foreach ($result as $type => $data) {
  64087. if (3 !== $type) {
  64088. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  64089. } elseif (!isset($this->fallbackStatus['signaled'])) {
  64090. $this->fallbackStatus['exitcode'] = (int) $data;
  64091. }
  64092. }
  64093. }
  64094. private function close()
  64095. {
  64096. $this->processPipes->close();
  64097. if (\is_resource($this->process)) {
  64098. proc_close($this->process);
  64099. }
  64100. $this->exitcode = $this->processInformation['exitcode'];
  64101. $this->status = self::STATUS_TERMINATED;
  64102. if (-1 === $this->exitcode) {
  64103. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  64104. $this->exitcode = 128 + $this->processInformation['termsig'];
  64105. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  64106. $this->processInformation['signaled'] = true;
  64107. $this->processInformation['termsig'] = -1;
  64108. }
  64109. }
  64110. $this->callback = null;
  64111. return $this->exitcode;
  64112. }
  64113. private function resetProcessData()
  64114. {
  64115. $this->starttime = null;
  64116. $this->callback = null;
  64117. $this->exitcode = null;
  64118. $this->fallbackStatus = array();
  64119. $this->processInformation = null;
  64120. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  64121. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  64122. $this->process = null;
  64123. $this->latestSignal = null;
  64124. $this->status = self::STATUS_READY;
  64125. $this->incrementalOutputOffset = 0;
  64126. $this->incrementalErrorOutputOffset = 0;
  64127. }
  64128. private function doSignal($signal, $throwException)
  64129. {
  64130. if (null === $pid = $this->getPid()) {
  64131. if ($throwException) {
  64132. throw new LogicException('Can not send signal on a non running process.');
  64133. }
  64134. return false;
  64135. }
  64136. if ('\\' === \DIRECTORY_SEPARATOR) {
  64137. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  64138. if ($exitCode && $this->isRunning()) {
  64139. if ($throwException) {
  64140. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  64141. }
  64142. return false;
  64143. }
  64144. } else {
  64145. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  64146. $ok = @proc_terminate($this->process, $signal);
  64147. } elseif (\function_exists('posix_kill')) {
  64148. $ok = @posix_kill($pid, $signal);
  64149. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  64150. $ok = false === fgets($pipes[2]);
  64151. }
  64152. if (!$ok) {
  64153. if ($throwException) {
  64154. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  64155. }
  64156. return false;
  64157. }
  64158. }
  64159. $this->latestSignal = (int) $signal;
  64160. $this->fallbackStatus['signaled'] = true;
  64161. $this->fallbackStatus['exitcode'] = -1;
  64162. $this->fallbackStatus['termsig'] = $this->latestSignal;
  64163. return true;
  64164. }
  64165. private function requireProcessIsStarted($functionName)
  64166. {
  64167. if (!$this->isStarted()) {
  64168. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  64169. }
  64170. }
  64171. private function requireProcessIsTerminated($functionName)
  64172. {
  64173. if (!$this->isTerminated()) {
  64174. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  64175. }
  64176. }
  64177. }
  64178. <?php
  64179. namespace Symfony\Component\Process;
  64180. use Symfony\Component\Process\Exception\InvalidArgumentException;
  64181. use Symfony\Component\Process\Exception\LogicException;
  64182. class ProcessBuilder
  64183. {
  64184. private $arguments;
  64185. private $cwd;
  64186. private $env = array();
  64187. private $input;
  64188. private $timeout = 60;
  64189. private $options = array();
  64190. private $inheritEnv = true;
  64191. private $prefix = array();
  64192. private $outputDisabled = false;
  64193. public function __construct(array $arguments = array())
  64194. {
  64195. $this->arguments = $arguments;
  64196. }
  64197. public static function create(array $arguments = array())
  64198. {
  64199. return new static($arguments);
  64200. }
  64201. public function add($argument)
  64202. {
  64203. $this->arguments[] = $argument;
  64204. return $this;
  64205. }
  64206. public function setPrefix($prefix)
  64207. {
  64208. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  64209. return $this;
  64210. }
  64211. public function setArguments(array $arguments)
  64212. {
  64213. $this->arguments = $arguments;
  64214. return $this;
  64215. }
  64216. public function setWorkingDirectory($cwd)
  64217. {
  64218. $this->cwd = $cwd;
  64219. return $this;
  64220. }
  64221. public function inheritEnvironmentVariables($inheritEnv = true)
  64222. {
  64223. $this->inheritEnv = $inheritEnv;
  64224. return $this;
  64225. }
  64226. public function setEnv($name, $value)
  64227. {
  64228. $this->env[$name] = $value;
  64229. return $this;
  64230. }
  64231. public function addEnvironmentVariables(array $variables)
  64232. {
  64233. $this->env = array_replace($this->env, $variables);
  64234. return $this;
  64235. }
  64236. public function setInput($input)
  64237. {
  64238. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  64239. return $this;
  64240. }
  64241. public function setTimeout($timeout)
  64242. {
  64243. if (null === $timeout) {
  64244. $this->timeout = null;
  64245. return $this;
  64246. }
  64247. $timeout = (float) $timeout;
  64248. if ($timeout < 0) {
  64249. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  64250. }
  64251. $this->timeout = $timeout;
  64252. return $this;
  64253. }
  64254. public function setOption($name, $value)
  64255. {
  64256. $this->options[$name] = $value;
  64257. return $this;
  64258. }
  64259. public function disableOutput()
  64260. {
  64261. $this->outputDisabled = true;
  64262. return $this;
  64263. }
  64264. public function enableOutput()
  64265. {
  64266. $this->outputDisabled = false;
  64267. return $this;
  64268. }
  64269. public function getProcess()
  64270. {
  64271. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  64272. throw new LogicException('You must add() command arguments before calling getProcess().');
  64273. }
  64274. $options = $this->options;
  64275. $arguments = array_merge($this->prefix, $this->arguments);
  64276. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  64277. if ($this->inheritEnv) {
  64278. $env = array_replace($_ENV, $_SERVER, $this->env);
  64279. } else {
  64280. $env = $this->env;
  64281. }
  64282. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  64283. if ($this->outputDisabled) {
  64284. $process->disableOutput();
  64285. }
  64286. return $process;
  64287. }
  64288. }
  64289. <?php
  64290. namespace Symfony\Component\Process;
  64291. use Symfony\Component\Process\Exception\InvalidArgumentException;
  64292. class ProcessUtils
  64293. {
  64294. private function __construct()
  64295. {
  64296. }
  64297. public static function escapeArgument($argument)
  64298. {
  64299. if ('\\' === \DIRECTORY_SEPARATOR) {
  64300. if ('' === $argument) {
  64301. return escapeshellarg($argument);
  64302. }
  64303. $escapedArgument = '';
  64304. $quote = false;
  64305. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  64306. if ('"' === $part) {
  64307. $escapedArgument .= '\\"';
  64308. } elseif (self::isSurroundedBy($part, '%')) {
  64309. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  64310. } else {
  64311. if ('\\' === substr($part, -1)) {
  64312. $part .= '\\';
  64313. }
  64314. $quote = true;
  64315. $escapedArgument .= $part;
  64316. }
  64317. }
  64318. if ($quote) {
  64319. $escapedArgument = '"'.$escapedArgument.'"';
  64320. }
  64321. return $escapedArgument;
  64322. }
  64323. return "'".str_replace("'", "'\\''", $argument)."'";
  64324. }
  64325. public static function validateInput($caller, $input)
  64326. {
  64327. if (null !== $input) {
  64328. if (\is_resource($input)) {
  64329. return $input;
  64330. }
  64331. if (\is_string($input)) {
  64332. return $input;
  64333. }
  64334. if (is_scalar($input)) {
  64335. return (string) $input;
  64336. }
  64337. if (\is_object($input) && method_exists($input, '__toString')) {
  64338. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  64339. return (string) $input;
  64340. }
  64341. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  64342. }
  64343. return $input;
  64344. }
  64345. private static function isSurroundedBy($arg, $char)
  64346. {
  64347. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  64348. }
  64349. }
  64350. <?php
  64351. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  64352. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  64353. }
  64354. setlocale(LC_ALL, 'C');
  64355. require __DIR__.'/../src/bootstrap.php';
  64356. use Composer\Console\Application;
  64357. use Composer\XdebugHandler\XdebugHandler;
  64358. error_reporting(-1);
  64359. // Restart without Xdebug
  64360. $xdebug = new XdebugHandler('Composer', '--ansi');
  64361. $xdebug->check();
  64362. unset($xdebug);
  64363. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  64364. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  64365. exit(1);
  64366. }
  64367. if (function_exists('ini_set')) {
  64368. @ini_set('display_errors', '1');
  64369. // Set user defined memory limit
  64370. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  64371. @ini_set('memory_limit', $memoryLimit);
  64372. } else {
  64373. $memoryInBytes = function ($value) {
  64374. $unit = strtolower(substr($value, -1, 1));
  64375. $value = (int) $value;
  64376. switch($unit) {
  64377. case 'g':
  64378. $value *= 1024;
  64379. // no break (cumulative multiplier)
  64380. case 'm':
  64381. $value *= 1024;
  64382. // no break (cumulative multiplier)
  64383. case 'k':
  64384. $value *= 1024;
  64385. }
  64386. return $value;
  64387. };
  64388. $memoryLimit = trim(ini_get('memory_limit'));
  64389. // Increase memory_limit if it is lower than 1.5GB
  64390. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  64391. @ini_set('memory_limit', '1536M');
  64392. }
  64393. unset($memoryInBytes);
  64394. }
  64395. unset($memoryLimit);
  64396. }
  64397. putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
  64398. // run the command application
  64399. $application = new Application();
  64400. $application->run();
  64401. Copyright (c) Nils Adermann, Jordi Boggiano
  64402. Permission is hereby granted, free of charge, to any person obtaining a copy
  64403. of this software and associated documentation files (the "Software"), to deal
  64404. in the Software without restriction, including without limitation the rights
  64405. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  64406. copies of the Software, and to permit persons to whom the Software is furnished
  64407. to do so, subject to the following conditions:
  64408. The above copyright notice and this permission notice shall be included in all
  64409. copies or substantial portions of the Software.
  64410. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  64411. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  64412. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  64413. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  64414. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  64415. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  64416. THE SOFTWARE.
  64417. ½×µC<7‹fP—£­€Ðo—fü���GBMB