composer.phar 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081
  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.phpz~��Ê´®_z~��é;�+¤������+���src/Composer/Autoload/ClassMapGenerator.phpî��Ê´®_î��í¼šl¤���������src/Composer/Cache.phpê��Ê´®_ê��ø¿=9¤������%���src/Composer/Command/AboutCommand.phpØ��Ê´®_Ø��ö÷;‡¤������'���src/Composer/Command/ArchiveCommand.phpÀ��Ê´®_À��Á’ =¤������$���src/Composer/Command/BaseCommand.phpG��Ê´®_G��p›_ƒ¤������.���src/Composer/Command/BaseDependencyCommand.php\��Ê´®_\��©L“Ƥ������1���src/Composer/Command/CheckPlatformReqsCommand.phpå��Ê´®_å��»Z¹g¤������*���src/Composer/Command/ClearCacheCommand.phpó��Ê´®_ó��ˆ(*Ô¤������&���src/Composer/Command/ConfigCommand.phpX��Ê´®_X��Û ´¤������-���src/Composer/Command/CreateProjectCommand.phpÐB��Ê´®_ÐB��£Â�ª¤������'���src/Composer/Command/DependsCommand.phpñ��Ê´®_ñ��kU‹{¤������(���src/Composer/Command/DiagnoseCommand.phpQI��Ê´®_QI��çÃ/Ȥ������,���src/Composer/Command/DumpAutoloadCommand.php±��Ê´®_±��a#®¤������$���src/Composer/Command/ExecCommand.php ��Ê´®_ ��X?!“¤������$���src/Composer/Command/FundCommand.phph ��Ê´®_h ��!›¤������&���src/Composer/Command/GlobalCommand.phpÊ ��Ê´®_Ê ���œE¤������$���src/Composer/Command/HomeCommand.php ��Ê´®_ ��àÓ¬¤������$���src/Composer/Command/InitCommand.php™[��Ê´®_™[��¡–à€¤������'���src/Composer/Command/InstallCommand.php)��Ê´®_)��”dö¤������(���src/Composer/Command/LicensesCommand.php[��Ê´®_[��íŸ!U¤������(���src/Composer/Command/OutdatedCommand.php� ��Ê´®_� ��7~½=¤������)���src/Composer/Command/ProhibitsCommand.php��Ê´®_��_¤éS¤������&���src/Composer/Command/RemoveCommand.php·)��Ê´®_·)��Þ4å¤������'���src/Composer/Command/RequireCommand.php˜7��Ê´®_˜7��( Œ¤������)���src/Composer/Command/RunScriptCommand.phpH��Ê´®_H��,_¼Ë¤������+���src/Composer/Command/ScriptAliasCommand.php¯��Ê´®_¯��?=Ѥ������&���src/Composer/Command/SearchCommand.phpU ��Ê´®_U ��…ߤ������*���src/Composer/Command/SelfUpdateCommand.php“C��Ê´®_“C��ºe�¤������$���src/Composer/Command/ShowCommand.phpt‹��Ê´®_t‹��’‚¢¤������&���src/Composer/Command/StatusCommand.phpò��Ê´®_ò��Ð�ô°¤������(���src/Composer/Command/SuggestsCommand.phpœ ��Ê´®_œ ��Ö”¤������&���src/Composer/Command/UpdateCommand.php12��Ê´®_12��K†<¤������(���src/Composer/Command/ValidateCommand.phpM��Ê´®_M��pwÓ’¤���������src/Composer/Composer.php ��Ê´®_ ��jûÌ|¤���������src/Composer/Config.phpu%��Ê´®_u%��χj~¤������-���src/Composer/Config/ConfigSourceInterface.php��Ê´®_���û¤������(���src/Composer/Config/JsonConfigSource.phps��Ê´®_s��:Iˆ¤������$���src/Composer/Console/Application.php<��Ê´®_<��~I¤������*���src/Composer/Console/GithubActionError.php`��Ê´®_`��ï×y ¤������,���src/Composer/Console/HtmlOutputFormatter.php3��Ê´®_3��Ú�Eu¤������-���src/Composer/DependencyResolver/Decisions.php<��Ê´®_<��_$©¤������1���src/Composer/DependencyResolver/DefaultPolicy.phpü��Ê´®_ü��q-=¤������/���src/Composer/DependencyResolver/GenericRule.php¢��Ê´®_¢��|x¬_¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.php”��Ê´®_”�� (o¤������3���src/Composer/DependencyResolver/LockTransaction.phpj ��Ê´®_j ��¿j™¤������5���src/Composer/DependencyResolver/MultiConflictRule.php-��Ê´®_-��´´š¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.php·��Ê´®_·��#Ò­’¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php��Ê´®_��RØDå¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php ��Ê´®_ ��ÇA;Ú¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÚ���Ê´®_Ú���Qâè¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.phpF��Ê´®_F�� ƒ‹s¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpŸ��Ê´®_Ÿ��o ±(¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpG��Ê´®_G��–ˆ
  25. ¤������3���src/Composer/DependencyResolver/PolicyInterface.php6��Ê´®_6��³m〤������(���src/Composer/DependencyResolver/Pool.phps��Ê´®_s��¤èCC¤������/���src/Composer/DependencyResolver/PoolBuilder.phpc0��Ê´®_c0��(¥‚Ö¤������+���src/Composer/DependencyResolver/Problem.php,6��Ê´®_,6��­zúܤ������+���src/Composer/DependencyResolver/Request.php��Ê´®_��{·Ñ¤������(���src/Composer/DependencyResolver/Rule.phpµ&��Ê´®_µ&��+óƒ¤������1���src/Composer/DependencyResolver/Rule2Literals.php��Ê´®_��ª÷Ϥ������+���src/Composer/DependencyResolver/RuleSet.phpt ��Ê´®_t ��Cyoâ¤������4���src/Composer/DependencyResolver/RuleSetGenerator.php¯��Ê´®_¯��ߌ;_¤������3���src/Composer/DependencyResolver/RuleSetIterator.php ��Ê´®_ ��…gØ,¤������2���src/Composer/DependencyResolver/RuleWatchChain.phpi��Ê´®_i��hïš,¤������2���src/Composer/DependencyResolver/RuleWatchGraph.php< ��Ê´®_< ��š8¿z¤������1���src/Composer/DependencyResolver/RuleWatchNode.php3��Ê´®_3��š±aÖ¤������*���src/Composer/DependencyResolver/Solver.php^8��Ê´®_^8��s5Q9¤������6���src/Composer/DependencyResolver/SolverBugException.php™��Ê´®_™��Xg6¤������;���src/Composer/DependencyResolver/SolverProblemsException.phpÒ ��Ê´®_Ò ��Íi¾T¤������/���src/Composer/DependencyResolver/Transaction.phpÂ��Ê´®_Â�� ý¹¤������-���src/Composer/Downloader/ArchiveDownloader.phpj ��Ê´®_j ��¨sá¤������1���src/Composer/Downloader/ChangeReportInterface.phpÌ���Ê´®_Ì���¯à¨¿¤������+���src/Composer/Downloader/DownloadManager.php;��Ê´®_;��2q²P¤������/���src/Composer/Downloader/DownloaderInterface.php��Ê´®_��<ê ¤������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ���Ê´®_Ñ���&Áœ¿¤������*���src/Composer/Downloader/FileDownloader.php�*��Ê´®_�*��ŒÀU¤������/���src/Composer/Downloader/FilesystemException.php
  26. ��Ê´®_
  27. ��.-‹¤������,���src/Composer/Downloader/FossilDownloader.phpÖ ��Ê´®_Ö ��À¯é¤������)���src/Composer/Downloader/GitDownloader.php€<��Ê´®_€<��=�>¤������*���src/Composer/Downloader/GzipDownloader.phpy��Ê´®_y��·Á�]¤������(���src/Composer/Downloader/HgDownloader.php ��Ê´®_ ��«£þ/¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phpi���Ê´®_i���Öt~p¤������*���src/Composer/Downloader/PathDownloader.phpe��Ê´®_e��op¤������.���src/Composer/Downloader/PerforceDownloader.php��Ê´®_��ܘ¤������*���src/Composer/Downloader/PharDownloader.php(��Ê´®_(��”=K¤������)���src/Composer/Downloader/RarDownloader.php®��Ê´®_®��]'ƒÇ¤������)���src/Composer/Downloader/SvnDownloader.phpF��Ê´®_F��ÊD‡¤������)���src/Composer/Downloader/TarDownloader.php&��Ê´®_&��C€—€¤������.���src/Composer/Downloader/TransportException.php=��Ê´®_=��ZÎÈÞ¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ���Ê´®_Ô���`§ôö¤������)���src/Composer/Downloader/VcsDownloader.phpA��Ê´®_A��Nmm ¤������(���src/Composer/Downloader/XzDownloader.phpç��Ê´®_ç��x�3.¤������)���src/Composer/Downloader/ZipDownloader.php«��Ê´®_«��Õò¤������&���src/Composer/EventDispatcher/Event.php ��Ê´®_ ��±™jï¤������0���src/Composer/EventDispatcher/EventDispatcher.php/.��Ê´®_/.��KÜ€§¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©���Ê´®_©���h·0¤������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv���Ê´®_v���wZ8S¤������9���src/Composer/Exception/IrrecoverableDownloadException.phpv���Ê´®_v���DM½y¤������)���src/Composer/Exception/NoSslException.phph���Ê´®_h���ˆdñÓ¤���������src/Composer/Factory.phpœB��Ê´®_œB��¾­c”¤���������src/Composer/IO/BaseIO.php��Ê´®_��´ó|¤���������src/Composer/IO/BufferIO.php·��Ê´®_·�� i² ¤���������src/Composer/IO/ConsoleIO.phpº��Ê´®_º��'ü¤ø¤���������src/Composer/IO/IOInterface.phpØ��Ê´®_Ø��Fò°ð¤���������src/Composer/IO/NullIO.phpÀ��Ê´®_À��F`sʤ������"���src/Composer/InstalledVersions.php- ��Ê´®_- ��&“ò(¤���������src/Composer/Installer.phpôs��Ê´®_ôs��N™¤������*���src/Composer/Installer/BinaryInstaller.php
  28. ��Ê´®_
  29. ��t¤{ø¤������2���src/Composer/Installer/BinaryPresenceInterface.phpË���Ê´®_Ë���À5š¨¤������.���src/Composer/Installer/InstallationManager.phpÍ1��Ê´®_Í1���+¦u¤������)���src/Composer/Installer/InstallerEvent.phpŒ��Ê´®_Œ��š´Úë¤������*���src/Composer/Installer/InstallerEvents.php…���Ê´®_…���nÜ<Á¤������-���src/Composer/Installer/InstallerInterface.phpJ��Ê´®_J��hK.U¤������+���src/Composer/Installer/LibraryInstaller.phpi��Ê´®_i��‰Á%è¤������/���src/Composer/Installer/MetapackageInstaller.phpü��Ê´®_ü��aNÕ‘¤������(���src/Composer/Installer/NoopInstaller.php]��Ê´®_]��Û‰öÓ¤������'���src/Composer/Installer/PackageEvent.php��Ê´®_��=ÉФ������(���src/Composer/Installer/PackageEvents.php¸��Ê´®_¸��dbØs¤������*���src/Composer/Installer/PluginInstaller.phpK
  30. ��Ê´®_K
  31. ��´S‚¤������+���src/Composer/Installer/ProjectInstaller.phpf��Ê´®_f��ÙÇ“B¤������4���src/Composer/Installer/SuggestedPackagesReporter.php��Ê´®_��Vt–¤���������src/Composer/Json/JsonFile.phpÿ��Ê´®_ÿ��²†»Ò¤������#���src/Composer/Json/JsonFormatter.php^��Ê´®_^��‚£.î¤������%���src/Composer/Json/JsonManipulator.phpÁ7��Ê´®_Á7���ýH¤������-���src/Composer/Json/JsonValidationException.php\��Ê´®_\��.Xóܤ������%���src/Composer/Package/AliasPackage.phpè��Ê´®_è��/¤�B¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php ��Ê´®_ ��yY+¦¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpæ��Ê´®_æ��U`Ƥ������0���src/Composer/Package/Archiver/ArchiveManager.phpf��Ê´®_f��‹ ½"¤������3���src/Composer/Package/Archiver/ArchiverInterface.php��Ê´®_��ñ´> ¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php—��Ê´®_—��FmÌZ¤������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php��Ê´®_��‹SZ0¤������2���src/Composer/Package/Archiver/GitExcludeFilter.phpr��Ê´®_r��3‘Mh¤������1���src/Composer/Package/Archiver/HgExcludeFilter.php ��Ê´®_ �� •¦S¤������.���src/Composer/Package/Archiver/PharArchiver.php?��Ê´®_?��®— u¤������-���src/Composer/Package/Archiver/ZipArchiver.php¤��Ê´®_¤��!Yò�¤������$���src/Composer/Package/BasePackage.php��Ê´®_��Þ)’ˤ������*���src/Composer/Package/Comparer/Comparer.php©��Ê´®_©��þí%†¤������(���src/Composer/Package/CompletePackage.php§��Ê´®_§�� h“¤������1���src/Composer/Package/CompletePackageInterface.php��Ê´®_��2%ž¤������+���src/Composer/Package/Dumper/ArrayDumper.php ��Ê´®_ ��Ã@Q¤���������src/Composer/Package/Link.phpÝ��Ê´®_Ý��ÃðÿФ������+���src/Composer/Package/Loader/ArrayLoader.phpã&��Ê´®_ã&��ª>l¤������7���src/Composer/Package/Loader/InvalidPackageException.phpE��Ê´®_E��xb¾¤������*���src/Composer/Package/Loader/JsonLoader.php°��Ê´®_°��Vœ\‹¤������/���src/Composer/Package/Loader/LoaderInterface.php²���Ê´®_²���¦}úΤ������1���src/Composer/Package/Loader/RootPackageLoader.php•��Ê´®_•��ÀUŽ|¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.php«A��Ê´®_«A��çë‹á¤���������src/Composer/Package/Locker.phpW%��Ê´®_W%��ܾ“}¤������ ���src/Composer/Package/Package.php��Ê´®_��¯°æg¤������)���src/Composer/Package/PackageInterface.php� ��Ê´®_� ��H^K_¤������)���src/Composer/Package/RootAliasPackage.phpH ��Ê´®_H ��ëie`¤������$���src/Composer/Package/RootPackage.phpI��Ê´®_I��q]V¤������-���src/Composer/Package/RootPackageInterface.php¹��Ê´®_¹��"maV¤������0���src/Composer/Package/Version/StabilityFilter.phpë��Ê´®_ë���H ¤������/���src/Composer/Package/Version/VersionGuesser.phpº$��Ê´®_º$��ÐDJT¤������.���src/Composer/Package/Version/VersionParser.phpý��Ê´®_ý��4º�Τ������0���src/Composer/Package/Version/VersionSelector.phpÿ��Ê´®_ÿ��G/”²¤������&���src/Composer/Platform/HhvmDetector.phpð��Ê´®_ð��Ë›ª¤������!���src/Composer/Platform/Runtime.php@��Ê´®_@��ª™ˆ`¤������!���src/Composer/Platform/Version.php’��Ê´®_’��wLão¤������-���src/Composer/Plugin/Capability/Capability.phpW���Ê´®_W���æ_¨1¤������2���src/Composer/Plugin/Capability/CommandProvider.php—���Ê´®_—���ûOâ>¤���������src/Composer/Plugin/Capable.php���Ê´®_���Æq+¤������$���src/Composer/Plugin/CommandEvent.phpâ��Ê´®_â��³ÆÇW¤������$���src/Composer/Plugin/PluginEvents.phpe��Ê´®_e��*U~r¤������'���src/Composer/Plugin/PluginInterface.phpŽ��Ê´®_Ž���4%~¤������%���src/Composer/Plugin/PluginManager.php.��Ê´®_.��Þ}¤������-���src/Composer/Plugin/PostFileDownloadEvent.phpä��Ê´®_ä��À¤}ý¤������*���src/Composer/Plugin/PreCommandRunEvent.phpõ��Ê´®_õ��:ðd¤������,���src/Composer/Plugin/PreFileDownloadEvent.phpO��Ê´®_O��¾­wÀ¤������*���src/Composer/Plugin/PrePoolCreateEvent.phpu��Ê´®_u��6sS„¤������4���src/Composer/Question/StrictConfirmationQuestion.php��Ê´®_��'.³è¤������+���src/Composer/Repository/ArrayRepository.phpì��Ê´®_ì��Œ†ó6¤������.���src/Composer/Repository/ArtifactRepository.phpô ��Ê´®_ô ��›©Ñn¤������.���src/Composer/Repository/ComposerRepository.php¨‡��Ê´®_¨‡��œ¿{¤������/���src/Composer/Repository/CompositeRepository.phpO ��Ê´®_O ��·P¯¤������;���src/Composer/Repository/ConfigurableRepositoryInterface.php…���Ê´®_…���±Ÿ_¤������0���src/Composer/Repository/FilesystemRepository.phpö��Ê´®_ö��>šGg¤������,���src/Composer/Repository/FilterRepository.php��Ê´®_��×y¯¢¤������4���src/Composer/Repository/InstalledArrayRepository.php3��Ê´®_3��…¥)n¤������9���src/Composer/Repository/InstalledFilesystemRepository.php1��Ê´®_1��y&êͤ������/���src/Composer/Repository/InstalledRepository.phpî��Ê´®_î��™5| ¤������8���src/Composer/Repository/InstalledRepositoryInterface.php¥���Ê´®_¥���Ã%¤������6���src/Composer/Repository/InvalidRepositoryException.phpn���Ê´®_n���à“똤������/���src/Composer/Repository/LockArrayRepository.php¥���Ê´®_¥���524¤������-���src/Composer/Repository/PackageRepository.phpÒ��Ê´®_Ò��åÒd¤������*���src/Composer/Repository/PathRepository.php%��Ê´®_%��õœjš¤������*���src/Composer/Repository/PearRepository.phpQ��Ê´®_Q��cø¤������.���src/Composer/Repository/PlatformRepository.php¡H��Ê´®_¡H���¨Iÿ¤������-���src/Composer/Repository/RepositoryFactory.php¦��Ê´®_¦��Ÿ�&<¤������/���src/Composer/Repository/RepositoryInterface.php;��Ê´®_;�� _‹¤������-���src/Composer/Repository/RepositoryManager.php ��Ê´®_ ��´=x¤������7���src/Composer/Repository/RepositorySecurityException.phpo���Ê´®_o���pÕ«ª¤������)���src/Composer/Repository/RepositorySet.phpÏ��Ê´®_Ï��^ì È¤������1���src/Composer/Repository/RootPackageRepository.php@��Ê´®_@��X¦Ž¤������/���src/Composer/Repository/Vcs/BitbucketDriver.phpŠ ��Ê´®_Š ��Ä›ÊV¤������,���src/Composer/Repository/Vcs/FossilDriver.phpl��Ê´®_l��wàù ¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpé��Ê´®_é��jºãe¤������)���src/Composer/Repository/Vcs/GitDriver.phpô��Ê´®_ô��íI�`¤������,���src/Composer/Repository/Vcs/GitHubDriver.phpü4��Ê´®_ü4��¸Ðtå¤������,���src/Composer/Repository/Vcs/GitLabDriver.php+��Ê´®_+��´P•z¤������1���src/Composer/Repository/Vcs/HgBitbucketDriver.phpã��Ê´®_ã��¬}ñ¤������(���src/Composer/Repository/Vcs/HgDriver.php��Ê´®_��_8¬­¤������.���src/Composer/Repository/Vcs/PerforceDriver.php¾ ��Ê´®_¾ ��ˆáÀ¤������)���src/Composer/Repository/Vcs/SvnDriver.php›��Ê´®_›��†
  32. \�����)���src/Composer/Repository/Vcs/VcsDriver.phpz
  33. ��Ê´®_z
  34. ��}ãh¤������2���src/Composer/Repository/Vcs/VcsDriverInterface.php÷��Ê´®_÷��ÇX[‰¤������)���src/Composer/Repository/VcsRepository.php`2��Ê´®_`2��twˆJ¤������1���src/Composer/Repository/VersionCacheInterface.php”���Ê´®_”���A?Rï¤������3���src/Composer/Repository/WritableArrayRepository.phpQ��Ê´®_Q���š�M¤������7���src/Composer/Repository/WritableRepositoryInterface.phpS��Ê´®_S��5CgÓ¤���������src/Composer/Script/Event.phpš��Ê´®_š��Óô©¤������$���src/Composer/Script/ScriptEvents.phpÜ��Ê´®_Ü��ÆíÁ¤������ ���src/Composer/SelfUpdate/Keys.php���Ê´®_��� îÊN¤������$���src/Composer/SelfUpdate/Versions.phpR��Ê´®_R��Ï×8�¤������ ���src/Composer/Util/AuthHelper.php(��Ê´®_(�� rG¤���������src/Composer/Util/Bitbucket.phpÜ��Ê´®_Ü��¨0Á›¤������$���src/Composer/Util/ComposerMirror.php±��Ê´®_±��­½øØ¤������%���src/Composer/Util/ConfigValidator.php:��Ê´®_:��«hñޤ������"���src/Composer/Util/ErrorHandler.php»��Ê´®_»��O›rk¤������ ���src/Composer/Util/Filesystem.phpu3��Ê´®_u3��ҥȤ���������src/Composer/Util/Git.phpÁ0��Ê´®_Á0��W¶ÂK¤���������src/Composer/Util/GitHub.phpW ��Ê´®_W ��–¹H¤���������src/Composer/Util/GitLab.php’��Ê´®_’��vu˜¼¤���������src/Composer/Util/Hg.php¶��Ê´®_¶��²?ܤ������)���src/Composer/Util/Http/CurlDownloader.phpê;��Ê´®_ê;��Ï™…f¤������&���src/Composer/Util/Http/ProxyHelper.php>
  35. ��Ê´®_>
  36. ��LÂ
  37. ú¤������'���src/Composer/Util/Http/ProxyManager.phpU
  38. ��Ê´®_U
  39. ��bP‘¤������'���src/Composer/Util/Http/RequestProxy.php��Ê´®_��üA8¤������#���src/Composer/Util/Http/Response.php#��Ê´®_#��Ûûß$¤������$���src/Composer/Util/HttpDownloader.php—$��Ê´®_—$��\ú]̤���������src/Composer/Util/IniHelper.phph��Ê´®_h��;FP¤���������src/Composer/Util/Loop.php-��Ê´®_-��íÚQ3¤������&���src/Composer/Util/MetadataMinifier.php¼��Ê´®_¼��$Ž.w¤������$���src/Composer/Util/NoProxyPattern.php|��Ê´®_|��¸|ää¤������#���src/Composer/Util/PackageSorter.phpð��Ê´®_ð��9hÑ­¤���������src/Composer/Util/Perforce.php^2��Ê´®_^2��=´MÔ¤���������src/Composer/Util/Platform.phpr��Ê´®_r��˜x/ô¤������%���src/Composer/Util/ProcessExecutor.phpU��Ê´®_U��õËù¤������&���src/Composer/Util/RemoteFilesystem.php¶M��Ê´®_¶M���8ºQ¤���������src/Composer/Util/Silencer.phpé��Ê´®_é��“Vjf¤������*���src/Composer/Util/StreamContextFactory.php¬��Ê´®_¬��lÔÙa¤���������src/Composer/Util/Svn.php)��Ê´®_)��¬íGj¤������ ���src/Composer/Util/SyncHelper.php;��Ê´®_;��Ž(¸¤���������src/Composer/Util/Tar.phpb��Ê´®_b��å]–¤���������src/Composer/Util/TlsHelper.phpL
  40. ��Ê´®_L
  41. ��" i¤���������src/Composer/Util/Url.phpö ��Ê´®_ö ��'úÁ…¤���������src/Composer/Util/Zip.php*��Ê´®_*��*Ø%Ǥ���������src/bootstrap.php¹��Ê´®_¹��I}œ¤������%���src/Composer/Autoload/ClassLoader.php£4��Ê´®_£4��?ÁT¨¤������#���res/composer-repository-schema.jsonñ��Ê´®_ñ��|0à„¤���������res/composer-schema.jsonÿª��Ê´®_ÿª��Ûp…¤���������vendor/autoload.php‚���Ê´®_‚���Þ�W ¤���������vendor/composer/ClassLoader.php¶��Ê´®_¶��ôJ1¤������%���vendor/composer/InstalledVersions.php–��Ê´®_–��£š-¤������%���vendor/composer/autoload_classmap.phpµ���Ê´®_µ���x’ý»¤������"���vendor/composer/autoload_files.phpŒ��Ê´®_Œ��� ¤������'���vendor/composer/autoload_namespaces.php¢���Ê´®_¢����R7c¤������!���vendor/composer/autoload_psr4.php÷��Ê´®_÷��Å*š¤������!���vendor/composer/autoload_real.phpG��Ê´®_G��‰C"±¤������#���vendor/composer/autoload_static.php¹ ��Ê´®_¹ ��íçQ¤������!���vendor/composer/ca-bundle/LICENSE��Ê´®_��G _¤������(���vendor/composer/ca-bundle/res/cacert.pemÜc�Ê´®_Üc�9ç‹ù¤������*���vendor/composer/ca-bundle/src/CaBundle.phpR��Ê´®_R��!Ã%�¤���������vendor/composer/installed.phpu ��Ê´®_u ��èÞ»¤���������vendor/composer/semver/LICENSE��Ê´®_��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��Ê´®_��^ÝŠ’¤������/���vendor/composer/semver/src/CompilingMatcher.phpo��Ê´®_o��Æ7L§¤������/���vendor/composer/semver/src/Constraint/Bound.phpt��Ê´®_t��ùÛœ¤������4���vendor/composer/semver/src/Constraint/Constraint.phpj��Ê´®_j��7k)¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php˜��Ê´®_˜��œ?[¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php§��Ê´®_§��ÃÛé¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÁ��Ê´®_Á��ê´ �¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.php��Ê´®_��•ª¡¤������'���vendor/composer/semver/src/Interval.phpè��Ê´®_è�� È�Û¤������(���vendor/composer/semver/src/Intervals.phpù+��Ê´®_ù+��Íòc»¤������%���vendor/composer/semver/src/Semver.phpü��Ê´®_ü��`°e¤������,���vendor/composer/semver/src/VersionParser.phpÊ+��Ê´®_Ê+��7m¤������%���vendor/composer/spdx-licenses/LICENSE��Ê´®_��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��Ê´®_¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.jsoná£��Ê´®_á£��Ú¼Ó¤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.phpH��Ê´®_H��͉T¤������&���vendor/composer/xdebug-handler/LICENSE+��Ê´®_+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php´��Ê´®_´��*D’�¤������.���vendor/composer/xdebug-handler/src/Process.phpp ��Ê´®_p ��i,i‘¤������-���vendor/composer/xdebug-handler/src/Status.php
  42. ��Ê´®_
  43. ��$Ÿv-¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.phpº$��Ê´®_º$��{Ä”¤������(���vendor/justinrainbow/json-schema/LICENSE"��Ê´®_"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��Ê´®_¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php�
  44. ��Ê´®_�
  45. ��ÍèÓ¯¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php§ ��Ê´®_§ ��›Vؤ������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��Ê´®_¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php]��Ê´®_]��VŽU<¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpã ��Ê´®_ã ��á0;¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.php…��Ê´®_…��“TœÚ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.php‡ ��Ê´®_‡ ��ï›(¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.phpÃ��Ê´®_Ã��©Å¼x¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php0 ��Ê´®_0 ��×j´˜¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.php��Ê´®_��¥wš‡¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��Ê´®_a�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��Ê´®_—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��Ê´®_‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php&��Ê´®_&��4˜©T¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.phpS"��Ê´®_S"��¼¾õ:¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��Ê´®_è��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���Ê´®_I���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���Ê´®_•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���Ê´®_l���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���Ê´®_l���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���Ê´®_u���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���Ê´®_w���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��Ê´®_Þ��\¸
  46. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���Ê´®_o���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���Ê´®_…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���Ê´®_€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���Ê´®_j���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���Ê´®_f���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��Ê´®_þ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��Ê´®_ ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.phpœ ��Ê´®_œ ��åfO¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��Ê´®_��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���Ê´®_á���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php¥��Ê´®_¥��Ô§Lb¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php%��Ê´®_%��5" ¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��Ê´®_,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���Ê´®_®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��Ê´®_ ��£Ÿ)à¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.phpF��Ê´®_F��¨IaD¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���Ê´®_ƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���Ê´®_…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phpv��Ê´®_v��õÍg¤���������vendor/psr/log/LICENSE?��Ê´®_?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��Ê´®_;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���Ê´®_`��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���Ê´®_û���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���Ê´®_|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���Ê´®_§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��Ê´®_È��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��Ê´®_k��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.php ���Ê´®_ ���ÆDi¯¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���Ê´®_p���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��Ê´®_ ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��Ê´®_<��þ(åI¤���������vendor/react/promise/LICENSE'��Ê´®_'��¶-º„¤������F���vendor/react/promise/src/React/Promise/CancellablePromiseInterface.php����Ê´®_���� ƒ<�¤������3���vendor/react/promise/src/React/Promise/Deferred.phpð ��Ê´®_ð ��o(ퟤ������:���vendor/react/promise/src/React/Promise/DeferredPromise.phpÇ��Ê´®_Ç��º`W¤������;���vendor/react/promise/src/React/Promise/DeferredResolver.phpÃ��Ê´®_Ã��7Ëu¤������;���vendor/react/promise/src/React/Promise/FulfilledPromise.phpÍ��Ê´®_Í��´–U¤������6���vendor/react/promise/src/React/Promise/LazyPromise.php��Ê´®_��Š»¤������2���vendor/react/promise/src/React/Promise/Promise.php��Ê´®_��º6Jµ¤������;���vendor/react/promise/src/React/Promise/PromiseInterface.phpŸ���Ê´®_Ÿ��� ½¨n¤������<���vendor/react/promise/src/React/Promise/PromisorInterface.php\���Ê´®_\���Wèêà¤������:���vendor/react/promise/src/React/Promise/RejectedPromise.php¾��Ê´®_¾��fC¿¤������<���vendor/react/promise/src/React/Promise/ResolverInterface.php¼���Ê´®_¼���û �O¤������/���vendor/react/promise/src/React/Promise/Util.phpè���Ê´®_è���Ëý$:¤������/���vendor/react/promise/src/React/Promise/When.phpÇ��Ê´®_Ç��¤o¤������4���vendor/react/promise/src/React/Promise/functions.phpÒ ��Ê´®_Ò ��š§Ë¥¤������<���vendor/react/promise/src/React/Promise/functions_include.php\���Ê´®_\���1…‰^¤���������vendor/seld/jsonlint/LICENSE$��Ê´®_$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.phpk��Ê´®_k��Zù¶Ã¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.phpU2��Ê´®_U2��ús.Ƥ������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php#��Ê´®_#��Úá@,¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php%��Ê´®_%��`a„|¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���Ê´®_>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��Ê´®_$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpÏ��Ê´®_Ï��_Aª¤������)���vendor/seld/phar-utils/src/Timestamps.php­ ��Ê´®_­ ��È?$ޤ������&���vendor/symfony/console/Application.php=X��Ê´®_=X��� S’¤������*���vendor/symfony/console/Command/Command.phpî"��Ê´®_î"��x°jÕ¤������.���vendor/symfony/console/Command/HelpCommand.phpØ��Ê´®_Ø��¦Ú-:¤������.���vendor/symfony/console/Command/ListCommand.phpZ��Ê´®_Z��»w`¤������(���vendor/symfony/console/ConsoleEvents.phpé���Ê´®_é���RÛÔe¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÐ��Ê´®_Ð��™Ž5°¤������0���vendor/symfony/console/Descriptor/Descriptor.php���Ê´®_���¿N•¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü���Ê´®_ü���±Qµ¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ��Ê´®_Ü ��*û�ɤ������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶��Ê´®_¶��·Ô;ݤ������4���vendor/symfony/console/Descriptor/TextDescriptor.php¼��Ê´®_¼��òç$¤������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��Ê´®_��b{<¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°��Ê´®_°��!�Ȥ������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ��Ê´®_Å��ÒxÛ\¤������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php��Ê´®_��á2é¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz��Ê´®_z��³,îL¤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ��Ê´®_Ô��È÷ L¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpf���Ê´®_f���¡ABª¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���Ê´®_¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���Ê´®_¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���Ê´®_’���ÍO\e¤������5���vendor/symfony/console/Exception/RuntimeException.php–���Ê´®_–���Ùí,6¤������4���vendor/symfony/console/Formatter/OutputFormatter.php6��Ê´®_6��?=¨¤������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ��Ê´®_Œ��òññÀ¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF��Ê´®_F��𦴤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„��Ê´®_„��÷½G¤������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@��Ê´®_@��G¨ýU¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy��Ê´®_y��Ì8ÆÐ¤������2���vendor/symfony/console/Helper/DescriptorHelper.phpw��Ê´®_w��|¦C¤������.���vendor/symfony/console/Helper/DialogHelper.php��Ê´®_��¹ÜÃ_¤������1���vendor/symfony/console/Helper/FormatterHelper.phpd��Ê´®_d��§×,¸¤������(���vendor/symfony/console/Helper/Helper.php«��Ê´®_«��!�§—¤������1���vendor/symfony/console/Helper/HelperInterface.phpå���Ê´®_å���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpÊ��Ê´®_Ê��áÏW"¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��Ê´®_c��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ��Ê´®_Ó ��©w‚R¤������-���vendor/symfony/console/Helper/ProgressBar.phpl%��Ê´®_l%�� díÛ¤������0���vendor/symfony/console/Helper/ProgressHelper.php]��Ê´®_]��ù»‰X¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpN��Ê´®_N��ÿ§³l¤������0���vendor/symfony/console/Helper/QuestionHelper.phpl��Ê´®_l��Ntó¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php–
  47. ��Ê´®_–
  48. ��- ؤ������'���vendor/symfony/console/Helper/Table.phpÄ*��Ê´®_Ä*��¾™ØT¤������+���vendor/symfony/console/Helper/TableCell.php���Ê´®_���åV^¤������-���vendor/symfony/console/Helper/TableHelper.php ��Ê´®_ ��›uô™¤������0���vendor/symfony/console/Helper/TableSeparator.phpÊ���Ê´®_Ê���az¤������,���vendor/symfony/console/Helper/TableStyle.php
  49. ��Ê´®_
  50. ��_ÍI"¤������*���vendor/symfony/console/Input/ArgvInput.php��Ê´®_��×ö†›¤������+���vendor/symfony/console/Input/ArrayInput.php) ��Ê´®_) ��¥ÑC¤������&���vendor/symfony/console/Input/Input.php£ ��Ê´®_£ ��f¡?¤������.���vendor/symfony/console/Input/InputArgument.php��Ê´®_��D £¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���Ê´®_˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php†��Ê´®_†��¤U)¤¤������/���vendor/symfony/console/Input/InputInterface.php£��Ê´®_£��ÆBŒ'¤������,���vendor/symfony/console/Input/InputOption.php ��Ê´®_ ��\¢Ü=¤������,���vendor/symfony/console/Input/StringInput.phpš��Ê´®_š��žµ è¤���������vendor/symfony/console/LICENSE+��Ê´®_+��²‹ g¤������/���vendor/symfony/console/Logger/ConsoleLogger.php0 ��Ê´®_0 ��…� ¸¤������0���vendor/symfony/console/Output/BufferedOutput.php_��Ê´®__��‹ >P¤������/���vendor/symfony/console/Output/ConsoleOutput.php±��Ê´®_±��nì!f¤������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà���Ê´®_à���‡†ÆÊ¤������,���vendor/symfony/console/Output/NullOutput.phpÏ��Ê´®_Ï��®˜‹Z¤������(���vendor/symfony/console/Output/Output.php˜ ��Ê´®_˜ ��0p¤������1���vendor/symfony/console/Output/OutputInterface.php��Ê´®_���ì&¤������.���vendor/symfony/console/Output/StreamOutput.php���Ê´®_���Ä’Oç¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpx
  51. ��Ê´®_x
  52. ��W€!¤������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè��Ê´®_è��/Ô�¤������,���vendor/symfony/console/Question/Question.phpÎ ��Ê´®_Î ��lF¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��Ê´®_�$��•�¥v¤������ ���vendor/symfony/console/Shell.phpæ��Ê´®_æ��¼XÒA¤������,���vendor/symfony/console/Style/OutputStyle.php\��Ê´®_\��wפ¤������/���vendor/symfony/console/Style/StyleInterface.phpÏ��Ê´®_Ï��&nÅѤ������-���vendor/symfony/console/Style/SymfonyStyle.phpä��Ê´®_ä��­å (¤������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ��Ê´®_Ï��sž9i¤������/���vendor/symfony/console/Tester/CommandTester.phpª��Ê´®_ª��¬K z¤������(���vendor/symfony/debug/BufferingLogger.phpt��Ê´®_t��=�hܤ���������vendor/symfony/debug/Debug.php,��Ê´®_,��Ë~Ž.¤������)���vendor/symfony/debug/DebugClassLoader.phpµ��Ê´®_µ��1rEÓ¤������%���vendor/symfony/debug/ErrorHandler.phpH��Ê´®_H��¹:D#¤������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–��Ê´®_–��i‰æô¤������8���vendor/symfony/debug/Exception/ContextErrorException.php˜��Ê´®_˜��-
  53. d2¤������1���vendor/symfony/debug/Exception/DummyException.php��Ê´®_��®+Ãê¤������6���vendor/symfony/debug/Exception/FatalErrorException.php��Ê´®_��™Ä¤������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW��Ê´®_W��?àèK¤������3���vendor/symfony/debug/Exception/FlattenException.php¼��Ê´®_¼�� פ������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~���Ê´®_~���ë¨oâ¤������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš��Ê´®_š���ñJÀ¤������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜��Ê´®_˜��nöêØ¤������)���vendor/symfony/debug/ExceptionHandler.php)3��Ê´®_)3���h5=¤������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.phpA��Ê´®_A��Ϥ¹l¤������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php��Ê´®_��ĹBV¤������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx��Ê´®_x��~ò"¤������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpO��Ê´®_O���ž¦*¤���������vendor/symfony/debug/LICENSE+��Ê´®_+��²‹ g¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi���Ê´®_i���$ ÿ›¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼��Ê´®_¼��pí\¶¤������3���vendor/symfony/filesystem/Exception/IOException.php‡��Ê´®_‡��€ü#Ѥ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���Ê´®_¦���jÙwM¤������(���vendor/symfony/filesystem/Filesystem.phpc4��Ê´®_c4��‹×@þ¤������!���vendor/symfony/filesystem/LICENSE+��Ê´®_+��²‹ g¤������)���vendor/symfony/filesystem/LockHandler.phpö��Ê´®_ö��ŸZµ1¤������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ��Ê´®_\ ��hˆB¤������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.php���Ê´®_���HC€/¤������2���vendor/symfony/finder/Adapter/AdapterInterface.php›��Ê´®_›��Mþ¤������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php3��Ê´®_3��75$·¤������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php��Ê´®_��Ÿ`]¤������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô��Ê´®_ô��Þdè;¤������/���vendor/symfony/finder/Comparator/Comparator.php���Ê´®_���¾üœµ¤������3���vendor/symfony/finder/Comparator/DateComparator.php#��Ê´®_#��°Τ������5���vendor/symfony/finder/Comparator/NumberComparator.php|��Ê´®_|��ITÇͤ������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���Ê´®_„���½¾sœ¤������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬��Ê´®_¬��wR¤������6���vendor/symfony/finder/Exception/ExceptionInterface.php„���Ê´®_„���Gz-¤������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)��Ê´®_)��x§e¤������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº��Ê´®_º��˜þ˜¤������/���vendor/symfony/finder/Expression/Expression.php��Ê´®_��i¥:Ť������)���vendor/symfony/finder/Expression/Glob.phpf��Ê´®_f��DÞcj¤������*���vendor/symfony/finder/Expression/Regex.php��Ê´®_��ü(ÃϤ������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ��Ê´®_Í��\p4†¤������ ���vendor/symfony/finder/Finder.phpc.��Ê´®_c.��:ˆ5g¤���������vendor/symfony/finder/Glob.phpL��Ê´®_L��jÍ9פ������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]��Ê´®_]��ÎoÅÆ¤������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx��Ê´®_x��ôP¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî��Ê´®_î��üÍ�q¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí��Ê´®_í��nõH¤������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#��Ê´®_#��G?T½¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ��Ê´®_Z��(&ø¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5��Ê´®_5��ší¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr��Ê´®_r��tu¤������1���vendor/symfony/finder/Iterator/FilterIterator.phpÃ��Ê´®_Ã��š+µÞ¤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php-��Ê´®_-��ºÎÒ_¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ��Ê´®_Ð��‚c¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ��Ê´®_ ��ë]í»¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe��Ê´®_e��Ÿ’áé¤������3���vendor/symfony/finder/Iterator/SortableIterator.php+��Ê´®_+��õÝË ¤���������vendor/symfony/finder/LICENSE+��Ê´®_+��²‹ g¤������'���vendor/symfony/finder/Shell/Command.php> ��Ê´®_> ��_~u ¤������%���vendor/symfony/finder/Shell/Shell.phpr��Ê´®_r��þpN¤������%���vendor/symfony/finder/SplFileInfo.php��Ê´®_��þ�íù¤������'���vendor/symfony/polyfill-ctype/Ctype.phpH ��Ê´®_H ��³�Õݤ������%���vendor/symfony/polyfill-ctype/LICENSE+��Ê´®_+��…»E:¤������+���vendor/symfony/polyfill-ctype/bootstrap.phpú��Ê´®_ú��|p:¤������(���vendor/symfony/polyfill-mbstring/LICENSE+��Ê´®_+��øÛ{¤������-���vendor/symfony/polyfill-mbstring/Mbstring.php‚G��Ê´®_‚G��ֽ̤������D���vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8Ë��Ê´®_Ë��Ú�.‚¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷T��Ê´®_÷T��ß2ª?¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��Ê´®_ã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpîU��Ê´®_îU��`þ8Q¤������.���vendor/symfony/polyfill-mbstring/bootstrap.php��Ê´®_��þJ¾¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpf���Ê´®_f���]ö>T¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���Ê´®_¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���Ê´®_”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��Ê´®_x��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php��Ê´®_��﫤������5���vendor/symfony/process/Exception/RuntimeException.php˜���Ê´®_˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.php���Ê´®_���ûus€¤���������vendor/symfony/process/LICENSE+��Ê´®_+��²‹ g¤������.���vendor/symfony/process/PhpExecutableFinder.phpÏ��Ê´®_Ï��Î%h¤������%���vendor/symfony/process/PhpProcess.phpü��Ê´®_ü��‡jûü¤������.���vendor/symfony/process/Pipes/AbstractPipes.php½��Ê´®_½��憤������/���vendor/symfony/process/Pipes/PipesInterface.phpD��Ê´®_D��vØî¡¤������*���vendor/symfony/process/Pipes/UnixPipes.php>��Ê´®_>��ª•ir¤������-���vendor/symfony/process/Pipes/WindowsPipes.phpp ��Ê´®_p ��âU~ɤ������"���vendor/symfony/process/Process.php·R��Ê´®_·R��Š`Õ¤������)���vendor/symfony/process/ProcessBuilder.phpâ
  54. ��Ê´®_â
  55. ��†M¶¤������'���vendor/symfony/process/ProcessUtils.phpQ��Ê´®_Q��b-$m¤������ ���bin/composer6��Ê´®_6�� 9Øï¤���������LICENSE.��Ê´®_.�� Õ¤������<?php
  56. namespace Composer\Autoload;
  57. use Composer\Config;
  58. use Composer\EventDispatcher\EventDispatcher;
  59. use Composer\Installer\InstallationManager;
  60. use Composer\IO\IOInterface;
  61. use Composer\Package\AliasPackage;
  62. use Composer\Package\PackageInterface;
  63. use Composer\Package\RootPackageInterface;
  64. use Composer\Repository\InstalledRepositoryInterface;
  65. use Composer\Repository\PlatformRepository;
  66. use Composer\Semver\Constraint\Bound;
  67. use Composer\Semver\Constraint\MatchAllConstraint;
  68. use Composer\Util\Filesystem;
  69. use Composer\Script\ScriptEvents;
  70. use Composer\Util\PackageSorter;
  71. class AutoloadGenerator
  72. {
  73. private $eventDispatcher;
  74. private $io;
  75. private $devMode = false;
  76. private $classMapAuthoritative = false;
  77. private $apcu = false;
  78. private $apcuPrefix;
  79. private $runScripts = false;
  80. private $ignorePlatformReqs = false;
  81. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  82. {
  83. $this->eventDispatcher = $eventDispatcher;
  84. $this->io = $io;
  85. }
  86. public function setDevMode($devMode = true)
  87. {
  88. $this->devMode = (bool) $devMode;
  89. }
  90. public function setClassMapAuthoritative($classMapAuthoritative)
  91. {
  92. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  93. }
  94. public function setApcu($apcu, $apcuPrefix = null)
  95. {
  96. $this->apcu = (bool) $apcu;
  97. $this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
  98. }
  99. public function setRunScripts($runScripts = true)
  100. {
  101. $this->runScripts = (bool) $runScripts;
  102. }
  103. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  104. {
  105. if (is_array($ignorePlatformReqs)) {
  106. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  107. return PlatformRepository::isPlatformPackage($req);
  108. });
  109. } else {
  110. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  111. }
  112. }
  113. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
  114. {
  115. if ($this->classMapAuthoritative) {
  116. $scanPsrPackages = true;
  117. }
  118. if ($this->runScripts) {
  119. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  120. 'optimize' => (bool) $scanPsrPackages,
  121. ));
  122. }
  123. $filesystem = new Filesystem();
  124. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  125. $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
  126. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  127. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  128. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  129. $targetDir = $vendorPath.'/'.$targetDir;
  130. $filesystem->ensureDirectoryExists($targetDir);
  131. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  132. $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
  133. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  134. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  135. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  136. $namespacesFile = <<<EOF
  137. <?php
  138. // autoload_namespaces.php @generated by Composer
  139. \$vendorDir = $vendorPathCode52;
  140. \$baseDir = $appBaseDirCode;
  141. return array(
  142. EOF;
  143. $psr4File = <<<EOF
  144. <?php
  145. // autoload_psr4.php @generated by Composer
  146. \$vendorDir = $vendorPathCode52;
  147. \$baseDir = $appBaseDirCode;
  148. return array(
  149. EOF;
  150. $devPackageNames = $localRepo->getDevPackageNames();
  151. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  152. if ($this->devMode) {
  153. $filteredDevPackages = false;
  154. } else {
  155. $filteredDevPackages = $devPackageNames ?: true;
  156. }
  157. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  158. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  159. $exportedPaths = array();
  160. foreach ($paths as $path) {
  161. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  162. }
  163. $exportedPrefix = var_export($namespace, true);
  164. $namespacesFile .= " $exportedPrefix => ";
  165. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  166. }
  167. $namespacesFile .= ");\n";
  168. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  169. $exportedPaths = array();
  170. foreach ($paths as $path) {
  171. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  172. }
  173. $exportedPrefix = var_export($namespace, true);
  174. $psr4File .= " $exportedPrefix => ";
  175. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  176. }
  177. $psr4File .= ");\n";
  178. $classmapFile = <<<EOF
  179. <?php
  180. // autoload_classmap.php @generated by Composer
  181. \$vendorDir = $vendorPathCode52;
  182. \$baseDir = $appBaseDirCode;
  183. return array(
  184. EOF;
  185. $targetDirLoader = null;
  186. $mainAutoload = $rootPackage->getAutoload();
  187. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  188. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  189. $prefixes = implode(', ', array_map(function ($prefix) {
  190. return var_export($prefix, true);
  191. }, array_keys($mainAutoload['psr-0'])));
  192. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  193. $targetDirLoader = <<<EOF
  194. public static function autoload(\$class)
  195. {
  196. \$dir = $baseDirFromTargetDirCode . '/';
  197. \$prefixes = array($prefixes);
  198. foreach (\$prefixes as \$prefix) {
  199. if (0 !== strpos(\$class, \$prefix)) {
  200. continue;
  201. }
  202. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  203. if (!\$path = stream_resolve_include_path(\$path)) {
  204. return false;
  205. }
  206. require \$path;
  207. return true;
  208. }
  209. }
  210. EOF;
  211. }
  212. $excluded = null;
  213. if (!empty($autoloads['exclude-from-classmap'])) {
  214. $excluded = '{(' . implode('|', $autoloads['exclude-from-classmap']) . ')}';
  215. }
  216. $classMap = array();
  217. $ambiguousClasses = array();
  218. $scannedFiles = array();
  219. foreach ($autoloads['classmap'] as $dir) {
  220. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, null, null, $classMap, $ambiguousClasses, $scannedFiles);
  221. }
  222. if ($scanPsrPackages) {
  223. $namespacesToScan = array();
  224. foreach (array('psr-4', 'psr-0') as $psrType) {
  225. foreach ($autoloads[$psrType] as $namespace => $paths) {
  226. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  227. }
  228. }
  229. krsort($namespacesToScan);
  230. foreach ($namespacesToScan as $namespace => $groups) {
  231. foreach ($groups as $group) {
  232. foreach ($group['paths'] as $dir) {
  233. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  234. if (!is_dir($dir)) {
  235. continue;
  236. }
  237. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespace, $group['type'], $classMap, $ambiguousClasses, $scannedFiles);
  238. }
  239. }
  240. }
  241. }
  242. foreach ($ambiguousClasses as $className => $ambigiousPaths) {
  243. $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);
  244. $this->io->writeError(
  245. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  246. ' was found '. (count($ambigiousPaths) + 1) .'x: in "'.$cleanPath.'" and "'. implode('", "', $ambigiousPaths) .'", the first will be used.</warning>'
  247. );
  248. }
  249. $classMap['Composer\\InstalledVersions'] = "\$vendorDir . '/composer/InstalledVersions.php',\n";
  250. ksort($classMap);
  251. foreach ($classMap as $class => $code) {
  252. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  253. }
  254. $classmapFile .= ");\n";
  255. if (!$suffix) {
  256. if (!$config->get('autoloader-suffix') && is_readable($vendorPath.'/autoload.php')) {
  257. $content = file_get_contents($vendorPath.'/autoload.php');
  258. if (preg_match('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  259. $suffix = $match[1];
  260. }
  261. }
  262. if (!$suffix) {
  263. $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
  264. }
  265. }
  266. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  267. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  268. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  269. $includePathFilePath = $targetDir.'/include_paths.php';
  270. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  271. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  272. } elseif (file_exists($includePathFilePath)) {
  273. unlink($includePathFilePath);
  274. }
  275. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  276. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  277. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  278. } elseif (file_exists($includeFilesFilePath)) {
  279. unlink($includeFilesFilePath);
  280. }
  281. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
  282. $checkPlatform = $config->get('platform-check') && $this->ignorePlatformReqs !== true;
  283. $platformCheckContent = null;
  284. if ($checkPlatform) {
  285. $platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array(), $config->get('platform-check'), $devPackageNames);
  286. if (null === $platformCheckContent) {
  287. $checkPlatform = false;
  288. }
  289. }
  290. if ($checkPlatform) {
  291. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  292. } elseif (file_exists($targetDir.'/platform_check.php')) {
  293. unlink($targetDir.'/platform_check.php');
  294. }
  295. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  296. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
  297. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  298. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  299. if ($this->runScripts) {
  300. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  301. 'optimize' => (bool) $scanPsrPackages,
  302. ));
  303. }
  304. return count($classMap);
  305. }
  306. private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles)
  307. {
  308. foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
  309. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  310. if (!isset($classMap[$class])) {
  311. $classMap[$class] = $pathCode;
  312. } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  313. $ambiguousClasses[$class][] = $path;
  314. }
  315. }
  316. return $classMap;
  317. }
  318. private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles)
  319. {
  320. return ClassMapGenerator::createMap($dir, $excluded, $showAmbiguousWarning ? $this->io : null, $namespaceFilter, $autoloadType, $scannedFiles);
  321. }
  322. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  323. {
  324. $packageMap = array(array($rootPackage, ''));
  325. foreach ($packages as $package) {
  326. if ($package instanceof AliasPackage) {
  327. continue;
  328. }
  329. $this->validatePackage($package);
  330. $packageMap[] = array(
  331. $package,
  332. $installationManager->getInstallPath($package),
  333. );
  334. }
  335. return $packageMap;
  336. }
  337. protected function validatePackage(PackageInterface $package)
  338. {
  339. $autoload = $package->getAutoload();
  340. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  341. $name = $package->getName();
  342. $package->getTargetDir();
  343. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  344. }
  345. if (!empty($autoload['psr-4'])) {
  346. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  347. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  348. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  349. }
  350. }
  351. }
  352. }
  353. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  354. {
  355. $rootPackageMap = array_shift($packageMap);
  356. if (is_array($filteredDevPackages)) {
  357. $packageMap = array_filter($packageMap, function ($item) use ($filteredDevPackages) {
  358. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  359. });
  360. } elseif ($filteredDevPackages) {
  361. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  362. }
  363. $sortedPackageMap = $this->sortPackageMap($packageMap);
  364. $sortedPackageMap[] = $rootPackageMap;
  365. array_unshift($packageMap, $rootPackageMap);
  366. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $rootPackage);
  367. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $rootPackage);
  368. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $rootPackage);
  369. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  370. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  371. krsort($psr0);
  372. krsort($psr4);
  373. return array(
  374. 'psr-0' => $psr0,
  375. 'psr-4' => $psr4,
  376. 'classmap' => $classmap,
  377. 'files' => $files,
  378. 'exclude-from-classmap' => $exclude,
  379. );
  380. }
  381. public function createLoader(array $autoloads)
  382. {
  383. $loader = new ClassLoader();
  384. if (isset($autoloads['psr-0'])) {
  385. foreach ($autoloads['psr-0'] as $namespace => $path) {
  386. $loader->add($namespace, $path);
  387. }
  388. }
  389. if (isset($autoloads['psr-4'])) {
  390. foreach ($autoloads['psr-4'] as $namespace => $path) {
  391. $loader->addPsr4($namespace, $path);
  392. }
  393. }
  394. if (isset($autoloads['classmap'])) {
  395. $excluded = null;
  396. if (!empty($autoloads['exclude-from-classmap'])) {
  397. $excluded = '{(' . implode('|', $autoloads['exclude-from-classmap']) . ')}';
  398. }
  399. $scannedFiles = array();
  400. foreach ($autoloads['classmap'] as $dir) {
  401. try {
  402. $loader->addClassMap($this->generateClassMap($dir, $excluded, null, null, false, $scannedFiles));
  403. } catch (\RuntimeException $e) {
  404. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  405. }
  406. }
  407. }
  408. return $loader;
  409. }
  410. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  411. {
  412. $includePaths = array();
  413. foreach ($packageMap as $item) {
  414. list($package, $installPath) = $item;
  415. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  416. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  417. }
  418. foreach ($package->getIncludePaths() as $includePath) {
  419. $includePath = trim($includePath, '/');
  420. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  421. }
  422. }
  423. if (!$includePaths) {
  424. return;
  425. }
  426. $includePathsCode = '';
  427. foreach ($includePaths as $path) {
  428. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  429. }
  430. return <<<EOF
  431. <?php
  432. // include_paths.php @generated by Composer
  433. \$vendorDir = $vendorPathCode;
  434. \$baseDir = $appBaseDirCode;
  435. return array(
  436. $includePathsCode);
  437. EOF;
  438. }
  439. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  440. {
  441. $filesCode = '';
  442. foreach ($files as $fileIdentifier => $functionFile) {
  443. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  444. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  445. }
  446. if (!$filesCode) {
  447. return false;
  448. }
  449. return <<<EOF
  450. <?php
  451. // autoload_files.php @generated by Composer
  452. \$vendorDir = $vendorPathCode;
  453. \$baseDir = $appBaseDirCode;
  454. return array(
  455. $filesCode);
  456. EOF;
  457. }
  458. protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
  459. {
  460. if (!$filesystem->isAbsolutePath($path)) {
  461. $path = $basePath . '/' . $path;
  462. }
  463. $path = $filesystem->normalizePath($path);
  464. $baseDir = '';
  465. if (strpos($path.'/', $vendorPath.'/') === 0) {
  466. $path = substr($path, strlen($vendorPath));
  467. $baseDir = '$vendorDir';
  468. if ($path !== false) {
  469. $baseDir .= " . ";
  470. }
  471. } else {
  472. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  473. if (!$filesystem->isAbsolutePath($path)) {
  474. $baseDir = '$baseDir . ';
  475. $path = '/' . $path;
  476. }
  477. }
  478. if (strpos($path, '.phar') !== false) {
  479. $baseDir = "'phar://' . " . $baseDir;
  480. }
  481. return $baseDir . (($path !== false) ? var_export($path, true) : "");
  482. }
  483. protected function getPlatformCheck(array $packageMap, array $ignorePlatformReqs, $checkPlatform, array $devPackageNames)
  484. {
  485. $lowestPhpVersion = Bound::zero();
  486. $requiredExtensions = array();
  487. $extensionProviders = array();
  488. foreach ($packageMap as $item) {
  489. $package = $item[0];
  490. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  491. if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  492. $extensionProviders[$match[1]][] = $link->getConstraint() ?: new MatchAllConstraint();
  493. }
  494. }
  495. }
  496. foreach ($packageMap as $item) {
  497. $package = $item[0];
  498. if (in_array($package->getName(), $devPackageNames, true)) {
  499. continue;
  500. }
  501. foreach ($package->getRequires() as $link) {
  502. if (in_array($link->getTarget(), $ignorePlatformReqs, true)) {
  503. continue;
  504. }
  505. if ('php' === $link->getTarget() && ($constraint = $link->getConstraint())) {
  506. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  507. $lowestPhpVersion = $constraint->getLowerBound();
  508. }
  509. }
  510. if ($checkPlatform === true && preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  511. if (isset($extensionProviders[$match[1]])) {
  512. foreach ($extensionProviders[$match[1]] as $provided) {
  513. if (!$link->getConstraint() || $provided->matches($link->getConstraint())) {
  514. continue 2;
  515. }
  516. }
  517. }
  518. if ($match[1] === 'zend-opcache') {
  519. $match[1] = 'zend opcache';
  520. }
  521. $extension = var_export($match[1], true);
  522. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  523. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  524. } else {
  525. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  526. }
  527. }
  528. }
  529. }
  530. ksort($requiredExtensions);
  531. $formatToPhpVersionId = function (Bound $bound) {
  532. if ($bound->isZero()) {
  533. return 0;
  534. }
  535. if ($bound->isPositiveInfinity()) {
  536. return 99999;
  537. }
  538. $version = str_replace('-', '.', $bound->getVersion());
  539. $chunks = array_map('intval', explode('.', $version));
  540. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  541. };
  542. $formatToHumanReadable = function (Bound $bound) {
  543. if ($bound->isZero()) {
  544. return 0;
  545. }
  546. if ($bound->isPositiveInfinity()) {
  547. return 99999;
  548. }
  549. $version = str_replace('-', '.', $bound->getVersion());
  550. $chunks = explode('.', $version);
  551. $chunks = array_slice($chunks, 0, 3);
  552. return implode('.', $chunks);
  553. };
  554. $requiredPhp = '';
  555. $requiredPhpError = '';
  556. if (!$lowestPhpVersion->isZero()) {
  557. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  558. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  559. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  560. }
  561. if ($requiredPhp) {
  562. $requiredPhp = <<<PHP_CHECK
  563. if (!($requiredPhp)) {
  564. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  565. }
  566. PHP_CHECK;
  567. }
  568. $requiredExtensions = implode('', $requiredExtensions);
  569. if ('' !== $requiredExtensions) {
  570. $requiredExtensions = <<<EXT_CHECKS
  571. \$missingExtensions = array();
  572. $requiredExtensions
  573. if (\$missingExtensions) {
  574. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  575. }
  576. EXT_CHECKS;
  577. }
  578. if (!$requiredPhp && !$requiredExtensions) {
  579. return null;
  580. }
  581. return <<<PLATFORM_CHECK
  582. <?php
  583. // platform_check.php @generated by Composer
  584. \$issues = array();
  585. ${requiredPhp}${requiredExtensions}
  586. if (\$issues) {
  587. if (!headers_sent()) {
  588. header('HTTP/1.1 500 Internal Server Error');
  589. }
  590. if (!ini_get('display_errors')) {
  591. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  592. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  593. } elseif (!headers_sent()) {
  594. 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;
  595. }
  596. }
  597. trigger_error(
  598. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  599. E_USER_ERROR
  600. );
  601. }
  602. PLATFORM_CHECK;
  603. }
  604. protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
  605. {
  606. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  607. if ("'" === $lastChar || '"' === $lastChar) {
  608. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  609. } else {
  610. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  611. }
  612. return <<<AUTOLOAD
  613. <?php
  614. // autoload.php @generated by Composer
  615. require_once $vendorPathToTargetDirCode;
  616. return ComposerAutoloaderInit$suffix::getLoader();
  617. AUTOLOAD;
  618. }
  619. protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)
  620. {
  621. $file = <<<HEADER
  622. <?php
  623. // autoload_real.php @generated by Composer
  624. class ComposerAutoloaderInit$suffix
  625. {
  626. private static \$loader;
  627. public static function loadClassLoader(\$class)
  628. {
  629. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  630. require __DIR__ . '/ClassLoader.php';
  631. }
  632. }
  633. /**
  634. * @return \Composer\Autoload\ClassLoader
  635. */
  636. public static function getLoader()
  637. {
  638. if (null !== self::\$loader) {
  639. return self::\$loader;
  640. }
  641. HEADER;
  642. if ($checkPlatform) {
  643. $file .= <<<'PLATFORM_CHECK'
  644. require __DIR__ . '/platform_check.php';
  645. PLATFORM_CHECK;
  646. }
  647. $file .= <<<CLASSLOADER_INIT
  648. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  649. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
  650. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  651. CLASSLOADER_INIT;
  652. if ($useIncludePath) {
  653. $file .= <<<'INCLUDE_PATH'
  654. $includePaths = require __DIR__ . '/include_paths.php';
  655. $includePaths[] = get_include_path();
  656. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  657. INCLUDE_PATH;
  658. }
  659. $file .= <<<STATIC_INIT
  660. \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  661. if (\$useStaticLoader) {
  662. require __DIR__ . '/autoload_static.php';
  663. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  664. } else {
  665. STATIC_INIT;
  666. if (!$this->classMapAuthoritative) {
  667. $file .= <<<'PSR04'
  668. $map = require __DIR__ . '/autoload_namespaces.php';
  669. foreach ($map as $namespace => $path) {
  670. $loader->set($namespace, $path);
  671. }
  672. $map = require __DIR__ . '/autoload_psr4.php';
  673. foreach ($map as $namespace => $path) {
  674. $loader->setPsr4($namespace, $path);
  675. }
  676. PSR04;
  677. }
  678. if ($useClassMap) {
  679. $file .= <<<'CLASSMAP'
  680. $classMap = require __DIR__ . '/autoload_classmap.php';
  681. if ($classMap) {
  682. $loader->addClassMap($classMap);
  683. }
  684. CLASSMAP;
  685. }
  686. $file .= " }\n\n";
  687. if ($this->classMapAuthoritative) {
  688. $file .= <<<'CLASSMAPAUTHORITATIVE'
  689. $loader->setClassMapAuthoritative(true);
  690. CLASSMAPAUTHORITATIVE;
  691. }
  692. if ($this->apcu) {
  693. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  694. $file .= <<<APCU
  695. \$loader->setApcuPrefix($apcuPrefix);
  696. APCU;
  697. }
  698. if ($useGlobalIncludePath) {
  699. $file .= <<<'INCLUDEPATH'
  700. $loader->setUseIncludePath(true);
  701. INCLUDEPATH;
  702. }
  703. if ($targetDirLoader) {
  704. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  705. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  706. REGISTER_TARGET_DIR_AUTOLOAD;
  707. }
  708. $file .= <<<REGISTER_LOADER
  709. \$loader->register($prependAutoloader);
  710. REGISTER_LOADER;
  711. if ($useIncludeFiles) {
  712. $file .= <<<INCLUDE_FILES
  713. if (\$useStaticLoader) {
  714. \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
  715. } else {
  716. \$includeFiles = require __DIR__ . '/autoload_files.php';
  717. }
  718. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  719. composerRequire$suffix(\$fileIdentifier, \$file);
  720. }
  721. INCLUDE_FILES;
  722. }
  723. $file .= <<<METHOD_FOOTER
  724. return \$loader;
  725. }
  726. METHOD_FOOTER;
  727. $file .= $targetDirLoader;
  728. if ($useIncludeFiles) {
  729. return $file . <<<FOOTER
  730. }
  731. function composerRequire$suffix(\$fileIdentifier, \$file)
  732. {
  733. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  734. require \$file;
  735. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  736. }
  737. }
  738. FOOTER;
  739. }
  740. return $file . <<<FOOTER
  741. }
  742. FOOTER;
  743. }
  744. protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
  745. {
  746. $staticPhpVersion = 50600;
  747. $file = <<<HEADER
  748. <?php
  749. // autoload_static.php @generated by Composer
  750. namespace Composer\Autoload;
  751. class ComposerStaticInit$suffix
  752. {
  753. HEADER;
  754. $loader = new ClassLoader();
  755. $map = require $targetDir . '/autoload_namespaces.php';
  756. foreach ($map as $namespace => $path) {
  757. $loader->set($namespace, $path);
  758. }
  759. $map = require $targetDir . '/autoload_psr4.php';
  760. foreach ($map as $namespace => $path) {
  761. $loader->setPsr4($namespace, $path);
  762. }
  763. $classMap = require $targetDir . '/autoload_classmap.php';
  764. if ($classMap) {
  765. $loader->addClassMap($classMap);
  766. }
  767. $filesystem = new Filesystem();
  768. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  769. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  770. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  771. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  772. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  773. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  774. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  775. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  776. $initializer = '';
  777. $prefix = "\0Composer\Autoload\ClassLoader\0";
  778. $prefixLen = strlen($prefix);
  779. if (file_exists($targetDir . '/autoload_files.php')) {
  780. $maps = array('files' => require $targetDir . '/autoload_files.php');
  781. } else {
  782. $maps = array();
  783. }
  784. foreach ((array) $loader as $prop => $value) {
  785. if ($value && 0 === strpos($prop, $prefix)) {
  786. $maps[substr($prop, $prefixLen)] = $value;
  787. }
  788. }
  789. foreach ($maps as $prop => $value) {
  790. if (count($value) > 32767) {
  791. $staticPhpVersion = 70000;
  792. }
  793. $value = strtr(
  794. var_export($value, true),
  795. array(
  796. $absoluteVendorPathCode => $vendorPathCode,
  797. $absoluteVendorPharPathCode => $vendorPharPathCode,
  798. $absoluteAppBaseDirCode => $appBaseDirCode,
  799. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  800. )
  801. );
  802. $value = ltrim(preg_replace('/^ */m', ' $0$0', $value));
  803. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  804. if ('files' !== $prop) {
  805. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  806. }
  807. }
  808. return $file . <<<INITIALIZER
  809. public static function getInitializer(ClassLoader \$loader)
  810. {
  811. return \Closure::bind(function () use (\$loader) {
  812. $initializer
  813. }, null, ClassLoader::class);
  814. }
  815. }
  816. INITIALIZER;
  817. }
  818. protected function parseAutoloadsType(array $packageMap, $type, RootPackageInterface $rootPackage)
  819. {
  820. $autoloads = array();
  821. foreach ($packageMap as $item) {
  822. list($package, $installPath) = $item;
  823. $autoload = $package->getAutoload();
  824. if ($this->devMode && $package === $rootPackage) {
  825. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  826. }
  827. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  828. continue;
  829. }
  830. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  831. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  832. }
  833. foreach ($autoload[$type] as $namespace => $paths) {
  834. foreach ((array) $paths as $path) {
  835. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !is_readable($installPath.'/'.$path)) {
  836. if ($package === $rootPackage) {
  837. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  838. $path = ltrim(preg_replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  839. } else {
  840. $path = $package->getTargetDir() . '/' . $path;
  841. }
  842. }
  843. if ($type === 'exclude-from-classmap') {
  844. $path = preg_replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  845. $path = strtr($path, array('\\*\\*' => '.+?', '\\*' => '[^/]+?'));
  846. $updir = null;
  847. $path = preg_replace_callback(
  848. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  849. function ($matches) use (&$updir) {
  850. if (isset($matches[1])) {
  851. $updir = str_replace('\\.', '.', $matches[1]);
  852. }
  853. return '';
  854. },
  855. $path
  856. );
  857. if (empty($installPath)) {
  858. $installPath = strtr(getcwd(), '\\', '/');
  859. }
  860. $resolvedPath = realpath($installPath . '/' . $updir);
  861. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  862. continue;
  863. }
  864. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  865. if ($type === 'files') {
  866. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  867. continue;
  868. }
  869. if ($type === 'classmap') {
  870. $autoloads[] = $relativePath;
  871. continue;
  872. }
  873. $autoloads[$namespace][] = $relativePath;
  874. }
  875. }
  876. }
  877. return $autoloads;
  878. }
  879. protected function getFileIdentifier(PackageInterface $package, $path)
  880. {
  881. return md5($package->getName() . ':' . $path);
  882. }
  883. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  884. {
  885. $packages = array();
  886. $include = array();
  887. $replacedBy = array();
  888. foreach ($packageMap as $item) {
  889. $package = $item[0];
  890. $name = $package->getName();
  891. $packages[$name] = $package;
  892. foreach ($package->getReplaces() as $replace) {
  893. $replacedBy[$replace->getTarget()] = $name;
  894. }
  895. }
  896. $add = function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy) {
  897. foreach ($package->getRequires() as $link) {
  898. $target = $link->getTarget();
  899. if (isset($replacedBy[$target])) {
  900. $target = $replacedBy[$target];
  901. }
  902. if (!isset($include[$target])) {
  903. $include[$target] = true;
  904. if (isset($packages[$target])) {
  905. $add($packages[$target]);
  906. }
  907. }
  908. }
  909. };
  910. $add($rootPackage);
  911. return array_filter(
  912. $packageMap,
  913. function ($item) use ($include) {
  914. $package = $item[0];
  915. foreach ($package->getNames() as $name) {
  916. if (isset($include[$name])) {
  917. return true;
  918. }
  919. }
  920. return false;
  921. }
  922. );
  923. }
  924. protected function sortPackageMap(array $packageMap)
  925. {
  926. $packages = array();
  927. $paths = array();
  928. foreach ($packageMap as $item) {
  929. list($package, $path) = $item;
  930. $name = $package->getName();
  931. $packages[$name] = $package;
  932. $paths[$name] = $path;
  933. }
  934. $sortedPackages = PackageSorter::sortPackages($packages);
  935. $sortedPackageMap = array();
  936. foreach ($sortedPackages as $package) {
  937. $name = $package->getName();
  938. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  939. }
  940. return $sortedPackageMap;
  941. }
  942. }
  943. <?php
  944. namespace Composer\Autoload;
  945. use Symfony\Component\Finder\Finder;
  946. use Composer\IO\IOInterface;
  947. use Composer\Util\Filesystem;
  948. class ClassMapGenerator
  949. {
  950. public static function dump($dirs, $file)
  951. {
  952. $maps = array();
  953. foreach ($dirs as $dir) {
  954. $maps = array_merge($maps, static::createMap($dir));
  955. }
  956. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  957. }
  958. public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
  959. {
  960. $basePath = $path;
  961. if (is_string($path)) {
  962. if (is_file($path)) {
  963. $path = array(new \SplFileInfo($path));
  964. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  965. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  966. } else {
  967. throw new \RuntimeException(
  968. 'Could not scan for classes inside "'.$path.
  969. '" which does not appear to be a file nor a folder'
  970. );
  971. }
  972. } elseif (null !== $autoloadType) {
  973. throw new \RuntimeException('Path must be a string when specifying an autoload type');
  974. }
  975. $map = array();
  976. $filesystem = new Filesystem();
  977. $cwd = realpath(getcwd());
  978. foreach ($path as $file) {
  979. $filePath = $file->getPathname();
  980. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  981. continue;
  982. }
  983. if (!$filesystem->isAbsolutePath($filePath)) {
  984. $filePath = $cwd . '/' . $filePath;
  985. $filePath = $filesystem->normalizePath($filePath);
  986. } else {
  987. $filePath = preg_replace('{[\\\\/]{2,}}', '/', $filePath);
  988. }
  989. $realPath = realpath($filePath);
  990. if (isset($scannedFiles[$realPath])) {
  991. continue;
  992. }
  993. if ($excluded && preg_match($excluded, strtr($realPath, '\\', '/'))) {
  994. continue;
  995. }
  996. if ($excluded && preg_match($excluded, strtr($filePath, '\\', '/'))) {
  997. continue;
  998. }
  999. $classes = self::findClasses($filePath);
  1000. if (null !== $autoloadType) {
  1001. $classes = self::filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath, $io);
  1002. if ($classes) {
  1003. $scannedFiles[$realPath] = true;
  1004. }
  1005. } else {
  1006. $scannedFiles[$realPath] = true;
  1007. }
  1008. foreach ($classes as $class) {
  1009. if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
  1010. continue;
  1011. }
  1012. if (!isset($map[$class])) {
  1013. $map[$class] = $filePath;
  1014. } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  1015. $io->writeError(
  1016. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1017. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  1018. );
  1019. }
  1020. }
  1021. }
  1022. return $map;
  1023. }
  1024. private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io)
  1025. {
  1026. $validClasses = array();
  1027. $rejectedClasses = array();
  1028. $realSubPath = substr($filePath, strlen($basePath) + 1);
  1029. $realSubPath = substr($realSubPath, 0, strrpos($realSubPath, '.'));
  1030. foreach ($classes as $class) {
  1031. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  1032. continue;
  1033. }
  1034. if ('psr-0' === $namespaceType) {
  1035. $namespaceLength = strrpos($class, '\\');
  1036. if (false !== $namespaceLength) {
  1037. $namespace = substr($class, 0, $namespaceLength + 1);
  1038. $className = substr($class, $namespaceLength + 1);
  1039. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  1040. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  1041. }
  1042. else {
  1043. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  1044. }
  1045. } elseif ('psr-4' === $namespaceType) {
  1046. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  1047. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  1048. } else {
  1049. throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");
  1050. }
  1051. if ($subPath === $realSubPath) {
  1052. $validClasses[] = $class;
  1053. } else {
  1054. $rejectedClasses[] = $class;
  1055. }
  1056. }
  1057. if (empty($validClasses)) {
  1058. foreach ($rejectedClasses as $class) {
  1059. if ($io) {
  1060. $io->writeError("<warning>Class $class located in ".preg_replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
  1061. }
  1062. }
  1063. return array();
  1064. }
  1065. return $validClasses;
  1066. }
  1067. private static function findClasses($path)
  1068. {
  1069. $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
  1070. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
  1071. $extraTypes .= '|enum';
  1072. }
  1073. $contents = @php_strip_whitespace($path);
  1074. if (!$contents) {
  1075. if (!file_exists($path)) {
  1076. $message = 'File at "%s" does not exist, check your classmap definitions';
  1077. } elseif (!is_readable($path)) {
  1078. $message = 'File at "%s" is not readable, check its permissions';
  1079. } elseif ('' === trim(file_get_contents($path))) {
  1080. return array();
  1081. } else {
  1082. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  1083. }
  1084. $error = error_get_last();
  1085. if (isset($error['message'])) {
  1086. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  1087. }
  1088. throw new \RuntimeException(sprintf($message, $path));
  1089. }
  1090. if (!preg_match('{\b(?:class|interface'.$extraTypes.')\s}i', $contents)) {
  1091. return array();
  1092. }
  1093. $contents = preg_replace('{<<<[ \t]*([\'"]?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)(?:\s*)\\2(?=\s+|[;,.)])}s', 'null', $contents);
  1094. $contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
  1095. if (strpos($contents, '<?') !== 0) {
  1096. $contents = preg_replace('{^.+?<\?}s', '<?', $contents, 1, $replacements);
  1097. if ($replacements === 0) {
  1098. return array();
  1099. }
  1100. }
  1101. $contents = preg_replace('{\?>(?:[^<]++|<(?!\?))*+<\?}s', '?><?', $contents);
  1102. $pos = strrpos($contents, '?>');
  1103. if (false !== $pos && false === strpos(substr($contents, $pos), '<?')) {
  1104. $contents = substr($contents, 0, $pos);
  1105. }
  1106. if (preg_match('{(<\?)(?!(php|hh))}i', $contents)) {
  1107. $contents = preg_replace('{//.* | /\*(?:[^*]++|\*(?!/))*\*/}x', '', $contents);
  1108. }
  1109. preg_match_all('{
  1110. (?:
  1111. \b(?<![\$:>])(?P<type>class|interface'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  1112. | \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*+ [\{;]
  1113. )
  1114. }ix', $contents, $matches);
  1115. $classes = array();
  1116. $namespace = '';
  1117. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  1118. if (!empty($matches['ns'][$i])) {
  1119. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
  1120. } else {
  1121. $name = $matches['name'][$i];
  1122. if ($name === 'extends' || $name === 'implements') {
  1123. continue;
  1124. }
  1125. if ($name[0] === ':') {
  1126. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  1127. } elseif ($matches['type'][$i] === 'enum') {
  1128. $name = rtrim($name, ':');
  1129. }
  1130. $classes[] = ltrim($namespace . $name, '\\');
  1131. }
  1132. }
  1133. return $classes;
  1134. }
  1135. }
  1136. <?php
  1137. namespace Composer;
  1138. use Composer\IO\IOInterface;
  1139. use Composer\Util\Filesystem;
  1140. use Composer\Util\Silencer;
  1141. use Symfony\Component\Finder\Finder;
  1142. class Cache
  1143. {
  1144. private static $cacheCollected = false;
  1145. private $io;
  1146. private $root;
  1147. private $enabled = true;
  1148. private $allowlist;
  1149. private $filesystem;
  1150. private $readOnly;
  1151. public function __construct(IOInterface $io, $cacheDir, $allowlist = 'a-z0-9.', Filesystem $filesystem = null, $readOnly = false)
  1152. {
  1153. $this->io = $io;
  1154. $this->root = rtrim($cacheDir, '/\\') . '/';
  1155. $this->allowlist = $allowlist;
  1156. $this->filesystem = $filesystem ?: new Filesystem();
  1157. $this->readOnly = (bool) $readOnly;
  1158. if (!self::isUsable($cacheDir)) {
  1159. $this->enabled = false;
  1160. return;
  1161. }
  1162. if (
  1163. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1164. || !is_writable($this->root)
  1165. ) {
  1166. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  1167. $this->enabled = false;
  1168. }
  1169. }
  1170. public function setReadOnly($readOnly)
  1171. {
  1172. $this->readOnly = (bool) $readOnly;
  1173. }
  1174. public function isReadOnly()
  1175. {
  1176. return $this->readOnly;
  1177. }
  1178. public static function isUsable($path)
  1179. {
  1180. return !preg_match('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1181. }
  1182. public function isEnabled()
  1183. {
  1184. return $this->enabled;
  1185. }
  1186. public function getRoot()
  1187. {
  1188. return $this->root;
  1189. }
  1190. public function read($file)
  1191. {
  1192. if ($this->enabled) {
  1193. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1194. if (file_exists($this->root . $file)) {
  1195. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1196. return file_get_contents($this->root . $file);
  1197. }
  1198. }
  1199. return false;
  1200. }
  1201. public function write($file, $contents)
  1202. {
  1203. if ($this->enabled && !$this->readOnly) {
  1204. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1205. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1206. try {
  1207. return file_put_contents($this->root . $file, $contents);
  1208. } catch (\ErrorException $e) {
  1209. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1210. if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1211. unlink($this->root . $file);
  1212. $message = sprintf(
  1213. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  1214. $this->root . $file,
  1215. $m[1],
  1216. $m[2],
  1217. @disk_free_space($this->root . dirname($file))
  1218. );
  1219. $this->io->writeError($message);
  1220. return false;
  1221. }
  1222. throw $e;
  1223. }
  1224. }
  1225. return false;
  1226. }
  1227. public function copyFrom($file, $source)
  1228. {
  1229. if ($this->enabled && !$this->readOnly) {
  1230. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1231. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1232. if (!file_exists($source)) {
  1233. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1234. } elseif ($this->io->isDebug()) {
  1235. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1236. }
  1237. return copy($source, $this->root . $file);
  1238. }
  1239. return false;
  1240. }
  1241. public function copyTo($file, $target)
  1242. {
  1243. if ($this->enabled) {
  1244. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1245. if (file_exists($this->root . $file)) {
  1246. try {
  1247. touch($this->root . $file, filemtime($this->root . $file), time());
  1248. } catch (\ErrorException $e) {
  1249. Silencer::call('touch', $this->root . $file);
  1250. }
  1251. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1252. return copy($this->root . $file, $target);
  1253. }
  1254. }
  1255. return false;
  1256. }
  1257. public function gcIsNecessary()
  1258. {
  1259. return (!self::$cacheCollected && !mt_rand(0, 50));
  1260. }
  1261. public function remove($file)
  1262. {
  1263. if ($this->enabled) {
  1264. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1265. if (file_exists($this->root . $file)) {
  1266. return $this->filesystem->unlink($this->root . $file);
  1267. }
  1268. }
  1269. return false;
  1270. }
  1271. public function clear()
  1272. {
  1273. if ($this->enabled) {
  1274. $this->filesystem->emptyDirectory($this->root);
  1275. return true;
  1276. }
  1277. return false;
  1278. }
  1279. public function gc($ttl, $maxSize)
  1280. {
  1281. if ($this->enabled) {
  1282. $expire = new \DateTime();
  1283. $expire->modify('-'.$ttl.' seconds');
  1284. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1285. foreach ($finder as $file) {
  1286. $this->filesystem->unlink($file->getPathname());
  1287. }
  1288. $totalSize = $this->filesystem->size($this->root);
  1289. if ($totalSize > $maxSize) {
  1290. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1291. while ($totalSize > $maxSize && $iterator->valid()) {
  1292. $filepath = $iterator->current()->getPathname();
  1293. $totalSize -= $this->filesystem->size($filepath);
  1294. $this->filesystem->unlink($filepath);
  1295. $iterator->next();
  1296. }
  1297. }
  1298. self::$cacheCollected = true;
  1299. return true;
  1300. }
  1301. return false;
  1302. }
  1303. public function sha1($file)
  1304. {
  1305. if ($this->enabled) {
  1306. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1307. if (file_exists($this->root . $file)) {
  1308. return sha1_file($this->root . $file);
  1309. }
  1310. }
  1311. return false;
  1312. }
  1313. public function sha256($file)
  1314. {
  1315. if ($this->enabled) {
  1316. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1317. if (file_exists($this->root . $file)) {
  1318. return hash_file('sha256', $this->root . $file);
  1319. }
  1320. }
  1321. return false;
  1322. }
  1323. protected function getFinder()
  1324. {
  1325. return Finder::create()->in($this->root)->files();
  1326. }
  1327. }
  1328. <?php
  1329. namespace Composer\Command;
  1330. use Symfony\Component\Console\Input\InputInterface;
  1331. use Symfony\Component\Console\Output\OutputInterface;
  1332. class AboutCommand extends BaseCommand
  1333. {
  1334. protected function configure()
  1335. {
  1336. $this
  1337. ->setName('about')
  1338. ->setDescription('Shows the short information about Composer.')
  1339. ->setHelp(
  1340. <<<EOT
  1341. <info>php composer.phar about</info>
  1342. EOT
  1343. )
  1344. ;
  1345. }
  1346. protected function execute(InputInterface $input, OutputInterface $output)
  1347. {
  1348. $this->getIO()->write(
  1349. <<<EOT
  1350. <info>Composer - Dependency Manager for PHP</info>
  1351. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1352. See https://getcomposer.org/ for more information.</comment>
  1353. EOT
  1354. );
  1355. return 0;
  1356. }
  1357. }
  1358. <?php
  1359. namespace Composer\Command;
  1360. use Composer\Factory;
  1361. use Composer\IO\IOInterface;
  1362. use Composer\Config;
  1363. use Composer\Composer;
  1364. use Composer\Repository\CompositeRepository;
  1365. use Composer\Repository\RepositoryFactory;
  1366. use Composer\Script\ScriptEvents;
  1367. use Composer\Plugin\CommandEvent;
  1368. use Composer\Plugin\PluginEvents;
  1369. use Composer\Util\Filesystem;
  1370. use Composer\Util\Loop;
  1371. use Composer\Util\ProcessExecutor;
  1372. use Symfony\Component\Console\Input\InputArgument;
  1373. use Symfony\Component\Console\Input\InputInterface;
  1374. use Symfony\Component\Console\Input\InputOption;
  1375. use Symfony\Component\Console\Output\OutputInterface;
  1376. class ArchiveCommand extends BaseCommand
  1377. {
  1378. protected function configure()
  1379. {
  1380. $this
  1381. ->setName('archive')
  1382. ->setDescription('Creates an archive of this composer package.')
  1383. ->setDefinition(array(
  1384. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1385. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1386. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'),
  1387. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1388. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1389. .' Note that the format will be appended.'),
  1390. new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1391. ))
  1392. ->setHelp(
  1393. <<<EOT
  1394. The <info>archive</info> command creates an archive of the specified format
  1395. containing the files and directories of the Composer project or the specified
  1396. package in the specified version and writes it to the specified directory.
  1397. <info>php composer.phar archive [--format=zip] [--dir=/foo] [package [version]]</info>
  1398. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1399. EOT
  1400. )
  1401. ;
  1402. }
  1403. protected function execute(InputInterface $input, OutputInterface $output)
  1404. {
  1405. $composer = $this->getComposer(false);
  1406. $config = null;
  1407. if ($composer) {
  1408. $config = $composer->getConfig();
  1409. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1410. $eventDispatcher = $composer->getEventDispatcher();
  1411. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1412. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1413. }
  1414. if (!$config) {
  1415. $config = Factory::createConfig();
  1416. }
  1417. if (null === $input->getOption('format')) {
  1418. $input->setOption('format', $config->get('archive-format'));
  1419. }
  1420. if (null === $input->getOption('dir')) {
  1421. $input->setOption('dir', $config->get('archive-dir'));
  1422. }
  1423. $returnCode = $this->archive(
  1424. $this->getIO(),
  1425. $config,
  1426. $input->getArgument('package'),
  1427. $input->getArgument('version'),
  1428. $input->getOption('format'),
  1429. $input->getOption('dir'),
  1430. $input->getOption('file'),
  1431. $input->getOption('ignore-filters'),
  1432. $composer
  1433. );
  1434. if (0 === $returnCode && $composer) {
  1435. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1436. }
  1437. return $returnCode;
  1438. }
  1439. protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
  1440. {
  1441. if ($composer) {
  1442. $archiveManager = $composer->getArchiveManager();
  1443. } else {
  1444. $factory = new Factory;
  1445. $process = new ProcessExecutor();
  1446. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1447. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1448. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1449. }
  1450. if ($packageName) {
  1451. $package = $this->selectPackage($io, $packageName, $version);
  1452. if (!$package) {
  1453. return 1;
  1454. }
  1455. } else {
  1456. $package = $this->getComposer()->getPackage();
  1457. }
  1458. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1459. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1460. $fs = new Filesystem;
  1461. $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
  1462. $io->writeError('Created: ', false);
  1463. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1464. return 0;
  1465. }
  1466. protected function selectPackage(IOInterface $io, $packageName, $version = null)
  1467. {
  1468. $io->writeError('<info>Searching for the specified package.</info>');
  1469. if ($composer = $this->getComposer(false)) {
  1470. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1471. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1472. } else {
  1473. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1474. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1475. $repo = new CompositeRepository($defaultRepos);
  1476. }
  1477. $packages = $repo->findPackages($packageName, $version);
  1478. if (count($packages) > 1) {
  1479. $package = reset($packages);
  1480. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1481. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {
  1482. return $p->getPrettyString();
  1483. }, $packages)).'.');
  1484. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1485. } elseif ($packages) {
  1486. $package = reset($packages);
  1487. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1488. } else {
  1489. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1490. return false;
  1491. }
  1492. return $package;
  1493. }
  1494. }
  1495. <?php
  1496. namespace Composer\Command;
  1497. use Composer\Composer;
  1498. use Composer\Config;
  1499. use Composer\Console\Application;
  1500. use Composer\Factory;
  1501. use Composer\IO\IOInterface;
  1502. use Composer\IO\NullIO;
  1503. use Composer\Plugin\PreCommandRunEvent;
  1504. use Composer\Package\Version\VersionParser;
  1505. use Composer\Plugin\PluginEvents;
  1506. use Symfony\Component\Console\Helper\Table;
  1507. use Symfony\Component\Console\Input\InputInterface;
  1508. use Symfony\Component\Console\Output\OutputInterface;
  1509. use Symfony\Component\Console\Command\Command;
  1510. abstract class BaseCommand extends Command
  1511. {
  1512. private $composer;
  1513. private $io;
  1514. public function getComposer($required = true, $disablePlugins = null)
  1515. {
  1516. if (null === $this->composer) {
  1517. $application = $this->getApplication();
  1518. if ($application instanceof Application) {
  1519. $this->composer = $application->getComposer($required, $disablePlugins);
  1520. } elseif ($required) {
  1521. throw new \RuntimeException(
  1522. 'Could not create a Composer\Composer instance, you must inject '.
  1523. 'one if this command is not used with a Composer\Console\Application instance'
  1524. );
  1525. }
  1526. }
  1527. return $this->composer;
  1528. }
  1529. public function setComposer(Composer $composer)
  1530. {
  1531. $this->composer = $composer;
  1532. }
  1533. public function resetComposer()
  1534. {
  1535. $this->composer = null;
  1536. $this->getApplication()->resetComposer();
  1537. }
  1538. public function isProxyCommand()
  1539. {
  1540. return false;
  1541. }
  1542. public function getIO()
  1543. {
  1544. if (null === $this->io) {
  1545. $application = $this->getApplication();
  1546. if ($application instanceof Application) {
  1547. $this->io = $application->getIO();
  1548. } else {
  1549. $this->io = new NullIO();
  1550. }
  1551. }
  1552. return $this->io;
  1553. }
  1554. public function setIO(IOInterface $io)
  1555. {
  1556. $this->io = $io;
  1557. }
  1558. protected function initialize(InputInterface $input, OutputInterface $output)
  1559. {
  1560. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1561. $composer = $this->getComposer(false, $disablePlugins);
  1562. if (null === $composer) {
  1563. $composer = Factory::createGlobal($this->getIO(), $disablePlugins);
  1564. }
  1565. if ($composer) {
  1566. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1567. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1568. }
  1569. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1570. $input->setOption('no-progress', true);
  1571. }
  1572. parent::initialize($input, $output);
  1573. }
  1574. protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
  1575. {
  1576. $preferSource = false;
  1577. $preferDist = false;
  1578. switch ($config->get('preferred-install')) {
  1579. case 'source':
  1580. $preferSource = true;
  1581. break;
  1582. case 'dist':
  1583. $preferDist = true;
  1584. break;
  1585. case 'auto':
  1586. default:
  1587. break;
  1588. }
  1589. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1590. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1591. $preferDist = (bool) $input->getOption('prefer-dist');
  1592. }
  1593. return array($preferSource, $preferDist);
  1594. }
  1595. protected function formatRequirements(array $requirements)
  1596. {
  1597. $requires = array();
  1598. $requirements = $this->normalizeRequirements($requirements);
  1599. foreach ($requirements as $requirement) {
  1600. if (!isset($requirement['version'])) {
  1601. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  1602. }
  1603. $requires[$requirement['name']] = $requirement['version'];
  1604. }
  1605. return $requires;
  1606. }
  1607. protected function normalizeRequirements(array $requirements)
  1608. {
  1609. $parser = new VersionParser();
  1610. return $parser->parseNameVersionPairs($requirements);
  1611. }
  1612. protected function renderTable(array $table, OutputInterface $output)
  1613. {
  1614. $renderer = new Table($output);
  1615. $renderer->setStyle('compact');
  1616. $rendererStyle = $renderer->getStyle();
  1617. if (method_exists($rendererStyle, 'setVerticalBorderChars')) {
  1618. $rendererStyle->setVerticalBorderChars('');
  1619. } else {
  1620. $rendererStyle->setVerticalBorderChar('');
  1621. }
  1622. $rendererStyle->setCellRowContentFormat('%s ');
  1623. $renderer->setRows($table)->render();
  1624. }
  1625. }
  1626. <?php
  1627. namespace Composer\Command;
  1628. use Composer\Package\Link;
  1629. use Composer\Package\PackageInterface;
  1630. use Composer\Package\RootPackage;
  1631. use Composer\Repository\InstalledArrayRepository;
  1632. use Composer\Repository\CompositeRepository;
  1633. use Composer\Repository\RootPackageRepository;
  1634. use Composer\Repository\InstalledRepository;
  1635. use Composer\Repository\PlatformRepository;
  1636. use Composer\Repository\RepositoryFactory;
  1637. use Composer\Plugin\CommandEvent;
  1638. use Composer\Plugin\PluginEvents;
  1639. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1640. use Composer\Package\Version\VersionParser;
  1641. use Symfony\Component\Console\Input\InputArgument;
  1642. use Symfony\Component\Console\Input\InputInterface;
  1643. use Symfony\Component\Console\Input\InputOption;
  1644. use Symfony\Component\Console\Output\OutputInterface;
  1645. class BaseDependencyCommand extends BaseCommand
  1646. {
  1647. const ARGUMENT_PACKAGE = 'package';
  1648. const ARGUMENT_CONSTRAINT = 'constraint';
  1649. const OPTION_RECURSIVE = 'recursive';
  1650. const OPTION_TREE = 'tree';
  1651. protected $colors;
  1652. protected function configure()
  1653. {
  1654. $this->setDefinition(array(
  1655. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  1656. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::OPTIONAL, 'Optional version constraint', '*'),
  1657. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  1658. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  1659. ));
  1660. }
  1661. protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
  1662. {
  1663. $composer = $this->getComposer();
  1664. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1665. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1666. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1667. $installedRepo = new InstalledRepository(array(
  1668. new RootPackageRepository($composer->getPackage()),
  1669. $composer->getRepositoryManager()->getLocalRepository(),
  1670. new PlatformRepository(array(), $platformOverrides),
  1671. ));
  1672. list($needle, $textConstraint) = array_pad(
  1673. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1674. 2,
  1675. $input->getArgument(self::ARGUMENT_CONSTRAINT)
  1676. );
  1677. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  1678. if (empty($packages)) {
  1679. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1680. }
  1681. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  1682. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  1683. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  1684. $installedRepo->addRepository(new InstalledArrayRepository(array(clone $match)));
  1685. }
  1686. }
  1687. $needles = array($needle);
  1688. if ($inverted) {
  1689. foreach ($packages as $package) {
  1690. $needles = array_merge($needles, array_map(function (Link $link) {
  1691. return $link->getTarget();
  1692. }, $package->getReplaces()));
  1693. }
  1694. }
  1695. if ('*' !== $textConstraint) {
  1696. $versionParser = new VersionParser();
  1697. $constraint = $versionParser->parseConstraints($textConstraint);
  1698. } else {
  1699. $constraint = null;
  1700. }
  1701. $renderTree = $input->getOption(self::OPTION_TREE);
  1702. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  1703. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  1704. if (empty($results)) {
  1705. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  1706. $this->getIO()->writeError(sprintf(
  1707. '<info>There is no installed package depending on "%s"%s</info>',
  1708. $needle,
  1709. $extra
  1710. ));
  1711. } elseif ($renderTree) {
  1712. $this->initStyles($output);
  1713. $root = $packages[0];
  1714. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root->getDescription()));
  1715. $this->printTree($results);
  1716. } else {
  1717. $this->printTable($output, $results);
  1718. }
  1719. return 0;
  1720. }
  1721. protected function printTable(OutputInterface $output, $results)
  1722. {
  1723. $table = array();
  1724. $doubles = array();
  1725. do {
  1726. $queue = array();
  1727. $rows = array();
  1728. foreach ($results as $result) {
  1729. list($package, $link, $children) = $result;
  1730. $unique = (string) $link;
  1731. if (isset($doubles[$unique])) {
  1732. continue;
  1733. }
  1734. $doubles[$unique] = true;
  1735. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  1736. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  1737. if ($children) {
  1738. $queue = array_merge($queue, $children);
  1739. }
  1740. }
  1741. $results = $queue;
  1742. $table = array_merge($rows, $table);
  1743. } while (!empty($results));
  1744. $this->renderTable($table, $output);
  1745. }
  1746. protected function initStyles(OutputInterface $output)
  1747. {
  1748. $this->colors = array(
  1749. 'green',
  1750. 'yellow',
  1751. 'cyan',
  1752. 'magenta',
  1753. 'blue',
  1754. );
  1755. foreach ($this->colors as $color) {
  1756. $style = new OutputFormatterStyle($color);
  1757. $output->getFormatter()->setStyle($color, $style);
  1758. }
  1759. }
  1760. protected function printTree($results, $prefix = '', $level = 1)
  1761. {
  1762. $count = count($results);
  1763. $idx = 0;
  1764. foreach ($results as $result) {
  1765. list($package, $link, $children) = $result;
  1766. $color = $this->colors[$level % count($this->colors)];
  1767. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  1768. $isLast = (++$idx == $count);
  1769. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  1770. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  1771. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  1772. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  1773. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  1774. if ($children) {
  1775. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  1776. }
  1777. }
  1778. }
  1779. private function writeTreeLine($line)
  1780. {
  1781. $io = $this->getIO();
  1782. if (!$io->isDecorated()) {
  1783. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  1784. }
  1785. $io->write($line);
  1786. }
  1787. }
  1788. <?php
  1789. namespace Composer\Command;
  1790. use Composer\Package\Link;
  1791. use Composer\Package\PackageInterface;
  1792. use Composer\Semver\Constraint\Constraint;
  1793. use Symfony\Component\Console\Input\InputInterface;
  1794. use Symfony\Component\Console\Input\InputOption;
  1795. use Symfony\Component\Console\Output\OutputInterface;
  1796. use Composer\Repository\PlatformRepository;
  1797. use Composer\Repository\RootPackageRepository;
  1798. use Composer\Repository\InstalledRepository;
  1799. class CheckPlatformReqsCommand extends BaseCommand
  1800. {
  1801. protected function configure()
  1802. {
  1803. $this->setName('check-platform-reqs')
  1804. ->setDescription('Check that platform requirements are satisfied.')
  1805. ->setDefinition(array(
  1806. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  1807. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  1808. ))
  1809. ->setHelp(
  1810. <<<EOT
  1811. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  1812. 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.
  1813. <info>php composer.phar check-platform-reqs</info>
  1814. EOT
  1815. );
  1816. }
  1817. protected function execute(InputInterface $input, OutputInterface $output)
  1818. {
  1819. $composer = $this->getComposer();
  1820. $requires = array();
  1821. $removePackages = array();
  1822. if ($input->getOption('lock')) {
  1823. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  1824. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  1825. } else {
  1826. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  1827. if (!$installedRepo->getPackages()) {
  1828. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  1829. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  1830. } else {
  1831. if ($input->getOption('no-dev')) {
  1832. $removePackages = $installedRepo->getDevPackageNames();
  1833. }
  1834. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  1835. }
  1836. }
  1837. if (!$input->getOption('no-dev')) {
  1838. $requires += $composer->getPackage()->getDevRequires();
  1839. }
  1840. foreach ($requires as $require => $link) {
  1841. $requires[$require] = array($link);
  1842. }
  1843. $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
  1844. foreach ($installedRepo->getPackages() as $package) {
  1845. if (in_array($package->getName(), $removePackages, true)) {
  1846. continue;
  1847. }
  1848. foreach ($package->getRequires() as $require => $link) {
  1849. $requires[$require][] = $link;
  1850. }
  1851. }
  1852. ksort($requires);
  1853. $installedRepo->addRepository(new PlatformRepository(array(), array()));
  1854. $results = array();
  1855. $exitCode = 0;
  1856. foreach ($requires as $require => $links) {
  1857. if (PlatformRepository::isPlatformPackage($require)) {
  1858. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  1859. if ($candidates) {
  1860. $reqResults = array();
  1861. foreach ($candidates as $candidate) {
  1862. $candidateConstraint = null;
  1863. if ($candidate->getName() === $require) {
  1864. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  1865. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  1866. } else {
  1867. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  1868. if ($link->getTarget() === $require) {
  1869. $candidateConstraint = $link->getConstraint();
  1870. break;
  1871. }
  1872. }
  1873. }
  1874. if (!$candidateConstraint) {
  1875. continue;
  1876. }
  1877. foreach ($links as $link) {
  1878. if (!$link->getConstraint()->matches($candidateConstraint)) {
  1879. $reqResults[] = array(
  1880. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1881. $candidateConstraint->getPrettyString(),
  1882. $link,
  1883. '<error>failed</error>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1884. );
  1885. continue 2;
  1886. }
  1887. }
  1888. $results[] = array(
  1889. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1890. $candidateConstraint->getPrettyString(),
  1891. null,
  1892. '<info>success</info>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1893. );
  1894. continue 2;
  1895. }
  1896. $results = array_merge($results, $reqResults);
  1897. $exitCode = max($exitCode, 1);
  1898. continue;
  1899. }
  1900. $results[] = array(
  1901. $require,
  1902. 'n/a',
  1903. $links[0],
  1904. '<error>missing</error>',
  1905. );
  1906. $exitCode = max($exitCode, 2);
  1907. }
  1908. }
  1909. $this->printTable($output, $results);
  1910. return $exitCode;
  1911. }
  1912. protected function printTable(OutputInterface $output, $results)
  1913. {
  1914. $rows = array();
  1915. foreach ($results as $result) {
  1916. list($platformPackage, $version, $link, $status) = $result;
  1917. $rows[] = array(
  1918. $platformPackage,
  1919. $version,
  1920. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  1921. $status,
  1922. );
  1923. }
  1924. $this->renderTable($rows, $output);
  1925. }
  1926. }
  1927. <?php
  1928. namespace Composer\Command;
  1929. use Composer\Cache;
  1930. use Composer\Factory;
  1931. use Symfony\Component\Console\Input\InputInterface;
  1932. use Symfony\Component\Console\Output\OutputInterface;
  1933. class ClearCacheCommand extends BaseCommand
  1934. {
  1935. protected function configure()
  1936. {
  1937. $this
  1938. ->setName('clear-cache')
  1939. ->setAliases(array('clearcache', 'cc'))
  1940. ->setDescription('Clears composer\'s internal package cache.')
  1941. ->setHelp(
  1942. <<<EOT
  1943. The <info>clear-cache</info> deletes all cached packages from composer's
  1944. cache directory.
  1945. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  1946. EOT
  1947. )
  1948. ;
  1949. }
  1950. protected function execute(InputInterface $input, OutputInterface $output)
  1951. {
  1952. $config = Factory::createConfig();
  1953. $io = $this->getIO();
  1954. $cachePaths = array(
  1955. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  1956. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  1957. 'cache-files-dir' => $config->get('cache-files-dir'),
  1958. 'cache-dir' => $config->get('cache-dir'),
  1959. );
  1960. foreach ($cachePaths as $key => $cachePath) {
  1961. $cachePath = realpath($cachePath);
  1962. if (!$cachePath) {
  1963. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  1964. continue;
  1965. }
  1966. $cache = new Cache($io, $cachePath);
  1967. $cache->setReadOnly($config->get('cache-read-only'));
  1968. if (!$cache->isEnabled()) {
  1969. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  1970. continue;
  1971. }
  1972. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  1973. $cache->clear();
  1974. }
  1975. $io->writeError('<info>All caches cleared.</info>');
  1976. return 0;
  1977. }
  1978. }
  1979. <?php
  1980. namespace Composer\Command;
  1981. use Composer\Util\Platform;
  1982. use Composer\Util\Silencer;
  1983. use Symfony\Component\Console\Input\InputInterface;
  1984. use Symfony\Component\Console\Input\InputArgument;
  1985. use Symfony\Component\Console\Input\InputOption;
  1986. use Symfony\Component\Console\Output\OutputInterface;
  1987. use Composer\Config;
  1988. use Composer\Config\JsonConfigSource;
  1989. use Composer\Factory;
  1990. use Composer\IO\IOInterface;
  1991. use Composer\Json\JsonFile;
  1992. use Composer\Semver\VersionParser;
  1993. use Composer\Package\BasePackage;
  1994. class ConfigCommand extends BaseCommand
  1995. {
  1996. protected $config;
  1997. protected $configFile;
  1998. protected $configSource;
  1999. protected $authConfigFile;
  2000. protected $authConfigSource;
  2001. protected function configure()
  2002. {
  2003. $this
  2004. ->setName('config')
  2005. ->setDescription('Sets config options.')
  2006. ->setDefinition(array(
  2007. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  2008. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  2009. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  2010. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  2011. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  2012. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  2013. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  2014. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  2015. 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'),
  2016. 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)'),
  2017. new InputArgument('setting-key', null, 'Setting key'),
  2018. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  2019. ))
  2020. ->setHelp(
  2021. <<<EOT
  2022. This command allows you to edit composer config settings and repositories
  2023. in either the local composer.json file or the global config.json file.
  2024. Additionally it lets you edit most properties in the local composer.json.
  2025. To set a config setting:
  2026. <comment>%command.full_name% bin-dir bin/</comment>
  2027. To read a config setting:
  2028. <comment>%command.full_name% bin-dir</comment>
  2029. Outputs: <info>bin</info>
  2030. To edit the global config.json file:
  2031. <comment>%command.full_name% --global</comment>
  2032. To add a repository:
  2033. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  2034. To remove a repository (repo is a short alias for repositories):
  2035. <comment>%command.full_name% --unset repo.foo</comment>
  2036. To disable packagist:
  2037. <comment>%command.full_name% repo.packagist false</comment>
  2038. You can alter repositories in the global config.json file by passing in the
  2039. <info>--global</info> option.
  2040. To add or edit suggested packages you can use:
  2041. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  2042. To add or edit extra properties you can use:
  2043. <comment>%command.full_name% extra.property value</comment>
  2044. Or to add a complex value you can use json with:
  2045. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  2046. To edit the file in an external editor:
  2047. <comment>%command.full_name% --editor</comment>
  2048. To choose your editor you can set the "EDITOR" env variable.
  2049. To get a list of configuration values in the file:
  2050. <comment>%command.full_name% --list</comment>
  2051. You can always pass more than one option. As an example, if you want to edit the
  2052. global config.json file.
  2053. <comment>%command.full_name% --editor --global</comment>
  2054. Read more at https://getcomposer.org/doc/03-cli.md#config
  2055. EOT
  2056. )
  2057. ;
  2058. }
  2059. protected function initialize(InputInterface $input, OutputInterface $output)
  2060. {
  2061. parent::initialize($input, $output);
  2062. if ($input->getOption('global') && null !== $input->getOption('file')) {
  2063. throw new \RuntimeException('--file and --global can not be combined');
  2064. }
  2065. $io = $this->getIO();
  2066. $this->config = Factory::createConfig($io);
  2067. $configFile = $input->getOption('global')
  2068. ? ($this->config->get('home') . '/config.json')
  2069. : ($input->getOption('file') ?: Factory::getComposerFile());
  2070. if (
  2071. ($configFile === 'composer.json' || $configFile === './composer.json')
  2072. && !file_exists($configFile)
  2073. && realpath(getcwd()) === realpath($this->config->get('home'))
  2074. ) {
  2075. file_put_contents($configFile, "{\n}\n");
  2076. }
  2077. $this->configFile = new JsonFile($configFile, null, $io);
  2078. $this->configSource = new JsonConfigSource($this->configFile);
  2079. $authConfigFile = $input->getOption('global')
  2080. ? ($this->config->get('home') . '/auth.json')
  2081. : dirname(realpath($configFile)) . '/auth.json';
  2082. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  2083. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  2084. if ($input->getOption('global') && !$this->configFile->exists()) {
  2085. touch($this->configFile->getPath());
  2086. $this->configFile->write(array('config' => new \ArrayObject));
  2087. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  2088. }
  2089. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  2090. touch($this->authConfigFile->getPath());
  2091. $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));
  2092. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  2093. }
  2094. if (!$this->configFile->exists()) {
  2095. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  2096. }
  2097. }
  2098. protected function execute(InputInterface $input, OutputInterface $output)
  2099. {
  2100. if ($input->getOption('editor')) {
  2101. $editor = escapeshellcmd(getenv('EDITOR'));
  2102. if (!$editor) {
  2103. if (Platform::isWindows()) {
  2104. $editor = 'notepad';
  2105. } else {
  2106. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  2107. if (exec('which '.$candidate)) {
  2108. $editor = $candidate;
  2109. break;
  2110. }
  2111. }
  2112. }
  2113. }
  2114. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  2115. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  2116. return 0;
  2117. }
  2118. if (!$input->getOption('global')) {
  2119. $this->config->merge($this->configFile->read());
  2120. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
  2121. }
  2122. if ($input->getOption('list')) {
  2123. $this->listConfiguration($this->config->all(), $this->config->raw(), $output);
  2124. return 0;
  2125. }
  2126. $settingKey = $input->getArgument('setting-key');
  2127. if (!$settingKey || !is_string($settingKey)) {
  2128. return 0;
  2129. }
  2130. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  2131. throw new \RuntimeException('You can not combine a setting value with --unset');
  2132. }
  2133. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  2134. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  2135. $rawData = $this->configFile->read();
  2136. $data = $this->config->all();
  2137. if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  2138. if (!isset($matches[1]) || $matches[1] === '') {
  2139. $value = isset($data['repositories']) ? $data['repositories'] : array();
  2140. } else {
  2141. if (!isset($data['repositories'][$matches[1]])) {
  2142. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  2143. }
  2144. $value = $data['repositories'][$matches[1]];
  2145. }
  2146. } elseif (strpos($settingKey, '.')) {
  2147. $bits = explode('.', $settingKey);
  2148. if ($bits[0] === 'extra') {
  2149. $data = $rawData;
  2150. } else {
  2151. $data = $data['config'];
  2152. }
  2153. $match = false;
  2154. foreach ($bits as $bit) {
  2155. $key = isset($key) ? $key.'.'.$bit : $bit;
  2156. $match = false;
  2157. if (isset($data[$key])) {
  2158. $match = true;
  2159. $data = $data[$key];
  2160. unset($key);
  2161. }
  2162. }
  2163. if (!$match) {
  2164. throw new \RuntimeException($settingKey.' is not defined.');
  2165. }
  2166. $value = $data;
  2167. } elseif (isset($data['config'][$settingKey])) {
  2168. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  2169. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  2170. $value = $rawData[$settingKey];
  2171. } else {
  2172. throw new \RuntimeException($settingKey.' is not defined');
  2173. }
  2174. if (is_array($value)) {
  2175. $value = json_encode($value);
  2176. }
  2177. $this->getIO()->write($value, true, IOInterface::QUIET);
  2178. return 0;
  2179. }
  2180. $values = $input->getArgument('setting-value');
  2181. $booleanValidator = function ($val) {
  2182. return in_array($val, array('true', 'false', '1', '0'), true);
  2183. };
  2184. $booleanNormalizer = function ($val) {
  2185. return $val !== 'false' && (bool) $val;
  2186. };
  2187. $uniqueConfigValues = array(
  2188. 'process-timeout' => array('is_numeric', 'intval'),
  2189. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  2190. 'use-github-api' => array($booleanValidator, $booleanNormalizer),
  2191. 'preferred-install' => array(
  2192. function ($val) {
  2193. return in_array($val, array('auto', 'source', 'dist'), true);
  2194. },
  2195. function ($val) {
  2196. return $val;
  2197. },
  2198. ),
  2199. 'store-auths' => array(
  2200. function ($val) {
  2201. return in_array($val, array('true', 'false', 'prompt'), true);
  2202. },
  2203. function ($val) {
  2204. if ('prompt' === $val) {
  2205. return 'prompt';
  2206. }
  2207. return $val !== 'false' && (bool) $val;
  2208. },
  2209. ),
  2210. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  2211. 'vendor-dir' => array('is_string', function ($val) {
  2212. return $val;
  2213. }),
  2214. 'bin-dir' => array('is_string', function ($val) {
  2215. return $val;
  2216. }),
  2217. 'archive-dir' => array('is_string', function ($val) {
  2218. return $val;
  2219. }),
  2220. 'archive-format' => array('is_string', function ($val) {
  2221. return $val;
  2222. }),
  2223. 'data-dir' => array('is_string', function ($val) {
  2224. return $val;
  2225. }),
  2226. 'cache-dir' => array('is_string', function ($val) {
  2227. return $val;
  2228. }),
  2229. 'cache-files-dir' => array('is_string', function ($val) {
  2230. return $val;
  2231. }),
  2232. 'cache-repo-dir' => array('is_string', function ($val) {
  2233. return $val;
  2234. }),
  2235. 'cache-vcs-dir' => array('is_string', function ($val) {
  2236. return $val;
  2237. }),
  2238. 'cache-ttl' => array('is_numeric', 'intval'),
  2239. 'cache-files-ttl' => array('is_numeric', 'intval'),
  2240. 'cache-files-maxsize' => array(
  2241. function ($val) {
  2242. return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0;
  2243. },
  2244. function ($val) {
  2245. return $val;
  2246. },
  2247. ),
  2248. 'bin-compat' => array(
  2249. function ($val) {
  2250. return in_array($val, array('auto', 'full'));
  2251. },
  2252. function ($val) {
  2253. return $val;
  2254. },
  2255. ),
  2256. 'discard-changes' => array(
  2257. function ($val) {
  2258. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  2259. },
  2260. function ($val) {
  2261. if ('stash' === $val) {
  2262. return 'stash';
  2263. }
  2264. return $val !== 'false' && (bool) $val;
  2265. },
  2266. ),
  2267. 'autoloader-suffix' => array('is_string', function ($val) {
  2268. return $val === 'null' ? null : $val;
  2269. }),
  2270. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  2271. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  2272. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  2273. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  2274. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  2275. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  2276. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  2277. 'cafile' => array(
  2278. function ($val) {
  2279. return file_exists($val) && is_readable($val);
  2280. },
  2281. function ($val) {
  2282. return $val === 'null' ? null : $val;
  2283. },
  2284. ),
  2285. 'capath' => array(
  2286. function ($val) {
  2287. return is_dir($val) && is_readable($val);
  2288. },
  2289. function ($val) {
  2290. return $val === 'null' ? null : $val;
  2291. },
  2292. ),
  2293. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  2294. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  2295. 'lock' => array($booleanValidator, $booleanNormalizer),
  2296. 'platform-check' => array(
  2297. function ($val) {
  2298. return in_array($val, array('php-only', 'true', 'false', '1', '0'), true);
  2299. },
  2300. function ($val) {
  2301. if ('php-only' === $val) {
  2302. return 'php-only';
  2303. }
  2304. return $val !== 'false' && (bool) $val;
  2305. },
  2306. ),
  2307. );
  2308. $multiConfigValues = array(
  2309. 'github-protocols' => array(
  2310. function ($vals) {
  2311. if (!is_array($vals)) {
  2312. return 'array expected';
  2313. }
  2314. foreach ($vals as $val) {
  2315. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2316. return 'valid protocols include: git, https, ssh';
  2317. }
  2318. }
  2319. return true;
  2320. },
  2321. function ($vals) {
  2322. return $vals;
  2323. },
  2324. ),
  2325. 'github-domains' => array(
  2326. function ($vals) {
  2327. if (!is_array($vals)) {
  2328. return 'array expected';
  2329. }
  2330. return true;
  2331. },
  2332. function ($vals) {
  2333. return $vals;
  2334. },
  2335. ),
  2336. 'gitlab-domains' => array(
  2337. function ($vals) {
  2338. if (!is_array($vals)) {
  2339. return 'array expected';
  2340. }
  2341. return true;
  2342. },
  2343. function ($vals) {
  2344. return $vals;
  2345. },
  2346. ),
  2347. );
  2348. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2349. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  2350. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2351. }
  2352. $this->configSource->removeConfigSetting($settingKey);
  2353. return 0;
  2354. }
  2355. if (isset($uniqueConfigValues[$settingKey])) {
  2356. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2357. return 0;
  2358. }
  2359. if (isset($multiConfigValues[$settingKey])) {
  2360. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2361. return 0;
  2362. }
  2363. if (preg_match('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  2364. if ($input->getOption('unset')) {
  2365. $this->configSource->removeConfigSetting($settingKey);
  2366. return 0;
  2367. }
  2368. list($validator) = $uniqueConfigValues['preferred-install'];
  2369. if (!$validator($values[0])) {
  2370. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  2371. }
  2372. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2373. return 0;
  2374. }
  2375. $uniqueProps = array(
  2376. 'name' => array('is_string', function ($val) {
  2377. return $val;
  2378. }),
  2379. 'type' => array('is_string', function ($val) {
  2380. return $val;
  2381. }),
  2382. 'description' => array('is_string', function ($val) {
  2383. return $val;
  2384. }),
  2385. 'homepage' => array('is_string', function ($val) {
  2386. return $val;
  2387. }),
  2388. 'version' => array('is_string', function ($val) {
  2389. return $val;
  2390. }),
  2391. 'minimum-stability' => array(
  2392. function ($val) {
  2393. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2394. },
  2395. function ($val) {
  2396. return VersionParser::normalizeStability($val);
  2397. },
  2398. ),
  2399. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2400. );
  2401. $multiProps = array(
  2402. 'keywords' => array(
  2403. function ($vals) {
  2404. if (!is_array($vals)) {
  2405. return 'array expected';
  2406. }
  2407. return true;
  2408. },
  2409. function ($vals) {
  2410. return $vals;
  2411. },
  2412. ),
  2413. 'license' => array(
  2414. function ($vals) {
  2415. if (!is_array($vals)) {
  2416. return 'array expected';
  2417. }
  2418. return true;
  2419. },
  2420. function ($vals) {
  2421. return $vals;
  2422. },
  2423. ),
  2424. );
  2425. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  2426. 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');
  2427. }
  2428. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2429. $this->configSource->removeProperty($settingKey);
  2430. return 0;
  2431. }
  2432. if (isset($uniqueProps[$settingKey])) {
  2433. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2434. return 0;
  2435. }
  2436. if (isset($multiProps[$settingKey])) {
  2437. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2438. return 0;
  2439. }
  2440. if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2441. if ($input->getOption('unset')) {
  2442. $this->configSource->removeRepository($matches[1]);
  2443. return 0;
  2444. }
  2445. if (2 === count($values)) {
  2446. $this->configSource->addRepository($matches[1], array(
  2447. 'type' => $values[0],
  2448. 'url' => $values[1],
  2449. ), $input->getOption('append'));
  2450. return 0;
  2451. }
  2452. if (1 === count($values)) {
  2453. $value = strtolower($values[0]);
  2454. if (true === $booleanValidator($value)) {
  2455. if (false === $booleanNormalizer($value)) {
  2456. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  2457. return 0;
  2458. }
  2459. } else {
  2460. $value = JsonFile::parseJson($values[0]);
  2461. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  2462. return 0;
  2463. }
  2464. }
  2465. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2466. }
  2467. if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
  2468. if ($input->getOption('unset')) {
  2469. $this->configSource->removeProperty($settingKey);
  2470. return 0;
  2471. }
  2472. $value = $values[0];
  2473. if ($input->getOption('json')) {
  2474. $value = JsonFile::parseJson($value);
  2475. if ($input->getOption('merge')) {
  2476. $currentValue = $this->configFile->read();
  2477. $bits = explode('.', $settingKey);
  2478. foreach ($bits as $bit) {
  2479. $currentValue = isset($currentValue[$bit]) ? $currentValue[$bit] : null;
  2480. }
  2481. if (is_array($currentValue)) {
  2482. $value = array_merge($currentValue, $value);
  2483. }
  2484. }
  2485. }
  2486. $this->configSource->addProperty($settingKey, $value);
  2487. return 0;
  2488. }
  2489. if (preg_match('/^suggest\.(.+)/', $settingKey, $matches)) {
  2490. if ($input->getOption('unset')) {
  2491. $this->configSource->removeProperty($settingKey);
  2492. return 0;
  2493. }
  2494. $this->configSource->addProperty($settingKey, implode(' ', $values));
  2495. return 0;
  2496. }
  2497. if (in_array($settingKey, array('suggest', 'extra'), true) && $input->getOption('unset')) {
  2498. $this->configSource->removeProperty($settingKey);
  2499. return 0;
  2500. }
  2501. if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
  2502. if ($input->getOption('unset')) {
  2503. $this->configSource->removeConfigSetting($settingKey);
  2504. return 0;
  2505. }
  2506. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2507. return 0;
  2508. }
  2509. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2510. $this->configSource->removeConfigSetting($settingKey);
  2511. return 0;
  2512. }
  2513. if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  2514. if ($input->getOption('unset')) {
  2515. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2516. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2517. return 0;
  2518. }
  2519. if ($matches[1] === 'bitbucket-oauth') {
  2520. if (2 !== count($values)) {
  2521. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2522. }
  2523. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2524. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2525. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  2526. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2527. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'token' => $values[1]));
  2528. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
  2529. if (1 !== count($values)) {
  2530. throw new \RuntimeException('Too many arguments, expected only one token');
  2531. }
  2532. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2533. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2534. } elseif ($matches[1] === 'http-basic') {
  2535. if (2 !== count($values)) {
  2536. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2537. }
  2538. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2539. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2540. }
  2541. return 0;
  2542. }
  2543. if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
  2544. if ($input->getOption('unset')) {
  2545. $this->configSource->removeProperty($settingKey);
  2546. return 0;
  2547. }
  2548. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2549. return 0;
  2550. }
  2551. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2552. }
  2553. protected function handleSingleValue($key, array $callbacks, array $values, $method)
  2554. {
  2555. list($validator, $normalizer) = $callbacks;
  2556. if (1 !== count($values)) {
  2557. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2558. }
  2559. if (true !== $validation = $validator($values[0])) {
  2560. throw new \RuntimeException(sprintf(
  2561. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2562. $values[0]
  2563. ));
  2564. }
  2565. $normalizedValue = $normalizer($values[0]);
  2566. if ($key === 'disable-tls') {
  2567. if (!$normalizedValue && $this->config->get('disable-tls')) {
  2568. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2569. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  2570. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  2571. }
  2572. }
  2573. return call_user_func(array($this->configSource, $method), $key, $normalizedValue);
  2574. }
  2575. protected function handleMultiValue($key, array $callbacks, array $values, $method)
  2576. {
  2577. list($validator, $normalizer) = $callbacks;
  2578. if (true !== $validation = $validator($values)) {
  2579. throw new \RuntimeException(sprintf(
  2580. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2581. json_encode($values)
  2582. ));
  2583. }
  2584. return call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2585. }
  2586. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
  2587. {
  2588. $origK = $k;
  2589. $io = $this->getIO();
  2590. foreach ($contents as $key => $value) {
  2591. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2592. continue;
  2593. }
  2594. $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
  2595. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2596. $k .= preg_replace('{^config\.}', '', $key . '.');
  2597. $this->listConfiguration($value, $rawVal, $output, $k);
  2598. $k = $origK;
  2599. continue;
  2600. }
  2601. if (is_array($value)) {
  2602. $value = array_map(function ($val) {
  2603. return is_array($val) ? json_encode($val) : $val;
  2604. }, $value);
  2605. $value = '['.implode(', ', $value).']';
  2606. }
  2607. if (is_bool($value)) {
  2608. $value = var_export($value, true);
  2609. }
  2610. if (is_string($rawVal) && $rawVal != $value) {
  2611. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>', true, IOInterface::QUIET);
  2612. } else {
  2613. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>', true, IOInterface::QUIET);
  2614. }
  2615. }
  2616. }
  2617. }
  2618. <?php
  2619. namespace Composer\Command;
  2620. use Composer\Config;
  2621. use Composer\Factory;
  2622. use Composer\Installer;
  2623. use Composer\Installer\ProjectInstaller;
  2624. use Composer\Installer\InstallationManager;
  2625. use Composer\Installer\SuggestedPackagesReporter;
  2626. use Composer\IO\IOInterface;
  2627. use Composer\Package\BasePackage;
  2628. use Composer\DependencyResolver\Operation\InstallOperation;
  2629. use Composer\Package\Version\VersionSelector;
  2630. use Composer\Package\AliasPackage;
  2631. use Composer\Repository\RepositoryFactory;
  2632. use Composer\Repository\CompositeRepository;
  2633. use Composer\Repository\PlatformRepository;
  2634. use Composer\Repository\InstalledFilesystemRepository;
  2635. use Composer\Repository\RepositorySet;
  2636. use Composer\Script\ScriptEvents;
  2637. use Composer\Util\Silencer;
  2638. use Symfony\Component\Console\Input\InputArgument;
  2639. use Symfony\Component\Console\Input\InputInterface;
  2640. use Symfony\Component\Console\Input\InputOption;
  2641. use Symfony\Component\Console\Output\OutputInterface;
  2642. use Symfony\Component\Finder\Finder;
  2643. use Composer\Json\JsonFile;
  2644. use Composer\Config\JsonConfigSource;
  2645. use Composer\Util\Filesystem;
  2646. use Composer\Util\ProcessExecutor;
  2647. use Composer\Util\Loop;
  2648. use Composer\Package\Version\VersionParser;
  2649. use Composer\EventDispatcher\EventDispatcher;
  2650. class CreateProjectCommand extends BaseCommand
  2651. {
  2652. protected $suggestedPackagesReporter;
  2653. protected function configure()
  2654. {
  2655. $this
  2656. ->setName('create-project')
  2657. ->setDescription('Creates new project from a package into given directory.')
  2658. ->setDefinition(array(
  2659. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  2660. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  2661. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  2662. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  2663. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  2664. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  2665. 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'),
  2666. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  2667. 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.'),
  2668. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  2669. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  2670. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  2671. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  2672. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  2673. 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.'),
  2674. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  2675. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  2676. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  2677. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  2678. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  2679. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  2680. ))
  2681. ->setHelp(
  2682. <<<EOT
  2683. The <info>create-project</info> command creates a new project from a given
  2684. package into a new directory. If executed without params and in a directory
  2685. with a composer.json file it installs the packages for the current project.
  2686. You can use this command to bootstrap new projects or setup a clean
  2687. version-controlled installation for developers of your project.
  2688. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  2689. You can also specify the version with the package name using = or : as separator.
  2690. <info>php composer.phar create-project vendor/project:version target-directory</info>
  2691. To install unstable packages, either specify the version you want, or use the
  2692. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  2693. To setup a developer workable version you should create the project using the source
  2694. controlled code by appending the <info>'--prefer-source'</info> flag.
  2695. To install a package from another repository than the default one you
  2696. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  2697. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  2698. EOT
  2699. )
  2700. ;
  2701. }
  2702. protected function execute(InputInterface $input, OutputInterface $output)
  2703. {
  2704. $config = Factory::createConfig();
  2705. $io = $this->getIO();
  2706. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  2707. if ($input->getOption('dev')) {
  2708. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  2709. }
  2710. if ($input->getOption('no-custom-installers')) {
  2711. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  2712. $input->setOption('no-plugins', true);
  2713. }
  2714. if ($input->isInteractive() && $input->getOption('ask')) {
  2715. $parts = explode("/", strtolower($input->getArgument('package')), 2);
  2716. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  2717. }
  2718. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  2719. return $this->installProject(
  2720. $io,
  2721. $config,
  2722. $input,
  2723. $input->getArgument('package'),
  2724. $input->getArgument('directory'),
  2725. $input->getArgument('version'),
  2726. $input->getOption('stability'),
  2727. $preferSource,
  2728. $preferDist,
  2729. !$input->getOption('no-dev'),
  2730. $input->getOption('repository') ?: $input->getOption('repository-url'),
  2731. $input->getOption('no-plugins'),
  2732. $input->getOption('no-scripts'),
  2733. $input->getOption('no-progress'),
  2734. $input->getOption('no-install'),
  2735. $ignorePlatformReqs,
  2736. !$input->getOption('no-secure-http'),
  2737. $input->getOption('add-repository')
  2738. );
  2739. }
  2740. 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)
  2741. {
  2742. $oldCwd = getcwd();
  2743. if ($repositories !== null && !is_array($repositories)) {
  2744. $repositories = (array) $repositories;
  2745. }
  2746. $io->loadConfiguration($config);
  2747. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  2748. if ($packageName !== null) {
  2749. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $noScripts, $noProgress, $ignorePlatformReqs, $secureHttp);
  2750. } else {
  2751. $installedFromVcs = false;
  2752. }
  2753. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  2754. unlink('composer.lock');
  2755. }
  2756. $composer = Factory::create($io, null, $disablePlugins);
  2757. if ($repositories !== null && $addRepository) {
  2758. foreach ($repositories as $index => $repo) {
  2759. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  2760. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  2761. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  2762. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2763. if (
  2764. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2765. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2766. ) {
  2767. $configSource->addRepository('packagist.org', false);
  2768. } else {
  2769. $configSource->addRepository($name, $repoConfig, false);
  2770. }
  2771. $composer = Factory::create($io, null, $disablePlugins);
  2772. }
  2773. }
  2774. $process = new ProcessExecutor($io);
  2775. $fs = new Filesystem($process);
  2776. if ($noScripts === false) {
  2777. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  2778. }
  2779. $config = $composer->getConfig();
  2780. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  2781. if ($noInstall === false) {
  2782. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  2783. $installer = Installer::create($io, $composer);
  2784. $installer->setPreferSource($preferSource)
  2785. ->setPreferDist($preferDist)
  2786. ->setDevMode($installDevPackages)
  2787. ->setRunScripts(!$noScripts)
  2788. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  2789. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  2790. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  2791. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  2792. ->setApcuAutoloader($config->get('apcu-autoloader'));
  2793. if (!$composer->getLocker()->isLocked()) {
  2794. $installer->setUpdate(true);
  2795. }
  2796. if ($disablePlugins) {
  2797. $installer->disablePlugins();
  2798. }
  2799. $status = $installer->run();
  2800. if (0 !== $status) {
  2801. return $status;
  2802. }
  2803. }
  2804. $hasVcs = $installedFromVcs;
  2805. if (
  2806. !$input->getOption('keep-vcs')
  2807. && $installedFromVcs
  2808. && (
  2809. $input->getOption('remove-vcs')
  2810. || !$io->isInteractive()
  2811. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  2812. )
  2813. ) {
  2814. $finder = new Finder();
  2815. $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
  2816. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  2817. $finder->name($vcsName);
  2818. }
  2819. try {
  2820. $dirs = iterator_to_array($finder);
  2821. unset($finder);
  2822. foreach ($dirs as $dir) {
  2823. if (!$fs->removeDirectory($dir)) {
  2824. throw new \RuntimeException('Could not remove '.$dir);
  2825. }
  2826. }
  2827. } catch (\Exception $e) {
  2828. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  2829. }
  2830. $hasVcs = false;
  2831. }
  2832. if (!$hasVcs) {
  2833. $package = $composer->getPackage();
  2834. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2835. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  2836. foreach ($package->{'get'.$meta['method']}() as $link) {
  2837. if ($link->getPrettyConstraint() === 'self.version') {
  2838. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  2839. }
  2840. }
  2841. }
  2842. }
  2843. if ($noScripts === false) {
  2844. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  2845. }
  2846. chdir($oldCwd);
  2847. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  2848. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  2849. Silencer::call('rmdir', $vendorComposerDir);
  2850. $vendorDir = $config->get('vendor-dir');
  2851. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  2852. Silencer::call('rmdir', $vendorDir);
  2853. }
  2854. }
  2855. return 0;
  2856. }
  2857. 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)
  2858. {
  2859. if (!$secureHttp) {
  2860. $config->merge(array('config' => array('secure-http' => false)));
  2861. }
  2862. $parser = new VersionParser();
  2863. $requirements = $parser->parseNameVersionPairs(array($packageName));
  2864. $name = strtolower($requirements[0]['name']);
  2865. if (!$packageVersion && isset($requirements[0]['version'])) {
  2866. $packageVersion = $requirements[0]['version'];
  2867. }
  2868. if (null === $directory) {
  2869. $parts = explode("/", $name, 2);
  2870. $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  2871. }
  2872. $process = new ProcessExecutor($io);
  2873. $fs = new Filesystem($process);
  2874. if (!$fs->isAbsolutePath($directory)) {
  2875. $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
  2876. }
  2877. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
  2878. if (file_exists($directory)) {
  2879. if (!is_dir($directory)) {
  2880. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  2881. }
  2882. if (!$fs->isDirEmpty($directory)) {
  2883. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  2884. }
  2885. }
  2886. if (null === $stability) {
  2887. if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  2888. $stability = $match[1];
  2889. } else {
  2890. $stability = VersionParser::parseStability($packageVersion);
  2891. }
  2892. }
  2893. $stability = VersionParser::normalizeStability($stability);
  2894. if (!isset(BasePackage::$stabilities[$stability])) {
  2895. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  2896. }
  2897. $composer = Factory::create($io, $config->all(), $disablePlugins);
  2898. $config = $composer->getConfig();
  2899. $rm = $composer->getRepositoryManager();
  2900. $repositorySet = new RepositorySet($stability);
  2901. if (null === $repositories) {
  2902. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  2903. } else {
  2904. foreach ($repositories as $repo) {
  2905. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  2906. if (
  2907. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2908. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2909. ) {
  2910. continue;
  2911. }
  2912. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  2913. }
  2914. }
  2915. $platformOverrides = $config->get('platform') ?: array();
  2916. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  2917. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  2918. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $ignorePlatformReqs);
  2919. if (!$package) {
  2920. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  2921. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $packageVersion, $stability, true)) {
  2922. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  2923. }
  2924. throw new \InvalidArgumentException($errorMessage .'.');
  2925. }
  2926. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  2927. @mkdir($directory, 0777, true);
  2928. if ($realDir = realpath($directory)) {
  2929. pcntl_async_signals(true);
  2930. pcntl_signal(SIGINT, function () use ($realDir) {
  2931. $fs = new Filesystem();
  2932. $fs->removeDirectory($realDir);
  2933. exit(130);
  2934. });
  2935. }
  2936. }
  2937. if (function_exists('sapi_windows_set_ctrl_handler')) {
  2938. @mkdir($directory, 0777, true);
  2939. if ($realDir = realpath($directory)) {
  2940. sapi_windows_set_ctrl_handler(function () use ($realDir) {
  2941. $fs = new Filesystem();
  2942. $fs->removeDirectory($realDir);
  2943. exit(130);
  2944. });
  2945. }
  2946. }
  2947. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  2948. $package = $package->getAliasOf();
  2949. }
  2950. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  2951. if ($disablePlugins) {
  2952. $io->writeError('<info>Plugins have been disabled.</info>');
  2953. }
  2954. if ($package instanceof AliasPackage) {
  2955. $package = $package->getAliasOf();
  2956. }
  2957. $dm = $composer->getDownloadManager();
  2958. $dm->setPreferSource($preferSource)
  2959. ->setPreferDist($preferDist);
  2960. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  2961. $im = $composer->getInstallationManager();
  2962. $im->setOutputProgress(!$noProgress);
  2963. $im->addInstaller($projectInstaller);
  2964. $im->execute(new InstalledFilesystemRepository(new JsonFile('php://memory')), array(new InstallOperation($package)));
  2965. $im->notifyInstalls($io);
  2966. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  2967. $installedFromVcs = 'source' === $package->getInstallationSource();
  2968. $io->writeError('<info>Created project in ' . $directory . '</info>');
  2969. chdir($directory);
  2970. $_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion();
  2971. putenv('COMPOSER_ROOT_VERSION='.$_SERVER['COMPOSER_ROOT_VERSION']);
  2972. return $installedFromVcs;
  2973. }
  2974. }
  2975. <?php
  2976. namespace Composer\Command;
  2977. use Symfony\Component\Console\Input\InputInterface;
  2978. use Symfony\Component\Console\Output\OutputInterface;
  2979. class DependsCommand extends BaseDependencyCommand
  2980. {
  2981. protected function configure()
  2982. {
  2983. parent::configure();
  2984. $this
  2985. ->setName('depends')
  2986. ->setAliases(array('why'))
  2987. ->setDescription('Shows which packages cause the given package to be installed.')
  2988. ->setHelp(
  2989. <<<EOT
  2990. Displays detailed information about where a package is referenced.
  2991. <info>php composer.phar depends composer/composer</info>
  2992. Read more at https://getcomposer.org/doc/03-cli.md#depends-why-
  2993. EOT
  2994. )
  2995. ;
  2996. }
  2997. protected function execute(InputInterface $input, OutputInterface $output)
  2998. {
  2999. return parent::doExecute($input, $output);
  3000. }
  3001. }
  3002. <?php
  3003. namespace Composer\Command;
  3004. use Composer\Composer;
  3005. use Composer\Factory;
  3006. use Composer\Config;
  3007. use Composer\Downloader\TransportException;
  3008. use Composer\Repository\PlatformRepository;
  3009. use Composer\Plugin\CommandEvent;
  3010. use Composer\Plugin\PluginEvents;
  3011. use Composer\Util\ConfigValidator;
  3012. use Composer\Util\IniHelper;
  3013. use Composer\Util\ProcessExecutor;
  3014. use Composer\Util\HttpDownloader;
  3015. use Composer\Util\StreamContextFactory;
  3016. use Composer\SelfUpdate\Keys;
  3017. use Composer\SelfUpdate\Versions;
  3018. use Composer\IO\NullIO;
  3019. use Symfony\Component\Console\Input\InputInterface;
  3020. use Symfony\Component\Console\Output\OutputInterface;
  3021. class DiagnoseCommand extends BaseCommand
  3022. {
  3023. protected $httpDownloader;
  3024. protected $process;
  3025. protected $exitCode = 0;
  3026. protected function configure()
  3027. {
  3028. $this
  3029. ->setName('diagnose')
  3030. ->setDescription('Diagnoses the system to identify common errors.')
  3031. ->setHelp(
  3032. <<<EOT
  3033. The <info>diagnose</info> command checks common errors to help debugging problems.
  3034. The process exit code will be 1 in case of warnings and 2 for errors.
  3035. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  3036. EOT
  3037. )
  3038. ;
  3039. }
  3040. protected function execute(InputInterface $input, OutputInterface $output)
  3041. {
  3042. $composer = $this->getComposer(false);
  3043. $io = $this->getIO();
  3044. if ($composer) {
  3045. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  3046. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3047. $io->write('Checking composer.json: ', false);
  3048. $this->outputResult($this->checkComposerSchema());
  3049. }
  3050. if ($composer) {
  3051. $config = $composer->getConfig();
  3052. } else {
  3053. $config = Factory::createConfig();
  3054. }
  3055. $config->merge(array('config' => array('secure-http' => false)));
  3056. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  3057. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  3058. $this->process = new ProcessExecutor($io);
  3059. $io->write('Checking platform settings: ', false);
  3060. $this->outputResult($this->checkPlatform());
  3061. $io->write('Checking git settings: ', false);
  3062. $this->outputResult($this->checkGit());
  3063. $io->write('Checking http connectivity to packagist: ', false);
  3064. $this->outputResult($this->checkHttp('http', $config));
  3065. $io->write('Checking https connectivity to packagist: ', false);
  3066. $this->outputResult($this->checkHttp('https', $config));
  3067. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  3068. if (!empty($opts['http']['proxy'])) {
  3069. $io->write('Checking HTTP proxy: ', false);
  3070. $this->outputResult($this->checkHttpProxy());
  3071. }
  3072. if ($oauth = $config->get('github-oauth')) {
  3073. foreach ($oauth as $domain => $token) {
  3074. $io->write('Checking '.$domain.' oauth access: ', false);
  3075. $this->outputResult($this->checkGithubOauth($domain, $token));
  3076. }
  3077. } else {
  3078. $io->write('Checking github.com rate limit: ', false);
  3079. try {
  3080. $rate = $this->getGithubRateLimit('github.com');
  3081. if (!is_array($rate)) {
  3082. $this->outputResult($rate);
  3083. } elseif (10 > $rate['remaining']) {
  3084. $io->write('<warning>WARNING</warning>');
  3085. $io->write(sprintf(
  3086. '<comment>Github has a rate limit on their API. '
  3087. . 'You currently have <options=bold>%u</options=bold> '
  3088. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  3089. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  3090. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  3091. $rate['remaining'],
  3092. $rate['limit']
  3093. ));
  3094. } else {
  3095. $this->outputResult(true);
  3096. }
  3097. } catch (\Exception $e) {
  3098. if ($e instanceof TransportException && $e->getCode() === 401) {
  3099. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  3100. } else {
  3101. $this->outputResult($e);
  3102. }
  3103. }
  3104. }
  3105. $io->write('Checking disk free space: ', false);
  3106. $this->outputResult($this->checkDiskSpace($config));
  3107. if (strpos(__FILE__, 'phar:') === 0) {
  3108. $io->write('Checking pubkeys: ', false);
  3109. $this->outputResult($this->checkPubKeys($config));
  3110. $io->write('Checking composer version: ', false);
  3111. $this->outputResult($this->checkVersion($config));
  3112. }
  3113. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  3114. $platformOverrides = $config->get('platform') ?: array();
  3115. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3116. $phpPkg = $platformRepo->findPackage('php', '*');
  3117. $phpVersion = $phpPkg->getPrettyVersion();
  3118. if (false !== strpos($phpPkg->getDescription(), 'overridden')) {
  3119. $phpVersion .= ' - ' . $phpPkg->getDescription();
  3120. }
  3121. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  3122. if (defined('PHP_BINARY')) {
  3123. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  3124. }
  3125. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  3126. $io->write('cURL version: ' . $this->getCurlVersion());
  3127. $io->write('zip extension: ' . (extension_loaded('zip') ? '<info>OK</info>' : '<info>not loaded</info>'));
  3128. return $this->exitCode;
  3129. }
  3130. private function checkComposerSchema()
  3131. {
  3132. $validator = new ConfigValidator($this->getIO());
  3133. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  3134. if ($errors || $warnings) {
  3135. $messages = array(
  3136. 'error' => $errors,
  3137. 'warning' => $warnings,
  3138. );
  3139. $output = '';
  3140. foreach ($messages as $style => $msgs) {
  3141. foreach ($msgs as $msg) {
  3142. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  3143. }
  3144. }
  3145. return rtrim($output);
  3146. }
  3147. return true;
  3148. }
  3149. private function checkGit()
  3150. {
  3151. $this->process->execute('git config color.ui', $output);
  3152. if (strtolower(trim($output)) === 'always') {
  3153. 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>';
  3154. }
  3155. return true;
  3156. }
  3157. private function checkHttp($proto, Config $config)
  3158. {
  3159. $result = $this->checkConnectivity();
  3160. if ($result !== true) {
  3161. return $result;
  3162. }
  3163. $result = array();
  3164. if ($proto === 'https' && $config->get('disable-tls') === true) {
  3165. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  3166. }
  3167. try {
  3168. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  3169. } catch (TransportException $e) {
  3170. if ($hints = HttpDownloader::getExceptionHints($e)) {
  3171. foreach ($hints as $hint) {
  3172. $result[] = $hint;
  3173. }
  3174. }
  3175. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  3176. }
  3177. if (isset($tlsWarning)) {
  3178. $result[] = $tlsWarning;
  3179. }
  3180. if (count($result) > 0) {
  3181. return $result;
  3182. }
  3183. return true;
  3184. }
  3185. private function checkHttpProxy()
  3186. {
  3187. $result = $this->checkConnectivity();
  3188. if ($result !== true) {
  3189. return $result;
  3190. }
  3191. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  3192. try {
  3193. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  3194. $hash = reset($json['provider-includes']);
  3195. $hash = $hash['sha256'];
  3196. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  3197. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  3198. if (hash('sha256', $provider) !== $hash) {
  3199. return 'It seems that your proxy is modifying http traffic on the fly';
  3200. }
  3201. } catch (\Exception $e) {
  3202. return $e;
  3203. }
  3204. return true;
  3205. }
  3206. private function checkGithubOauth($domain, $token)
  3207. {
  3208. $result = $this->checkConnectivity();
  3209. if ($result !== true) {
  3210. return $result;
  3211. }
  3212. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3213. try {
  3214. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  3215. return $this->httpDownloader->get($url, array(
  3216. 'retry-auth-failure' => false,
  3217. )) ? true : 'Unexpected error';
  3218. } catch (\Exception $e) {
  3219. if ($e instanceof TransportException && $e->getCode() === 401) {
  3220. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  3221. }
  3222. return $e;
  3223. }
  3224. }
  3225. private function getGithubRateLimit($domain, $token = null)
  3226. {
  3227. $result = $this->checkConnectivity();
  3228. if ($result !== true) {
  3229. return $result;
  3230. }
  3231. if ($token) {
  3232. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3233. }
  3234. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  3235. $data = $this->httpDownloader->get($url, array('retry-auth-failure' => false))->decodeJson();
  3236. return $data['resources']['core'];
  3237. }
  3238. private function checkDiskSpace($config)
  3239. {
  3240. $minSpaceFree = 1024 * 1024;
  3241. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  3242. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  3243. ) {
  3244. return '<error>The disk hosting '.$dir.' is full</error>';
  3245. }
  3246. return true;
  3247. }
  3248. private function checkPubKeys($config)
  3249. {
  3250. $home = $config->get('home');
  3251. $errors = array();
  3252. $io = $this->getIO();
  3253. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  3254. $io->write('');
  3255. }
  3256. if (file_exists($home.'/keys.tags.pub')) {
  3257. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  3258. } else {
  3259. $errors[] = '<error>Missing pubkey for tags verification</error>';
  3260. }
  3261. if (file_exists($home.'/keys.dev.pub')) {
  3262. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  3263. } else {
  3264. $errors[] = '<error>Missing pubkey for dev verification</error>';
  3265. }
  3266. if ($errors) {
  3267. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  3268. }
  3269. return $errors ?: true;
  3270. }
  3271. private function checkVersion($config)
  3272. {
  3273. $result = $this->checkConnectivity();
  3274. if ($result !== true) {
  3275. return $result;
  3276. }
  3277. $versionsUtil = new Versions($config, $this->httpDownloader);
  3278. try {
  3279. $latest = $versionsUtil->getLatest();
  3280. } catch (\Exception $e) {
  3281. return $e;
  3282. }
  3283. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  3284. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  3285. }
  3286. return true;
  3287. }
  3288. private function getCurlVersion()
  3289. {
  3290. if (extension_loaded('curl')) {
  3291. if (!HttpDownloader::isCurlEnabled()) {
  3292. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  3293. }
  3294. $version = curl_version();
  3295. return '<comment>'.$version['version'].'</comment> '.
  3296. 'libz <comment>'.(isset($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  3297. 'ssl <comment>'.(isset($version['ssl_version']) ? $version['ssl_version'] : 'missing').'</comment>';
  3298. }
  3299. return '<error>missing, using php streams fallback, which reduces performance</error>';
  3300. }
  3301. private function outputResult($result)
  3302. {
  3303. $io = $this->getIO();
  3304. if (true === $result) {
  3305. $io->write('<info>OK</info>');
  3306. return;
  3307. }
  3308. $hadError = false;
  3309. $hadWarning = false;
  3310. if ($result instanceof \Exception) {
  3311. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  3312. }
  3313. if (!$result) {
  3314. $hadError = true;
  3315. } else {
  3316. if (!is_array($result)) {
  3317. $result = array($result);
  3318. }
  3319. foreach ($result as $message) {
  3320. if (false !== strpos($message, '<error>')) {
  3321. $hadError = true;
  3322. } elseif (false !== strpos($message, '<warning>')) {
  3323. $hadWarning = true;
  3324. }
  3325. }
  3326. }
  3327. if ($hadError) {
  3328. $io->write('<error>FAIL</error>');
  3329. $this->exitCode = max($this->exitCode, 2);
  3330. } elseif ($hadWarning) {
  3331. $io->write('<warning>WARNING</warning>');
  3332. $this->exitCode = max($this->exitCode, 1);
  3333. }
  3334. if ($result) {
  3335. foreach ($result as $message) {
  3336. $io->write($message);
  3337. }
  3338. }
  3339. }
  3340. private function checkPlatform()
  3341. {
  3342. $output = '';
  3343. $out = function ($msg, $style) use (&$output) {
  3344. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  3345. };
  3346. $errors = array();
  3347. $warnings = array();
  3348. $displayIniMessage = false;
  3349. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  3350. $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.';
  3351. if (!function_exists('json_decode')) {
  3352. $errors['json'] = true;
  3353. }
  3354. if (!extension_loaded('Phar')) {
  3355. $errors['phar'] = true;
  3356. }
  3357. if (!extension_loaded('filter')) {
  3358. $errors['filter'] = true;
  3359. }
  3360. if (!extension_loaded('hash')) {
  3361. $errors['hash'] = true;
  3362. }
  3363. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  3364. $errors['iconv_mbstring'] = true;
  3365. }
  3366. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  3367. $errors['allow_url_fopen'] = true;
  3368. }
  3369. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  3370. $errors['ioncube'] = ioncube_loader_version();
  3371. }
  3372. if (PHP_VERSION_ID < 50302) {
  3373. $errors['php'] = PHP_VERSION;
  3374. }
  3375. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  3376. $warnings['php'] = PHP_VERSION;
  3377. }
  3378. if (!extension_loaded('openssl')) {
  3379. $errors['openssl'] = true;
  3380. }
  3381. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  3382. $warnings['openssl_version'] = true;
  3383. }
  3384. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  3385. $warnings['apc_cli'] = true;
  3386. }
  3387. if (!extension_loaded('zlib')) {
  3388. $warnings['zlib'] = true;
  3389. }
  3390. ob_start();
  3391. phpinfo(INFO_GENERAL);
  3392. $phpinfo = ob_get_clean();
  3393. if (preg_match('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  3394. $configure = $match[1];
  3395. if (false !== strpos($configure, '--enable-sigchild')) {
  3396. $warnings['sigchild'] = true;
  3397. }
  3398. if (false !== strpos($configure, '--with-curlwrappers')) {
  3399. $warnings['curlwrappers'] = true;
  3400. }
  3401. }
  3402. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  3403. $warnings['xdebug_profile'] = true;
  3404. } elseif (extension_loaded('xdebug')) {
  3405. $warnings['xdebug_loaded'] = true;
  3406. }
  3407. if (defined('PHP_WINDOWS_VERSION_BUILD')
  3408. && (version_compare(PHP_VERSION, '7.2.23', '<')
  3409. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  3410. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  3411. $warnings['onedrive'] = PHP_VERSION;
  3412. }
  3413. if (!empty($errors)) {
  3414. foreach ($errors as $error => $current) {
  3415. switch ($error) {
  3416. case 'json':
  3417. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  3418. $text .= "Install it or recompile php without --disable-json";
  3419. break;
  3420. case 'phar':
  3421. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3422. $text .= "Install it or recompile php without --disable-phar";
  3423. break;
  3424. case 'filter':
  3425. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3426. $text .= "Install it or recompile php without --disable-filter";
  3427. break;
  3428. case 'hash':
  3429. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3430. $text .= "Install it or recompile php without --disable-hash";
  3431. break;
  3432. case 'iconv_mbstring':
  3433. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3434. $text .= "Install either of them or recompile php without --disable-iconv";
  3435. break;
  3436. case 'php':
  3437. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  3438. break;
  3439. case 'allow_url_fopen':
  3440. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3441. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3442. $text .= " allow_url_fopen = On";
  3443. $displayIniMessage = true;
  3444. break;
  3445. case 'ioncube':
  3446. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3447. $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;
  3448. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3449. $displayIniMessage = true;
  3450. break;
  3451. case 'openssl':
  3452. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3453. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3454. break;
  3455. default:
  3456. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  3457. }
  3458. $out($text, 'error');
  3459. }
  3460. $output .= PHP_EOL;
  3461. }
  3462. if (!empty($warnings)) {
  3463. foreach ($warnings as $warning => $current) {
  3464. switch ($warning) {
  3465. case 'apc_cli':
  3466. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3467. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3468. $text .= " apc.enable_cli = Off";
  3469. $displayIniMessage = true;
  3470. break;
  3471. case 'zlib':
  3472. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3473. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3474. $displayIniMessage = true;
  3475. break;
  3476. case 'sigchild':
  3477. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3478. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3479. $text .= " https://bugs.php.net/bug.php?id=22999";
  3480. break;
  3481. case 'curlwrappers':
  3482. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3483. $text .= " Recompile it without this flag if possible";
  3484. break;
  3485. case 'php':
  3486. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  3487. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  3488. break;
  3489. case 'openssl_version':
  3490. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3491. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3492. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3493. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3494. break;
  3495. case 'xdebug_loaded':
  3496. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3497. $text .= " Disabling it when using Composer is recommended.";
  3498. break;
  3499. case 'xdebug_profile':
  3500. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3501. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3502. $text .= " xdebug.profiler_enabled = 0";
  3503. $displayIniMessage = true;
  3504. break;
  3505. case 'onedrive':
  3506. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  3507. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  3508. break;
  3509. default:
  3510. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  3511. }
  3512. $out($text, 'comment');
  3513. }
  3514. }
  3515. if ($displayIniMessage) {
  3516. $out($iniMessage, 'comment');
  3517. }
  3518. return !$warnings && !$errors ? true : $output;
  3519. }
  3520. private function checkConnectivity()
  3521. {
  3522. if (!ini_get('allow_url_fopen')) {
  3523. return '<info>Skipped because allow_url_fopen is missing.</info>';
  3524. }
  3525. return true;
  3526. }
  3527. }
  3528. <?php
  3529. namespace Composer\Command;
  3530. use Composer\Plugin\CommandEvent;
  3531. use Composer\Plugin\PluginEvents;
  3532. use Symfony\Component\Console\Input\InputInterface;
  3533. use Symfony\Component\Console\Input\InputOption;
  3534. use Symfony\Component\Console\Output\OutputInterface;
  3535. class DumpAutoloadCommand extends BaseCommand
  3536. {
  3537. protected function configure()
  3538. {
  3539. $this
  3540. ->setName('dump-autoload')
  3541. ->setAliases(array('dumpautoload'))
  3542. ->setDescription('Dumps the autoloader.')
  3543. ->setDefinition(array(
  3544. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  3545. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3546. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3547. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3548. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  3549. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules.'),
  3550. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3551. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3552. ))
  3553. ->setHelp(
  3554. <<<EOT
  3555. <info>php composer.phar dump-autoload</info>
  3556. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
  3557. EOT
  3558. )
  3559. ;
  3560. }
  3561. protected function execute(InputInterface $input, OutputInterface $output)
  3562. {
  3563. $composer = $this->getComposer();
  3564. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3565. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3566. $installationManager = $composer->getInstallationManager();
  3567. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3568. $package = $composer->getPackage();
  3569. $config = $composer->getConfig();
  3570. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3571. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3572. $apcuPrefix = $input->getOption('apcu-prefix');
  3573. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  3574. if ($authoritative) {
  3575. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  3576. } elseif ($optimize) {
  3577. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  3578. } else {
  3579. $this->getIO()->write('<info>Generating autoload files</info>');
  3580. }
  3581. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  3582. $generator = $composer->getAutoloadGenerator();
  3583. $generator->setDevMode(!$input->getOption('no-dev'));
  3584. $generator->setClassMapAuthoritative($authoritative);
  3585. $generator->setApcu($apcu, $apcuPrefix);
  3586. $generator->setRunScripts(!$input->getOption('no-scripts'));
  3587. $generator->setIgnorePlatformRequirements($ignorePlatformReqs);
  3588. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3589. if ($authoritative) {
  3590. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3591. } elseif ($optimize) {
  3592. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3593. } else {
  3594. $this->getIO()->write('<info>Generated autoload files</info>');
  3595. }
  3596. return 0;
  3597. }
  3598. }
  3599. <?php
  3600. namespace Composer\Command;
  3601. use Symfony\Component\Console\Input\InputInterface;
  3602. use Symfony\Component\Console\Input\InputOption;
  3603. use Symfony\Component\Console\Output\OutputInterface;
  3604. use Symfony\Component\Console\Input\InputArgument;
  3605. class ExecCommand extends BaseCommand
  3606. {
  3607. protected function configure()
  3608. {
  3609. $this
  3610. ->setName('exec')
  3611. ->setDescription('Executes a vendored binary/script.')
  3612. ->setDefinition(array(
  3613. new InputOption('list', 'l', InputOption::VALUE_NONE),
  3614. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  3615. new InputArgument(
  3616. 'args',
  3617. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  3618. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  3619. ),
  3620. ))
  3621. ->setHelp(
  3622. <<<EOT
  3623. Executes a vendored binary/script.
  3624. Read more at https://getcomposer.org/doc/03-cli.md#exec
  3625. EOT
  3626. )
  3627. ;
  3628. }
  3629. protected function execute(InputInterface $input, OutputInterface $output)
  3630. {
  3631. $composer = $this->getComposer();
  3632. $binDir = $composer->getConfig()->get('bin-dir');
  3633. if ($input->getOption('list') || !$input->getArgument('binary')) {
  3634. $bins = glob($binDir . '/*');
  3635. $bins = array_merge($bins, array_map(function ($e) {
  3636. return "$e (local)";
  3637. }, $composer->getPackage()->getBinaries()));
  3638. if (!$bins) {
  3639. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  3640. }
  3641. $this->getIO()->write(
  3642. <<<EOT
  3643. <comment>Available binaries:</comment>
  3644. EOT
  3645. );
  3646. foreach ($bins as $bin) {
  3647. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  3648. continue;
  3649. }
  3650. $previousBin = $bin;
  3651. $bin = basename($bin);
  3652. $this->getIO()->write(
  3653. <<<EOT
  3654. <info>- $bin</info>
  3655. EOT
  3656. );
  3657. }
  3658. return 0;
  3659. }
  3660. $binary = $input->getArgument('binary');
  3661. $dispatcher = $composer->getEventDispatcher();
  3662. $dispatcher->addListener('__exec_command', $binary);
  3663. if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
  3664. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  3665. }
  3666. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {
  3667. try {
  3668. chdir($this->getApplication()->getInitialWorkingDirectory());
  3669. } catch (\Exception $e) {
  3670. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  3671. }
  3672. }
  3673. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  3674. }
  3675. }
  3676. <?php
  3677. namespace Composer\Command;
  3678. use Composer\Package\CompletePackageInterface;
  3679. use Composer\Package\AliasPackage;
  3680. use Composer\Package\BasePackage;
  3681. use Composer\Semver\Constraint\MatchAllConstraint;
  3682. use Composer\Repository\CompositeRepository;
  3683. use Symfony\Component\Console\Input\InputInterface;
  3684. use Symfony\Component\Console\Input\InputOption;
  3685. use Symfony\Component\Console\Output\OutputInterface;
  3686. class FundCommand extends BaseCommand
  3687. {
  3688. protected function configure()
  3689. {
  3690. $this->setName('fund')
  3691. ->setDescription('Discover how to help fund the maintenance of your dependencies.')
  3692. ;
  3693. }
  3694. protected function execute(InputInterface $input, OutputInterface $output)
  3695. {
  3696. $composer = $this->getComposer();
  3697. $repo = $composer->getRepositoryManager()->getLocalRepository();
  3698. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  3699. $fundings = array();
  3700. $packagesToLoad = array();
  3701. foreach ($repo->getPackages() as $package) {
  3702. if ($package instanceof AliasPackage) {
  3703. continue;
  3704. }
  3705. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  3706. }
  3707. $result = $remoteRepos->loadPackages($packagesToLoad, array('dev' => BasePackage::STABILITY_DEV), array());
  3708. foreach ($result['packages'] as $package) {
  3709. if (
  3710. !$package instanceof AliasPackage
  3711. && $package instanceof CompletePackageInterface
  3712. && $package->isDefaultBranch()
  3713. && $package->getFunding()
  3714. && isset($packagesToLoad[$package->getName()])
  3715. ) {
  3716. $fundings = $this->insertFundingData($fundings, $package);
  3717. unset($packagesToLoad[$package->getName()]);
  3718. }
  3719. }
  3720. foreach ($repo->getPackages() as $package) {
  3721. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  3722. continue;
  3723. }
  3724. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  3725. $fundings = $this->insertFundingData($fundings, $package);
  3726. }
  3727. }
  3728. ksort($fundings);
  3729. $io = $this->getIO();
  3730. if ($fundings) {
  3731. $prev = null;
  3732. $io->write('The following packages were found in your dependencies which publish funding information:');
  3733. foreach ($fundings as $vendor => $links) {
  3734. $io->write('');
  3735. $io->write(sprintf("<comment>%s</comment>", $vendor));
  3736. foreach ($links as $url => $packages) {
  3737. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  3738. if ($prev !== $line) {
  3739. $io->write($line);
  3740. $prev = $line;
  3741. }
  3742. $io->write(sprintf(' %s', $url));
  3743. }
  3744. }
  3745. $io->write("");
  3746. $io->write("Please consider following these links and sponsoring the work of package authors!");
  3747. $io->write("Thank you!");
  3748. } else {
  3749. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  3750. }
  3751. return 0;
  3752. }
  3753. private function insertFundingData(array $fundings, CompletePackageInterface $package)
  3754. {
  3755. foreach ($package->getFunding() as $fundingOption) {
  3756. list($vendor, $packageName) = explode('/', $package->getPrettyName());
  3757. if (empty($fundingOption['url'])) {
  3758. continue;
  3759. }
  3760. $url = $fundingOption['url'];
  3761. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && preg_match('{^https://github.com/([^/]+)$}', $url, $match)) {
  3762. $url = 'https://github.com/sponsors/'.$match[1];
  3763. }
  3764. $fundings[$vendor][$url][] = $packageName;
  3765. }
  3766. return $fundings;
  3767. }
  3768. }
  3769. <?php
  3770. namespace Composer\Command;
  3771. use Composer\Factory;
  3772. use Composer\Util\Filesystem;
  3773. use Symfony\Component\Console\Input\InputInterface;
  3774. use Symfony\Component\Console\Input\InputArgument;
  3775. use Symfony\Component\Console\Input\StringInput;
  3776. use Symfony\Component\Console\Output\OutputInterface;
  3777. class GlobalCommand extends BaseCommand
  3778. {
  3779. protected function configure()
  3780. {
  3781. $this
  3782. ->setName('global')
  3783. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  3784. ->setDefinition(array(
  3785. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  3786. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  3787. ))
  3788. ->setHelp(
  3789. <<<EOT
  3790. Use this command as a wrapper to run other Composer commands
  3791. within the global context of COMPOSER_HOME.
  3792. You can use this to install CLI utilities globally, all you need
  3793. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  3794. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  3795. and /home/<user>/.composer on unix systems.
  3796. If your system uses freedesktop.org standards, then it will first check
  3797. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  3798. Note: This path may vary depending on customizations to bin-dir in
  3799. composer.json or the environmental variable COMPOSER_BIN_DIR.
  3800. Read more at https://getcomposer.org/doc/03-cli.md#global
  3801. EOT
  3802. )
  3803. ;
  3804. }
  3805. public function run(InputInterface $input, OutputInterface $output)
  3806. {
  3807. $tokens = preg_split('{\s+}', $input->__toString());
  3808. $args = array();
  3809. foreach ($tokens as $token) {
  3810. if ($token && $token[0] !== '-') {
  3811. $args[] = $token;
  3812. if (count($args) >= 2) {
  3813. break;
  3814. }
  3815. }
  3816. }
  3817. if (count($args) < 2) {
  3818. return parent::run($input, $output);
  3819. }
  3820. if (getenv('COMPOSER')) {
  3821. putenv('COMPOSER');
  3822. unset($_SERVER['COMPOSER']);
  3823. }
  3824. $config = Factory::createConfig();
  3825. $home = $config->get('home');
  3826. if (!is_dir($home)) {
  3827. $fs = new Filesystem();
  3828. $fs->ensureDirectoryExists($home);
  3829. if (!is_dir($home)) {
  3830. throw new \RuntimeException('Could not create home directory');
  3831. }
  3832. }
  3833. try {
  3834. chdir($home);
  3835. } catch (\Exception $e) {
  3836. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  3837. }
  3838. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  3839. $input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  3840. $this->getApplication()->resetComposer();
  3841. return $this->getApplication()->run($input, $output);
  3842. }
  3843. public function isProxyCommand()
  3844. {
  3845. return true;
  3846. }
  3847. }
  3848. <?php
  3849. namespace Composer\Command;
  3850. use Composer\Package\CompletePackageInterface;
  3851. use Composer\Repository\RepositoryInterface;
  3852. use Composer\Repository\RootPackageRepository;
  3853. use Composer\Repository\RepositoryFactory;
  3854. use Composer\Util\Platform;
  3855. use Composer\Util\ProcessExecutor;
  3856. use Symfony\Component\Console\Input\InputArgument;
  3857. use Symfony\Component\Console\Input\InputOption;
  3858. use Symfony\Component\Console\Input\InputInterface;
  3859. use Symfony\Component\Console\Output\OutputInterface;
  3860. class HomeCommand extends BaseCommand
  3861. {
  3862. protected function configure()
  3863. {
  3864. $this
  3865. ->setName('browse')
  3866. ->setAliases(array('home'))
  3867. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  3868. ->setDefinition(array(
  3869. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  3870. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  3871. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  3872. ))
  3873. ->setHelp(
  3874. <<<EOT
  3875. The home command opens or shows a package's repository URL or
  3876. homepage in your default browser.
  3877. To open the homepage by default, use -H or --homepage.
  3878. To show instead of open the repository or homepage URL, use -s or --show.
  3879. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  3880. EOT
  3881. );
  3882. }
  3883. protected function execute(InputInterface $input, OutputInterface $output)
  3884. {
  3885. $repos = $this->initializeRepos();
  3886. $io = $this->getIO();
  3887. $return = 0;
  3888. $packages = $input->getArgument('packages');
  3889. if (!$packages) {
  3890. $io->writeError('No package specified, opening homepage for the root package');
  3891. $packages = array($this->getComposer()->getPackage()->getName());
  3892. }
  3893. foreach ($packages as $packageName) {
  3894. $handled = false;
  3895. $packageExists = false;
  3896. foreach ($repos as $repo) {
  3897. foreach ($repo->findPackages($packageName) as $package) {
  3898. $packageExists = true;
  3899. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  3900. $handled = true;
  3901. break 2;
  3902. }
  3903. }
  3904. }
  3905. if (!$packageExists) {
  3906. $return = 1;
  3907. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  3908. }
  3909. if (!$handled) {
  3910. $return = 1;
  3911. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  3912. }
  3913. }
  3914. return $return;
  3915. }
  3916. private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
  3917. {
  3918. $support = $package->getSupport();
  3919. $url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
  3920. if (!$url || $showHomepage) {
  3921. $url = $package->getHomepage();
  3922. }
  3923. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  3924. return false;
  3925. }
  3926. if ($showOnly) {
  3927. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  3928. } else {
  3929. $this->openBrowser($url);
  3930. }
  3931. return true;
  3932. }
  3933. private function openBrowser($url)
  3934. {
  3935. $url = ProcessExecutor::escape($url);
  3936. $process = new ProcessExecutor($this->getIO());
  3937. if (Platform::isWindows()) {
  3938. return $process->execute('start "web" explorer "' . $url . '"', $output);
  3939. }
  3940. $linux = $process->execute('which xdg-open', $output);
  3941. $osx = $process->execute('which open', $output);
  3942. if (0 === $linux) {
  3943. $process->execute('xdg-open ' . $url, $output);
  3944. } elseif (0 === $osx) {
  3945. $process->execute('open ' . $url, $output);
  3946. } else {
  3947. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  3948. }
  3949. }
  3950. private function initializeRepos()
  3951. {
  3952. $composer = $this->getComposer(false);
  3953. if ($composer) {
  3954. return array_merge(
  3955. array(new RootPackageRepository($composer->getPackage())),
  3956. array($composer->getRepositoryManager()->getLocalRepository()),
  3957. $composer->getRepositoryManager()->getRepositories()
  3958. );
  3959. }
  3960. return RepositoryFactory::defaultRepos($this->getIO());
  3961. }
  3962. }
  3963. <?php
  3964. namespace Composer\Command;
  3965. use Composer\Factory;
  3966. use Composer\Json\JsonFile;
  3967. use Composer\Package\BasePackage;
  3968. use Composer\Package\Package;
  3969. use Composer\Package\Version\VersionParser;
  3970. use Composer\Package\Version\VersionSelector;
  3971. use Composer\Repository\CompositeRepository;
  3972. use Composer\Repository\PlatformRepository;
  3973. use Composer\Repository\RepositoryFactory;
  3974. use Composer\Repository\RepositorySet;
  3975. use Composer\Util\ProcessExecutor;
  3976. use Symfony\Component\Console\Input\ArrayInput;
  3977. use Symfony\Component\Console\Input\InputInterface;
  3978. use Symfony\Component\Console\Input\InputOption;
  3979. use Symfony\Component\Console\Output\OutputInterface;
  3980. use Symfony\Component\Process\ExecutableFinder;
  3981. use Symfony\Component\Process\Process;
  3982. class InitCommand extends BaseCommand
  3983. {
  3984. protected $repos;
  3985. private $gitConfig;
  3986. private $repositorySets;
  3987. protected function configure()
  3988. {
  3989. $this
  3990. ->setName('init')
  3991. ->setDescription('Creates a basic composer.json file in current directory.')
  3992. ->setDefinition(array(
  3993. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  3994. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  3995. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  3996. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  3997. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  3998. 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"'),
  3999. 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"'),
  4000. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  4001. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  4002. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  4003. ))
  4004. ->setHelp(
  4005. <<<EOT
  4006. The <info>init</info> command creates a basic composer.json file
  4007. in the current directory.
  4008. <info>php composer.phar init</info>
  4009. Read more at https://getcomposer.org/doc/03-cli.md#init
  4010. EOT
  4011. )
  4012. ;
  4013. }
  4014. protected function execute(InputInterface $input, OutputInterface $output)
  4015. {
  4016. $io = $this->getIO();
  4017. $allowlist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license');
  4018. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  4019. if (isset($options['author'])) {
  4020. $options['authors'] = $this->formatAuthors($options['author']);
  4021. unset($options['author']);
  4022. }
  4023. $repositories = $input->getOption('repository');
  4024. if ($repositories) {
  4025. $config = Factory::createConfig($io);
  4026. foreach ($repositories as $repo) {
  4027. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  4028. }
  4029. }
  4030. if (isset($options['stability'])) {
  4031. $options['minimum-stability'] = $options['stability'];
  4032. unset($options['stability']);
  4033. }
  4034. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  4035. if (array() === $options['require']) {
  4036. $options['require'] = new \stdClass;
  4037. }
  4038. if (isset($options['require-dev'])) {
  4039. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  4040. if (array() === $options['require-dev']) {
  4041. $options['require-dev'] = new \stdClass;
  4042. }
  4043. }
  4044. $file = new JsonFile(Factory::getComposerFile());
  4045. $json = JsonFile::encode($options);
  4046. if ($input->isInteractive()) {
  4047. $io->writeError(array('', $json, ''));
  4048. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  4049. $io->writeError('<error>Command aborted</error>');
  4050. return 1;
  4051. }
  4052. } else {
  4053. if (json_encode($options) === '{"require":{}}') {
  4054. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  4055. }
  4056. $io->writeError('Writing composer.json');
  4057. }
  4058. $file->write($options);
  4059. if ($input->isInteractive() && is_dir('.git')) {
  4060. $ignoreFile = realpath('.gitignore');
  4061. if (false === $ignoreFile) {
  4062. $ignoreFile = realpath('.') . '/.gitignore';
  4063. }
  4064. if (!$this->hasVendorIgnore($ignoreFile)) {
  4065. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  4066. if ($io->askConfirmation($question)) {
  4067. $this->addVendorIgnore($ignoreFile);
  4068. }
  4069. }
  4070. }
  4071. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  4072. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  4073. $this->installDependencies($output);
  4074. }
  4075. return 0;
  4076. }
  4077. protected function interact(InputInterface $input, OutputInterface $output)
  4078. {
  4079. $git = $this->getGitConfig();
  4080. $io = $this->getIO();
  4081. $formatter = $this->getHelperSet()->get('formatter');
  4082. $repositories = $input->getOption('repository');
  4083. if ($repositories) {
  4084. $config = Factory::createConfig($io);
  4085. $repos = array(new PlatformRepository);
  4086. $createDefaultPackagistRepo = true;
  4087. foreach ($repositories as $repo) {
  4088. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4089. if (
  4090. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  4091. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  4092. ) {
  4093. $createDefaultPackagistRepo = false;
  4094. continue;
  4095. }
  4096. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig);
  4097. }
  4098. if ($createDefaultPackagistRepo) {
  4099. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  4100. 'type' => 'composer',
  4101. 'url' => 'https://repo.packagist.org',
  4102. ));
  4103. }
  4104. $this->repos = new CompositeRepository($repos);
  4105. unset($repos, $config, $repositories);
  4106. }
  4107. $io->writeError(array(
  4108. '',
  4109. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  4110. '',
  4111. ));
  4112. $io->writeError(array(
  4113. '',
  4114. 'This command will guide you through creating your composer.json config.',
  4115. '',
  4116. ));
  4117. $cwd = realpath(".");
  4118. if (!$name = $input->getOption('name')) {
  4119. $name = basename($cwd);
  4120. $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  4121. $name = strtolower($name);
  4122. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  4123. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  4124. } elseif (isset($git['github.user'])) {
  4125. $name = $git['github.user'] . '/' . $name;
  4126. } elseif (!empty($_SERVER['USERNAME'])) {
  4127. $name = $_SERVER['USERNAME'] . '/' . $name;
  4128. } elseif (!empty($_SERVER['USER'])) {
  4129. $name = $_SERVER['USER'] . '/' . $name;
  4130. } elseif (get_current_user()) {
  4131. $name = get_current_user() . '/' . $name;
  4132. } else {
  4133. $name .= '/' . $name;
  4134. }
  4135. $name = strtolower($name);
  4136. } else {
  4137. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $name)) {
  4138. throw new \InvalidArgumentException(
  4139. '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_.-]+'
  4140. );
  4141. }
  4142. }
  4143. $name = $io->askAndValidate(
  4144. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  4145. function ($value) use ($name) {
  4146. if (null === $value) {
  4147. return $name;
  4148. }
  4149. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  4150. throw new \InvalidArgumentException(
  4151. '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_.-]+'
  4152. );
  4153. }
  4154. return $value;
  4155. },
  4156. null,
  4157. $name
  4158. );
  4159. $input->setOption('name', $name);
  4160. $description = $input->getOption('description') ?: false;
  4161. $description = $io->ask(
  4162. 'Description [<comment>'.$description.'</comment>]: ',
  4163. $description
  4164. );
  4165. $input->setOption('description', $description);
  4166. if (null === $author = $input->getOption('author')) {
  4167. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  4168. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  4169. } elseif (isset($git['user.name'])) {
  4170. $author_name = $git['user.name'];
  4171. }
  4172. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  4173. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  4174. } elseif (isset($git['user.email'])) {
  4175. $author_email = $git['user.email'];
  4176. }
  4177. if (isset($author_name, $author_email)) {
  4178. $author = sprintf('%s <%s>', $author_name, $author_email);
  4179. }
  4180. }
  4181. $self = $this;
  4182. $author = $io->askAndValidate(
  4183. 'Author [<comment>'.$author.'</comment>, n to skip]: ',
  4184. function ($value) use ($self, $author) {
  4185. if ($value === 'n' || $value === 'no') {
  4186. return;
  4187. }
  4188. $value = $value ?: $author;
  4189. $author = $self->parseAuthorString($value);
  4190. return sprintf('%s <%s>', $author['name'], $author['email']);
  4191. },
  4192. null,
  4193. $author
  4194. );
  4195. $input->setOption('author', $author);
  4196. $minimumStability = $input->getOption('stability') ?: null;
  4197. $minimumStability = $io->askAndValidate(
  4198. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  4199. function ($value) use ($minimumStability) {
  4200. if (null === $value) {
  4201. return $minimumStability;
  4202. }
  4203. if (!isset(BasePackage::$stabilities[$value])) {
  4204. throw new \InvalidArgumentException(
  4205. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  4206. implode(', ', array_keys(BasePackage::$stabilities))
  4207. );
  4208. }
  4209. return $value;
  4210. },
  4211. null,
  4212. $minimumStability
  4213. );
  4214. $input->setOption('stability', $minimumStability);
  4215. $type = $input->getOption('type') ?: false;
  4216. $type = $io->ask(
  4217. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  4218. $type
  4219. );
  4220. $input->setOption('type', $type);
  4221. if (null === $license = $input->getOption('license')) {
  4222. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  4223. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  4224. }
  4225. }
  4226. $license = $io->ask(
  4227. 'License [<comment>'.$license.'</comment>]: ',
  4228. $license
  4229. );
  4230. $input->setOption('license', $license);
  4231. $io->writeError(array('', 'Define your dependencies.', ''));
  4232. $repos = $this->getRepos();
  4233. $preferredStability = $minimumStability ?: 'stable';
  4234. $platformRepo = null;
  4235. if ($repos instanceof CompositeRepository) {
  4236. foreach ($repos->getRepositories() as $candidateRepo) {
  4237. if ($candidateRepo instanceof PlatformRepository) {
  4238. $platformRepo = $candidateRepo;
  4239. break;
  4240. }
  4241. }
  4242. }
  4243. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  4244. $require = $input->getOption('require');
  4245. $requirements = array();
  4246. if ($require || $io->askConfirmation($question)) {
  4247. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  4248. }
  4249. $input->setOption('require', $requirements);
  4250. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  4251. $requireDev = $input->getOption('require-dev');
  4252. $devRequirements = array();
  4253. if ($requireDev || $io->askConfirmation($question)) {
  4254. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  4255. }
  4256. $input->setOption('require-dev', $devRequirements);
  4257. }
  4258. public function parseAuthorString($author)
  4259. {
  4260. if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
  4261. if ($this->isValidEmail($match['email'])) {
  4262. return array(
  4263. 'name' => trim($match['name']),
  4264. 'email' => $match['email'],
  4265. );
  4266. }
  4267. }
  4268. throw new \InvalidArgumentException(
  4269. 'Invalid author string. Must be in the format: '.
  4270. 'John Smith <john@example.com>'
  4271. );
  4272. }
  4273. protected function findPackages($name)
  4274. {
  4275. return $this->getRepos()->search($name);
  4276. }
  4277. protected function getRepos()
  4278. {
  4279. if (!$this->repos) {
  4280. $this->repos = new CompositeRepository(array_merge(
  4281. array(new PlatformRepository),
  4282. RepositoryFactory::defaultRepos($this->getIO())
  4283. ));
  4284. }
  4285. return $this->repos;
  4286. }
  4287. final protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), PlatformRepository $platformRepo = null, $preferredStability = 'stable', $checkProvidedVersions = true, $fixed = false)
  4288. {
  4289. if ($requires) {
  4290. $requires = $this->normalizeRequirements($requires);
  4291. $result = array();
  4292. $io = $this->getIO();
  4293. foreach ($requires as $requirement) {
  4294. if (!isset($requirement['version'])) {
  4295. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);
  4296. $requirement['version'] = $version;
  4297. $requirement['name'] = $name;
  4298. $io->writeError(sprintf(
  4299. 'Using version <info>%s</info> for <info>%s</info>',
  4300. $requirement['version'],
  4301. $requirement['name']
  4302. ));
  4303. } else {
  4304. list($name) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed);
  4305. $requirement['name'] = $name;
  4306. }
  4307. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  4308. }
  4309. return $result;
  4310. }
  4311. $versionParser = new VersionParser();
  4312. $composer = $this->getComposer(false);
  4313. $installedRepo = $composer ? $composer->getRepositoryManager()->getLocalRepository() : null;
  4314. $existingPackages = array();
  4315. if ($installedRepo) {
  4316. foreach ($installedRepo->getPackages() as $package) {
  4317. $existingPackages[] = $package->getName();
  4318. }
  4319. }
  4320. unset($composer, $installedRepo);
  4321. $io = $this->getIO();
  4322. while (null !== $package = $io->ask('Search for a package: ')) {
  4323. $matches = $this->findPackages($package);
  4324. if (count($matches)) {
  4325. foreach ($matches as $position => $foundPackage) {
  4326. if (in_array($foundPackage['name'], $existingPackages, true)) {
  4327. unset($matches[$position]);
  4328. }
  4329. }
  4330. $matches = array_values($matches);
  4331. $exactMatch = null;
  4332. $choices = array();
  4333. foreach ($matches as $position => $foundPackage) {
  4334. $abandoned = '';
  4335. if (isset($foundPackage['abandoned'])) {
  4336. if (is_string($foundPackage['abandoned'])) {
  4337. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  4338. } else {
  4339. $replacement = 'No replacement was suggested';
  4340. }
  4341. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  4342. }
  4343. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  4344. if ($foundPackage['name'] === $package) {
  4345. $exactMatch = true;
  4346. break;
  4347. }
  4348. }
  4349. if (!$exactMatch) {
  4350. $io->writeError(array(
  4351. '',
  4352. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  4353. '',
  4354. ));
  4355. $io->writeError($choices);
  4356. $io->writeError('');
  4357. $validator = function ($selection) use ($matches, $versionParser) {
  4358. if ('' === $selection) {
  4359. return false;
  4360. }
  4361. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  4362. $package = $matches[(int) $selection];
  4363. return $package['name'];
  4364. }
  4365. if (preg_match('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  4366. if (isset($packageMatches['version'])) {
  4367. $versionParser->parseConstraints($packageMatches['version']);
  4368. return $packageMatches['name'].' '.$packageMatches['version'];
  4369. }
  4370. return $packageMatches['name'];
  4371. }
  4372. throw new \Exception('Not a valid selection');
  4373. };
  4374. $package = $io->askAndValidate(
  4375. 'Enter package # to add, or the complete package name if it is not listed: ',
  4376. $validator,
  4377. 3,
  4378. false
  4379. );
  4380. }
  4381. if (false !== $package && false === strpos($package, ' ')) {
  4382. $validator = function ($input) {
  4383. $input = trim($input);
  4384. return $input ?: false;
  4385. };
  4386. $constraint = $io->askAndValidate(
  4387. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  4388. $validator,
  4389. 3,
  4390. false
  4391. );
  4392. if (false === $constraint) {
  4393. list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
  4394. $io->writeError(sprintf(
  4395. 'Using version <info>%s</info> for <info>%s</info>',
  4396. $constraint,
  4397. $package
  4398. ));
  4399. }
  4400. $package .= ' '.$constraint;
  4401. }
  4402. if (false !== $package) {
  4403. $requires[] = $package;
  4404. $existingPackages[] = substr($package, 0, strpos($package, ' '));
  4405. }
  4406. }
  4407. }
  4408. return $requires;
  4409. }
  4410. protected function formatAuthors($author)
  4411. {
  4412. return array($this->parseAuthorString($author));
  4413. }
  4414. protected function getGitConfig()
  4415. {
  4416. if (null !== $this->gitConfig) {
  4417. return $this->gitConfig;
  4418. }
  4419. $finder = new ExecutableFinder();
  4420. $gitBin = $finder->find('git');
  4421. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  4422. $cmd = new Process(array($gitBin, 'config', '-l'));
  4423. } else {
  4424. $cmd = new Process(sprintf('%s config -l', ProcessExecutor::escape($gitBin)));
  4425. }
  4426. $cmd->run();
  4427. if ($cmd->isSuccessful()) {
  4428. $this->gitConfig = array();
  4429. preg_match_all('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches, PREG_SET_ORDER);
  4430. foreach ($matches as $match) {
  4431. $this->gitConfig[$match[1]] = $match[2];
  4432. }
  4433. return $this->gitConfig;
  4434. }
  4435. return $this->gitConfig = array();
  4436. }
  4437. protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
  4438. {
  4439. if (!file_exists($ignoreFile)) {
  4440. return false;
  4441. }
  4442. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  4443. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  4444. foreach ($lines as $line) {
  4445. if (preg_match($pattern, $line)) {
  4446. return true;
  4447. }
  4448. }
  4449. return false;
  4450. }
  4451. protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
  4452. {
  4453. $contents = "";
  4454. if (file_exists($ignoreFile)) {
  4455. $contents = file_get_contents($ignoreFile);
  4456. if (strpos($contents, "\n") !== 0) {
  4457. $contents .= "\n";
  4458. }
  4459. }
  4460. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  4461. }
  4462. protected function isValidEmail($email)
  4463. {
  4464. if (!function_exists('filter_var')) {
  4465. return true;
  4466. }
  4467. if (PHP_VERSION_ID < 50303) {
  4468. return true;
  4469. }
  4470. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  4471. }
  4472. private function getRepositorySet(InputInterface $input, $minimumStability = null)
  4473. {
  4474. $key = $minimumStability ?: 'default';
  4475. if (!isset($this->repositorySets[$key])) {
  4476. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?: $this->getMinimumStability($input));
  4477. $repositorySet->addRepository($this->getRepos());
  4478. }
  4479. return $this->repositorySets[$key];
  4480. }
  4481. private function getMinimumStability(InputInterface $input)
  4482. {
  4483. if ($input->hasOption('stability')) {
  4484. return VersionParser::normalizeStability($input->getOption('stability') ?: 'stable');
  4485. }
  4486. $file = Factory::getComposerFile();
  4487. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  4488. if (!empty($composer['minimum-stability'])) {
  4489. return VersionParser::normalizeStability($composer['minimum-stability']);
  4490. }
  4491. }
  4492. return 'stable';
  4493. }
  4494. private function findBestVersionAndNameForPackage(InputInterface $input, $name, PlatformRepository $platformRepo = null, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null, $fixed = null)
  4495. {
  4496. $ignorePlatformReqs = false;
  4497. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  4498. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4499. }
  4500. $versionSelector = new VersionSelector($this->getRepositorySet($input, $minimumStability), $platformRepo);
  4501. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs);
  4502. if (!$package) {
  4503. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($name, $ignorePlatformReqs))) && PlatformRepository::isPlatformPackage($name)) {
  4504. return array($name, $requiredVersion ?: '*');
  4505. }
  4506. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, true)) {
  4507. throw new \InvalidArgumentException(sprintf(
  4508. 'Package %s%s has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version',
  4509. $name,
  4510. $requiredVersion ? ' at version '.$requiredVersion : ''
  4511. ));
  4512. }
  4513. if ($package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  4514. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4515. throw new \InvalidArgumentException(
  4516. '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.'
  4517. );
  4518. }
  4519. throw new \InvalidArgumentException(sprintf(
  4520. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  4521. $name,
  4522. $this->getMinimumStability($input)
  4523. ));
  4524. }
  4525. if ($requiredVersion && $package = $versionSelector->findBestCandidate($name, null, $preferredStability, $ignorePlatformReqs)) {
  4526. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, false, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4527. throw new \InvalidArgumentException(
  4528. '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.'
  4529. );
  4530. }
  4531. throw new \InvalidArgumentException(sprintf(
  4532. 'Could not find package %s in a version matching %s',
  4533. $name,
  4534. $requiredVersion
  4535. ));
  4536. }
  4537. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, null, $preferredStability, true)) {
  4538. throw new \InvalidArgumentException(sprintf(
  4539. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version',
  4540. $name
  4541. ));
  4542. }
  4543. $similar = $this->findSimilar($name);
  4544. if ($similar) {
  4545. throw new \InvalidArgumentException(sprintf(
  4546. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  4547. $name,
  4548. implode("\n ", $similar)
  4549. ));
  4550. }
  4551. throw new \InvalidArgumentException(sprintf(
  4552. '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).',
  4553. $name,
  4554. $this->getMinimumStability($input)
  4555. ));
  4556. }
  4557. return array(
  4558. $package->getPrettyName(),
  4559. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  4560. );
  4561. }
  4562. private function findSimilar($package)
  4563. {
  4564. try {
  4565. $results = $this->repos->search($package);
  4566. } catch (\Exception $e) {
  4567. return array();
  4568. }
  4569. $similarPackages = array();
  4570. $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
  4571. foreach ($results as $result) {
  4572. if ($installedRepo->findPackage($result['name'], '*')) {
  4573. continue;
  4574. }
  4575. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  4576. }
  4577. asort($similarPackages);
  4578. return array_keys(array_slice($similarPackages, 0, 5));
  4579. }
  4580. private function installDependencies($output)
  4581. {
  4582. try {
  4583. $installCommand = $this->getApplication()->find('install');
  4584. $installCommand->run(new ArrayInput(array()), $output);
  4585. } catch (\Exception $e) {
  4586. $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.');
  4587. }
  4588. }
  4589. private function hasDependencies($options)
  4590. {
  4591. $requires = (array) $options['require'];
  4592. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  4593. return !empty($requires) || !empty($devRequires);
  4594. }
  4595. }
  4596. <?php
  4597. namespace Composer\Command;
  4598. use Composer\Installer;
  4599. use Composer\Plugin\CommandEvent;
  4600. use Composer\Plugin\PluginEvents;
  4601. use Symfony\Component\Console\Input\InputInterface;
  4602. use Symfony\Component\Console\Input\InputOption;
  4603. use Symfony\Component\Console\Input\InputArgument;
  4604. use Symfony\Component\Console\Output\OutputInterface;
  4605. class InstallCommand extends BaseCommand
  4606. {
  4607. protected function configure()
  4608. {
  4609. $this
  4610. ->setName('install')
  4611. ->setAliases(array('i'))
  4612. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  4613. ->setDefinition(array(
  4614. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4615. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  4616. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4617. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4618. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  4619. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4620. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  4621. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4622. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4623. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  4624. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  4625. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4626. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4627. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4628. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4629. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4630. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4631. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  4632. ))
  4633. ->setHelp(
  4634. <<<EOT
  4635. The <info>install</info> command reads the composer.lock file from
  4636. the current directory, processes it, and downloads and installs all the
  4637. libraries and dependencies outlined in that file. If the file does not
  4638. exist it will look for composer.json and do the same.
  4639. <info>php composer.phar install</info>
  4640. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  4641. EOT
  4642. )
  4643. ;
  4644. }
  4645. protected function execute(InputInterface $input, OutputInterface $output)
  4646. {
  4647. $io = $this->getIO();
  4648. if ($input->getOption('dev')) {
  4649. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  4650. }
  4651. if ($input->getOption('no-suggest')) {
  4652. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  4653. }
  4654. if ($args = $input->getArgument('packages')) {
  4655. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  4656. return 1;
  4657. }
  4658. if ($input->getOption('no-install')) {
  4659. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  4660. return 1;
  4661. }
  4662. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4663. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  4664. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4665. $install = Installer::create($io, $composer);
  4666. $config = $composer->getConfig();
  4667. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  4668. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  4669. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4670. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  4671. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  4672. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4673. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  4674. $install
  4675. ->setDryRun($input->getOption('dry-run'))
  4676. ->setVerbose($input->getOption('verbose'))
  4677. ->setPreferSource($preferSource)
  4678. ->setPreferDist($preferDist)
  4679. ->setDevMode(!$input->getOption('no-dev'))
  4680. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  4681. ->setRunScripts(!$input->getOption('no-scripts'))
  4682. ->setOptimizeAutoloader($optimize)
  4683. ->setClassMapAuthoritative($authoritative)
  4684. ->setApcuAutoloader($apcu, $apcuPrefix)
  4685. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  4686. ;
  4687. if ($input->getOption('no-plugins')) {
  4688. $install->disablePlugins();
  4689. }
  4690. return $install->run();
  4691. }
  4692. }
  4693. <?php
  4694. namespace Composer\Command;
  4695. use Composer\Json\JsonFile;
  4696. use Composer\Plugin\CommandEvent;
  4697. use Composer\Plugin\PluginEvents;
  4698. use Composer\Package\PackageInterface;
  4699. use Composer\Repository\RepositoryInterface;
  4700. use Symfony\Component\Console\Helper\Table;
  4701. use Symfony\Component\Console\Input\InputInterface;
  4702. use Symfony\Component\Console\Input\InputOption;
  4703. use Symfony\Component\Console\Output\OutputInterface;
  4704. use Symfony\Component\Console\Style\SymfonyStyle;
  4705. class LicensesCommand extends BaseCommand
  4706. {
  4707. protected function configure()
  4708. {
  4709. $this
  4710. ->setName('licenses')
  4711. ->setDescription('Shows information about licenses of dependencies.')
  4712. ->setDefinition(array(
  4713. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  4714. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4715. ))
  4716. ->setHelp(
  4717. <<<EOT
  4718. The license command displays detailed information about the licenses of
  4719. the installed dependencies.
  4720. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  4721. EOT
  4722. )
  4723. ;
  4724. }
  4725. protected function execute(InputInterface $input, OutputInterface $output)
  4726. {
  4727. $composer = $this->getComposer();
  4728. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  4729. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4730. $root = $composer->getPackage();
  4731. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4732. if ($input->getOption('no-dev')) {
  4733. $packages = $this->filterRequiredPackages($repo, $root);
  4734. } else {
  4735. $packages = $this->appendPackages($repo->getPackages(), array());
  4736. }
  4737. ksort($packages);
  4738. $io = $this->getIO();
  4739. switch ($format = $input->getOption('format')) {
  4740. case 'text':
  4741. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  4742. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  4743. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  4744. $io->write('Dependencies:');
  4745. $io->write('');
  4746. $table = new Table($output);
  4747. $table->setStyle('compact');
  4748. $tableStyle = $table->getStyle();
  4749. if (method_exists($tableStyle, 'setVerticalBorderChars')) {
  4750. $tableStyle->setVerticalBorderChars('');
  4751. } else {
  4752. $tableStyle->setVerticalBorderChar('');
  4753. }
  4754. $tableStyle->setCellRowContentFormat('%s ');
  4755. $table->setHeaders(array('Name', 'Version', 'License'));
  4756. foreach ($packages as $package) {
  4757. $table->addRow(array(
  4758. $package->getPrettyName(),
  4759. $package->getFullPrettyVersion(),
  4760. implode(', ', $package->getLicense()) ?: 'none',
  4761. ));
  4762. }
  4763. $table->render();
  4764. break;
  4765. case 'json':
  4766. $dependencies = array();
  4767. foreach ($packages as $package) {
  4768. $dependencies[$package->getPrettyName()] = array(
  4769. 'version' => $package->getFullPrettyVersion(),
  4770. 'license' => $package->getLicense(),
  4771. );
  4772. }
  4773. $io->write(JsonFile::encode(array(
  4774. 'name' => $root->getPrettyName(),
  4775. 'version' => $root->getFullPrettyVersion(),
  4776. 'license' => $root->getLicense(),
  4777. 'dependencies' => $dependencies,
  4778. )));
  4779. break;
  4780. case 'summary':
  4781. $usedLicenses = array();
  4782. foreach ($packages as $package) {
  4783. $license = $package->getLicense();
  4784. $licenseName = $license[0];
  4785. if (!isset($usedLicenses[$licenseName])) {
  4786. $usedLicenses[$licenseName] = 0;
  4787. }
  4788. $usedLicenses[$licenseName]++;
  4789. }
  4790. arsort($usedLicenses, SORT_NUMERIC);
  4791. $rows = array();
  4792. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  4793. $rows[] = array($usedLicense, $numberOfDependencies);
  4794. }
  4795. $symfonyIo = new SymfonyStyle($input, $output);
  4796. $symfonyIo->table(
  4797. array('License', 'Number of dependencies'),
  4798. $rows
  4799. );
  4800. break;
  4801. default:
  4802. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4803. }
  4804. return 0;
  4805. }
  4806. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  4807. {
  4808. $requires = array_keys($package->getRequires());
  4809. $packageListNames = array_keys($bucket);
  4810. $packages = array_filter(
  4811. $repo->getPackages(),
  4812. function ($package) use ($requires, $packageListNames) {
  4813. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  4814. }
  4815. );
  4816. $bucket = $this->appendPackages($packages, $bucket);
  4817. foreach ($packages as $package) {
  4818. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  4819. }
  4820. return $bucket;
  4821. }
  4822. public function appendPackages(array $packages, array $bucket)
  4823. {
  4824. foreach ($packages as $package) {
  4825. $bucket[$package->getName()] = $package;
  4826. }
  4827. return $bucket;
  4828. }
  4829. }
  4830. <?php
  4831. namespace Composer\Command;
  4832. use Symfony\Component\Console\Input\InputInterface;
  4833. use Symfony\Component\Console\Input\InputArgument;
  4834. use Symfony\Component\Console\Input\ArrayInput;
  4835. use Symfony\Component\Console\Input\InputOption;
  4836. use Symfony\Component\Console\Output\OutputInterface;
  4837. class OutdatedCommand extends ShowCommand
  4838. {
  4839. protected function configure()
  4840. {
  4841. $this
  4842. ->setName('outdated')
  4843. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  4844. ->setDefinition(array(
  4845. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  4846. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  4847. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  4848. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  4849. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  4850. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  4851. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  4852. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4853. 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.'),
  4854. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4855. ))
  4856. ->setHelp(
  4857. <<<EOT
  4858. The outdated command is just a proxy for `composer show -l`
  4859. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  4860. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  4861. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  4862. compatibility breaks according to semver, so upgrade when you can but it
  4863. may involve work.
  4864. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  4865. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  4866. EOT
  4867. )
  4868. ;
  4869. }
  4870. protected function execute(InputInterface $input, OutputInterface $output)
  4871. {
  4872. $args = array(
  4873. 'command' => 'show',
  4874. '--latest' => true,
  4875. );
  4876. if (!$input->getOption('all')) {
  4877. $args['--outdated'] = true;
  4878. }
  4879. if ($input->getOption('direct')) {
  4880. $args['--direct'] = true;
  4881. }
  4882. if ($input->getArgument('package')) {
  4883. $args['package'] = $input->getArgument('package');
  4884. }
  4885. if ($input->getOption('strict')) {
  4886. $args['--strict'] = true;
  4887. }
  4888. if ($input->getOption('minor-only')) {
  4889. $args['--minor-only'] = true;
  4890. }
  4891. if ($input->getOption('locked')) {
  4892. $args['--locked'] = true;
  4893. }
  4894. if ($input->getOption('no-dev')) {
  4895. $args['--no-dev'] = true;
  4896. }
  4897. $args['--format'] = $input->getOption('format');
  4898. $args['--ignore'] = $input->getOption('ignore');
  4899. $input = new ArrayInput($args);
  4900. return $this->getApplication()->run($input, $output);
  4901. }
  4902. public function isProxyCommand()
  4903. {
  4904. return true;
  4905. }
  4906. }
  4907. <?php
  4908. namespace Composer\Command;
  4909. use Symfony\Component\Console\Input\InputInterface;
  4910. use Symfony\Component\Console\Output\OutputInterface;
  4911. class ProhibitsCommand extends BaseDependencyCommand
  4912. {
  4913. protected function configure()
  4914. {
  4915. parent::configure();
  4916. $this
  4917. ->setName('prohibits')
  4918. ->setAliases(array('why-not'))
  4919. ->setDescription('Shows which packages prevent the given package from being installed.')
  4920. ->setHelp(
  4921. <<<EOT
  4922. Displays detailed information about why a package cannot be installed.
  4923. <info>php composer.phar prohibits composer/composer</info>
  4924. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  4925. EOT
  4926. )
  4927. ;
  4928. }
  4929. protected function execute(InputInterface $input, OutputInterface $output)
  4930. {
  4931. return parent::doExecute($input, $output, true);
  4932. }
  4933. }
  4934. <?php
  4935. namespace Composer\Command;
  4936. use Composer\Config\JsonConfigSource;
  4937. use Composer\DependencyResolver\Request;
  4938. use Composer\Installer;
  4939. use Composer\Plugin\CommandEvent;
  4940. use Composer\Plugin\PluginEvents;
  4941. use Composer\Json\JsonFile;
  4942. use Composer\Factory;
  4943. use Symfony\Component\Console\Input\InputInterface;
  4944. use Symfony\Component\Console\Input\InputOption;
  4945. use Symfony\Component\Console\Input\InputArgument;
  4946. use Symfony\Component\Console\Output\OutputInterface;
  4947. use Composer\Package\BasePackage;
  4948. class RemoveCommand extends BaseCommand
  4949. {
  4950. protected function configure()
  4951. {
  4952. $this
  4953. ->setName('remove')
  4954. ->setDescription('Removes a package from the require or require-dev.')
  4955. ->setDefinition(array(
  4956. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  4957. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  4958. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4959. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4960. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  4961. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  4962. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4963. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  4964. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  4965. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  4966. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  4967. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  4968. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  4969. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4970. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4971. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4972. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4973. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4974. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4975. ))
  4976. ->setHelp(
  4977. <<<EOT
  4978. The <info>remove</info> command removes a package from the current
  4979. list of installed packages
  4980. <info>php composer.phar remove</info>
  4981. Read more at https://getcomposer.org/doc/03-cli.md#remove
  4982. EOT
  4983. )
  4984. ;
  4985. }
  4986. protected function interact(InputInterface $input, OutputInterface $output)
  4987. {
  4988. if ($input->getOption('unused')) {
  4989. $composer = $this->getComposer();
  4990. $locker = $composer->getLocker();
  4991. if (!$locker->isLocked()) {
  4992. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  4993. }
  4994. $lockedPackages = $locker->getLockedRepository()->getPackages();
  4995. $required = array();
  4996. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  4997. $required[$link->getTarget()] = true;
  4998. }
  4999. do {
  5000. $found = false;
  5001. foreach ($lockedPackages as $index => $package) {
  5002. foreach ($package->getNames() as $name) {
  5003. if (isset($required[$name])) {
  5004. foreach ($package->getRequires() as $link) {
  5005. $required[$link->getTarget()] = true;
  5006. }
  5007. $found = true;
  5008. unset($lockedPackages[$index]);
  5009. break;
  5010. }
  5011. }
  5012. }
  5013. } while ($found);
  5014. $unused = array();
  5015. foreach ($lockedPackages as $package) {
  5016. $unused[] = $package->getName();
  5017. }
  5018. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  5019. if (!$input->getArgument('packages')) {
  5020. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  5021. $this->setCode(function () {
  5022. return 0;
  5023. });
  5024. }
  5025. }
  5026. }
  5027. protected function execute(InputInterface $input, OutputInterface $output)
  5028. {
  5029. $packages = $input->getArgument('packages');
  5030. $packages = array_map('strtolower', $packages);
  5031. $file = Factory::getComposerFile();
  5032. $jsonFile = new JsonFile($file);
  5033. $composer = $jsonFile->read();
  5034. $composerBackup = file_get_contents($jsonFile->getPath());
  5035. $json = new JsonConfigSource($jsonFile);
  5036. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5037. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5038. $io = $this->getIO();
  5039. if ($input->getOption('update-with-dependencies')) {
  5040. $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>');
  5041. }
  5042. foreach (array('require', 'require-dev') as $linkType) {
  5043. if (isset($composer[$linkType])) {
  5044. foreach ($composer[$linkType] as $name => $version) {
  5045. $composer[$linkType][strtolower($name)] = $name;
  5046. }
  5047. }
  5048. }
  5049. $dryRun = $input->getOption('dry-run');
  5050. $toRemove = array();
  5051. foreach ($packages as $package) {
  5052. if (isset($composer[$type][$package])) {
  5053. if ($dryRun) {
  5054. $toRemove[$type][] = $composer[$type][$package];
  5055. } else {
  5056. $json->removeLink($type, $composer[$type][$package]);
  5057. }
  5058. } elseif (isset($composer[$altType][$package])) {
  5059. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5060. if ($io->isInteractive()) {
  5061. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5062. if ($dryRun) {
  5063. $toRemove[$altType][] = $composer[$altType][$package];
  5064. } else {
  5065. $json->removeLink($altType, $composer[$altType][$package]);
  5066. }
  5067. }
  5068. }
  5069. } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  5070. foreach ($matches as $matchedPackage) {
  5071. if ($dryRun) {
  5072. $toRemove[$type][] = $matchedPackage;
  5073. } else {
  5074. $json->removeLink($type, $matchedPackage);
  5075. }
  5076. }
  5077. } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  5078. foreach ($matches as $matchedPackage) {
  5079. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5080. if ($io->isInteractive()) {
  5081. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5082. if ($dryRun) {
  5083. $toRemove[$altType][] = $matchedPackage;
  5084. } else {
  5085. $json->removeLink($altType, $matchedPackage);
  5086. }
  5087. }
  5088. }
  5089. }
  5090. } else {
  5091. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5092. }
  5093. }
  5094. $io->writeError('<info>'.$file.' has been updated</info>');
  5095. if ($input->getOption('no-update')) {
  5096. return 0;
  5097. }
  5098. $this->resetComposer();
  5099. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5100. if ($dryRun) {
  5101. $rootPackage = $composer->getPackage();
  5102. $links = array(
  5103. 'require' => $rootPackage->getRequires(),
  5104. 'require-dev' => $rootPackage->getDevRequires(),
  5105. );
  5106. foreach ($toRemove as $type => $names) {
  5107. foreach ($names as $name) {
  5108. unset($links[$type][$name]);
  5109. }
  5110. }
  5111. $rootPackage->setRequires($links['require']);
  5112. $rootPackage->setDevRequires($links['require-dev']);
  5113. }
  5114. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5115. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5116. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5117. $install = Installer::create($io, $composer);
  5118. $updateDevMode = !$input->getOption('update-no-dev');
  5119. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5120. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5121. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5122. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5123. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5124. $flags = '';
  5125. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5126. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5127. $flags .= ' --with-all-dependencies';
  5128. } elseif ($input->getOption('no-update-with-dependencies')) {
  5129. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5130. $flags .= ' --with-dependencies';
  5131. }
  5132. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5133. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5134. $install
  5135. ->setVerbose($input->getOption('verbose'))
  5136. ->setDevMode($updateDevMode)
  5137. ->setOptimizeAutoloader($optimize)
  5138. ->setClassMapAuthoritative($authoritative)
  5139. ->setApcuAutoloader($apcu, $apcuPrefix)
  5140. ->setUpdate(true)
  5141. ->setInstall(!$input->getOption('no-install'))
  5142. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5143. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5144. ->setRunScripts(!$input->getOption('no-scripts'))
  5145. ->setDryRun($dryRun)
  5146. ;
  5147. if ($composer->getLocker()->isLocked()) {
  5148. $install->setUpdateAllowList($packages);
  5149. }
  5150. $status = $install->run();
  5151. if ($status !== 0) {
  5152. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5153. file_put_contents($jsonFile->getPath(), $composerBackup);
  5154. }
  5155. if (!$dryRun) {
  5156. foreach ($packages as $package) {
  5157. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5158. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5159. return 2;
  5160. }
  5161. }
  5162. }
  5163. return $status;
  5164. }
  5165. }
  5166. <?php
  5167. namespace Composer\Command;
  5168. use Composer\DependencyResolver\Request;
  5169. use Symfony\Component\Console\Input\InputInterface;
  5170. use Symfony\Component\Console\Input\InputArgument;
  5171. use Symfony\Component\Console\Input\InputOption;
  5172. use Symfony\Component\Console\Output\OutputInterface;
  5173. use Composer\Factory;
  5174. use Composer\Installer;
  5175. use Composer\Json\JsonFile;
  5176. use Composer\Json\JsonManipulator;
  5177. use Composer\Package\Version\VersionParser;
  5178. use Composer\Package\Loader\ArrayLoader;
  5179. use Composer\Package\BasePackage;
  5180. use Composer\Plugin\CommandEvent;
  5181. use Composer\Plugin\PluginEvents;
  5182. use Composer\Repository\CompositeRepository;
  5183. use Composer\Repository\PlatformRepository;
  5184. use Composer\IO\IOInterface;
  5185. use Composer\Util\Silencer;
  5186. class RequireCommand extends InitCommand
  5187. {
  5188. private $newlyCreated;
  5189. private $firstRequire;
  5190. private $json;
  5191. private $file;
  5192. private $composerBackup;
  5193. private $lock;
  5194. private $lockBackup;
  5195. protected function configure()
  5196. {
  5197. $this
  5198. ->setName('require')
  5199. ->setDescription('Adds required packages to your composer.json and installs them.')
  5200. ->setDefinition(array(
  5201. 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"'),
  5202. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5203. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5204. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5205. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  5206. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5207. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5208. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5209. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5210. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5211. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5212. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5213. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5214. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5215. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5216. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5217. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5218. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5219. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5220. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5221. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5222. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5223. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5224. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5225. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5226. ))
  5227. ->setHelp(
  5228. <<<EOT
  5229. The require command adds required packages to your composer.json and installs them.
  5230. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5231. matches to require.
  5232. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5233. If you do not want to install the new dependencies immediately you can call it with --no-update
  5234. Read more at https://getcomposer.org/doc/03-cli.md#require
  5235. EOT
  5236. )
  5237. ;
  5238. }
  5239. protected function execute(InputInterface $input, OutputInterface $output)
  5240. {
  5241. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  5242. pcntl_async_signals(true);
  5243. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  5244. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  5245. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  5246. }
  5247. $this->file = Factory::getComposerFile();
  5248. $io = $this->getIO();
  5249. if ($input->getOption('no-suggest')) {
  5250. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5251. }
  5252. $this->newlyCreated = !file_exists($this->file);
  5253. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  5254. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  5255. return 1;
  5256. }
  5257. if (!is_readable($this->file) && false === Silencer::call('file_get_contents', $this->file)) {
  5258. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  5259. return 1;
  5260. }
  5261. if (filesize($this->file) === 0) {
  5262. file_put_contents($this->file, "{\n}\n");
  5263. }
  5264. $this->json = new JsonFile($this->file);
  5265. $this->lock = Factory::getLockFile($this->file);
  5266. $this->composerBackup = file_get_contents($this->json->getPath());
  5267. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  5268. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  5269. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  5270. return 1;
  5271. }
  5272. if ($input->getOption('fixed') === true) {
  5273. $config = $this->json->read();
  5274. $packageType = empty($config['type']) ? 'library' : $config['type'];
  5275. if ($packageType !== 'project') {
  5276. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  5277. if (empty($config['type'])) {
  5278. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  5279. }
  5280. return 1;
  5281. }
  5282. }
  5283. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5284. $repos = $composer->getRepositoryManager()->getRepositories();
  5285. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5286. $this->repos = new CompositeRepository(array_merge(
  5287. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  5288. $repos
  5289. ));
  5290. if ($composer->getPackage()->getPreferStable()) {
  5291. $preferredStability = 'stable';
  5292. } else {
  5293. $preferredStability = $composer->getPackage()->getMinimumStability();
  5294. }
  5295. try {
  5296. $requirements = $this->determineRequirements(
  5297. $input,
  5298. $output,
  5299. $input->getArgument('packages'),
  5300. $platformRepo,
  5301. $preferredStability,
  5302. !$input->getOption('no-update'),
  5303. $input->getOption('fixed')
  5304. );
  5305. } catch (\Exception $e) {
  5306. if ($this->newlyCreated) {
  5307. throw new \RuntimeException('No composer.json present in the current directory, this may be the cause of the following exception.', 0, $e);
  5308. }
  5309. throw $e;
  5310. }
  5311. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  5312. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  5313. $requirements = $this->formatRequirements($requirements);
  5314. $versionParser = new VersionParser();
  5315. foreach ($requirements as $package => $constraint) {
  5316. if (strtolower($package) === $composer->getPackage()->getName()) {
  5317. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  5318. return 1;
  5319. }
  5320. $versionParser->parseConstraints($constraint);
  5321. }
  5322. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  5323. $this->firstRequire = $this->newlyCreated;
  5324. if (!$this->firstRequire) {
  5325. $composerDefinition = $this->json->read();
  5326. if (empty($composerDefinition['require']) && empty($composerDefinition['require-dev'])) {
  5327. $this->firstRequire = true;
  5328. }
  5329. }
  5330. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  5331. $composerDefinition = $this->json->read();
  5332. foreach ($requirements as $package => $version) {
  5333. $composerDefinition[$requireKey][$package] = $version;
  5334. unset($composerDefinition[$removeKey][$package]);
  5335. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  5336. unset($composerDefinition[$removeKey]);
  5337. }
  5338. }
  5339. $this->json->write($composerDefinition);
  5340. }
  5341. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  5342. if ($input->getOption('no-update')) {
  5343. return 0;
  5344. }
  5345. try {
  5346. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  5347. } catch (\Exception $e) {
  5348. $this->revertComposerFile(false);
  5349. throw $e;
  5350. }
  5351. }
  5352. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
  5353. {
  5354. $this->resetComposer();
  5355. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5356. if ($input->getOption('dry-run')) {
  5357. $rootPackage = $composer->getPackage();
  5358. $links = array(
  5359. 'require' => $rootPackage->getRequires(),
  5360. 'require-dev' => $rootPackage->getDevRequires(),
  5361. );
  5362. $loader = new ArrayLoader();
  5363. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['description'], $requirements);
  5364. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  5365. foreach ($requirements as $package => $constraint) {
  5366. unset($links[$removeKey][$package]);
  5367. }
  5368. $rootPackage->setRequires($links['require']);
  5369. $rootPackage->setDevRequires($links['require-dev']);
  5370. }
  5371. $updateDevMode = !$input->getOption('update-no-dev');
  5372. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5373. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5374. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5375. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5376. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5377. $flags = '';
  5378. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5379. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5380. $flags .= ' --with-all-dependencies';
  5381. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  5382. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5383. $flags .= ' --with-dependencies';
  5384. }
  5385. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  5386. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  5387. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5388. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5389. $install = Installer::create($io, $composer);
  5390. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5391. $install
  5392. ->setDryRun($input->getOption('dry-run'))
  5393. ->setVerbose($input->getOption('verbose'))
  5394. ->setPreferSource($input->getOption('prefer-source'))
  5395. ->setPreferDist($input->getOption('prefer-dist'))
  5396. ->setDevMode($updateDevMode)
  5397. ->setRunScripts(!$input->getOption('no-scripts'))
  5398. ->setOptimizeAutoloader($optimize)
  5399. ->setClassMapAuthoritative($authoritative)
  5400. ->setApcuAutoloader($apcu, $apcuPrefix)
  5401. ->setUpdate(true)
  5402. ->setInstall(!$input->getOption('no-install'))
  5403. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5404. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5405. ->setPreferStable($input->getOption('prefer-stable'))
  5406. ->setPreferLowest($input->getOption('prefer-lowest'))
  5407. ;
  5408. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  5409. $install->setUpdateAllowList(array_keys($requirements));
  5410. }
  5411. $status = $install->run();
  5412. if ($status !== 0) {
  5413. $this->revertComposerFile(false);
  5414. }
  5415. return $status;
  5416. }
  5417. private function updateFileCleanly($json, array $new, $requireKey, $removeKey, $sortPackages)
  5418. {
  5419. $contents = file_get_contents($json->getPath());
  5420. $manipulator = new JsonManipulator($contents);
  5421. foreach ($new as $package => $constraint) {
  5422. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  5423. return false;
  5424. }
  5425. if (!$manipulator->removeSubNode($removeKey, $package)) {
  5426. return false;
  5427. }
  5428. }
  5429. $manipulator->removeMainKeyIfEmpty($removeKey);
  5430. file_put_contents($json->getPath(), $manipulator->getContents());
  5431. return true;
  5432. }
  5433. protected function interact(InputInterface $input, OutputInterface $output)
  5434. {
  5435. return;
  5436. }
  5437. public function revertComposerFile($hardExit = true)
  5438. {
  5439. $io = $this->getIO();
  5440. if ($this->newlyCreated) {
  5441. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  5442. unlink($this->json->getPath());
  5443. if (file_exists($this->lock)) {
  5444. unlink($this->lock);
  5445. }
  5446. } else {
  5447. $msg = ' to its ';
  5448. if ($this->lockBackup) {
  5449. $msg = ' and '.$this->lock.' to their ';
  5450. }
  5451. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  5452. file_put_contents($this->json->getPath(), $this->composerBackup);
  5453. if ($this->lockBackup) {
  5454. file_put_contents($this->lock, $this->lockBackup);
  5455. }
  5456. }
  5457. if ($hardExit) {
  5458. exit(1);
  5459. }
  5460. }
  5461. }
  5462. <?php
  5463. namespace Composer\Command;
  5464. use Composer\Script\Event as ScriptEvent;
  5465. use Composer\Script\ScriptEvents;
  5466. use Composer\Util\ProcessExecutor;
  5467. use Symfony\Component\Console\Input\InputInterface;
  5468. use Symfony\Component\Console\Input\InputOption;
  5469. use Symfony\Component\Console\Input\InputArgument;
  5470. use Symfony\Component\Console\Output\OutputInterface;
  5471. class RunScriptCommand extends BaseCommand
  5472. {
  5473. protected $scriptEvents = array(
  5474. ScriptEvents::PRE_INSTALL_CMD,
  5475. ScriptEvents::POST_INSTALL_CMD,
  5476. ScriptEvents::PRE_UPDATE_CMD,
  5477. ScriptEvents::POST_UPDATE_CMD,
  5478. ScriptEvents::PRE_STATUS_CMD,
  5479. ScriptEvents::POST_STATUS_CMD,
  5480. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  5481. ScriptEvents::POST_CREATE_PROJECT_CMD,
  5482. ScriptEvents::PRE_ARCHIVE_CMD,
  5483. ScriptEvents::POST_ARCHIVE_CMD,
  5484. ScriptEvents::PRE_AUTOLOAD_DUMP,
  5485. ScriptEvents::POST_AUTOLOAD_DUMP,
  5486. );
  5487. protected function configure()
  5488. {
  5489. $this
  5490. ->setName('run-script')
  5491. ->setAliases(array('run'))
  5492. ->setDescription('Runs the scripts defined in composer.json.')
  5493. ->setDefinition(array(
  5494. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  5495. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5496. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  5497. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5498. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5499. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  5500. ))
  5501. ->setHelp(
  5502. <<<EOT
  5503. The <info>run-script</info> command runs scripts defined in composer.json:
  5504. <info>php composer.phar run-script post-update-cmd</info>
  5505. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5506. EOT
  5507. )
  5508. ;
  5509. }
  5510. protected function execute(InputInterface $input, OutputInterface $output)
  5511. {
  5512. if ($input->getOption('list')) {
  5513. return $this->listScripts($output);
  5514. }
  5515. if (!$input->getArgument('script')) {
  5516. throw new \RuntimeException('Missing required argument "script"');
  5517. }
  5518. $script = $input->getArgument('script');
  5519. if (!in_array($script, $this->scriptEvents)) {
  5520. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  5521. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  5522. }
  5523. }
  5524. $composer = $this->getComposer();
  5525. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  5526. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  5527. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  5528. if (!$hasListeners) {
  5529. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  5530. }
  5531. $args = $input->getArgument('args');
  5532. if (null !== $timeout = $input->getOption('timeout')) {
  5533. if (!ctype_digit($timeout)) {
  5534. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  5535. }
  5536. ProcessExecutor::setTimeout((int) $timeout);
  5537. }
  5538. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  5539. }
  5540. protected function listScripts(OutputInterface $output)
  5541. {
  5542. $scripts = $this->getComposer()->getPackage()->getScripts();
  5543. if (!count($scripts)) {
  5544. return 0;
  5545. }
  5546. $io = $this->getIO();
  5547. $io->writeError('<info>scripts:</info>');
  5548. $table = array();
  5549. foreach ($scripts as $name => $script) {
  5550. $description = '';
  5551. try {
  5552. $cmd = $this->getApplication()->find($name);
  5553. if ($cmd instanceof ScriptAliasCommand) {
  5554. $description = $cmd->getDescription();
  5555. }
  5556. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  5557. }
  5558. $table[] = array(' '.$name, $description);
  5559. }
  5560. $this->renderTable($table, $output);
  5561. return 0;
  5562. }
  5563. }
  5564. <?php
  5565. namespace Composer\Command;
  5566. use Symfony\Component\Console\Input\InputInterface;
  5567. use Symfony\Component\Console\Input\InputOption;
  5568. use Symfony\Component\Console\Input\InputArgument;
  5569. use Symfony\Component\Console\Output\OutputInterface;
  5570. class ScriptAliasCommand extends BaseCommand
  5571. {
  5572. private $script;
  5573. private $description;
  5574. public function __construct($script, $description)
  5575. {
  5576. $this->script = $script;
  5577. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  5578. parent::__construct();
  5579. }
  5580. protected function configure()
  5581. {
  5582. $this
  5583. ->setName($this->script)
  5584. ->setDescription($this->description)
  5585. ->setDefinition(array(
  5586. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5587. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5588. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5589. ))
  5590. ->setHelp(
  5591. <<<EOT
  5592. The <info>run-script</info> command runs scripts defined in composer.json:
  5593. <info>php composer.phar run-script post-update-cmd</info>
  5594. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5595. EOT
  5596. )
  5597. ;
  5598. }
  5599. protected function execute(InputInterface $input, OutputInterface $output)
  5600. {
  5601. $composer = $this->getComposer();
  5602. $args = $input->getArguments();
  5603. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  5604. }
  5605. }
  5606. <?php
  5607. namespace Composer\Command;
  5608. use Composer\Factory;
  5609. use Symfony\Component\Console\Input\InputInterface;
  5610. use Symfony\Component\Console\Input\InputArgument;
  5611. use Symfony\Component\Console\Input\InputOption;
  5612. use Symfony\Component\Console\Output\OutputInterface;
  5613. use Composer\Repository\CompositeRepository;
  5614. use Composer\Repository\PlatformRepository;
  5615. use Composer\Repository\RepositoryInterface;
  5616. use Composer\Plugin\CommandEvent;
  5617. use Composer\Plugin\PluginEvents;
  5618. class SearchCommand extends BaseCommand
  5619. {
  5620. protected $matches;
  5621. protected $lowMatches = array();
  5622. protected $tokens;
  5623. protected $output;
  5624. protected $onlyName;
  5625. protected function configure()
  5626. {
  5627. $this
  5628. ->setName('search')
  5629. ->setDescription('Searches for packages.')
  5630. ->setDefinition(array(
  5631. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in name'),
  5632. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  5633. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  5634. ))
  5635. ->setHelp(
  5636. <<<EOT
  5637. The search command searches for packages by its name
  5638. <info>php composer.phar search symfony composer</info>
  5639. Read more at https://getcomposer.org/doc/03-cli.md#search
  5640. EOT
  5641. )
  5642. ;
  5643. }
  5644. protected function execute(InputInterface $input, OutputInterface $output)
  5645. {
  5646. $platformRepo = new PlatformRepository;
  5647. $io = $this->getIO();
  5648. if (!($composer = $this->getComposer(false))) {
  5649. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  5650. }
  5651. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5652. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  5653. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  5654. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  5655. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5656. $onlyName = $input->getOption('only-name');
  5657. $type = $input->getOption('type') ?: null;
  5658. $flags = $onlyName ? RepositoryInterface::SEARCH_NAME : RepositoryInterface::SEARCH_FULLTEXT;
  5659. $results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags, $type);
  5660. foreach ($results as $result) {
  5661. $io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
  5662. }
  5663. return 0;
  5664. }
  5665. }
  5666. <?php
  5667. namespace Composer\Command;
  5668. use Composer\Composer;
  5669. use Composer\Factory;
  5670. use Composer\Config;
  5671. use Composer\Util\Filesystem;
  5672. use Composer\Util\Platform;
  5673. use Composer\SelfUpdate\Keys;
  5674. use Composer\SelfUpdate\Versions;
  5675. use Composer\IO\IOInterface;
  5676. use Composer\Downloader\FilesystemException;
  5677. use Symfony\Component\Console\Input\InputInterface;
  5678. use Symfony\Component\Console\Input\InputOption;
  5679. use Symfony\Component\Console\Input\InputArgument;
  5680. use Symfony\Component\Console\Output\OutputInterface;
  5681. use Symfony\Component\Finder\Finder;
  5682. class SelfUpdateCommand extends BaseCommand
  5683. {
  5684. const HOMEPAGE = 'getcomposer.org';
  5685. const OLD_INSTALL_EXT = '-old.phar';
  5686. protected function configure()
  5687. {
  5688. $this
  5689. ->setName('self-update')
  5690. ->setAliases(array('selfupdate'))
  5691. ->setDescription('Updates composer.phar to the latest version.')
  5692. ->setDefinition(array(
  5693. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  5694. 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'),
  5695. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  5696. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5697. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  5698. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  5699. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  5700. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  5701. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  5702. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  5703. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  5704. ))
  5705. ->setHelp(
  5706. <<<EOT
  5707. The <info>self-update</info> command checks getcomposer.org for newer
  5708. versions of composer and if found, installs the latest.
  5709. <info>php composer.phar self-update</info>
  5710. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  5711. EOT
  5712. )
  5713. ;
  5714. }
  5715. protected function execute(InputInterface $input, OutputInterface $output)
  5716. {
  5717. $config = Factory::createConfig();
  5718. if ($config->get('disable-tls') === true) {
  5719. $baseUrl = 'http://' . self::HOMEPAGE;
  5720. } else {
  5721. $baseUrl = 'https://' . self::HOMEPAGE;
  5722. }
  5723. $io = $this->getIO();
  5724. $httpDownloader = Factory::createHttpDownloader($io, $config);
  5725. $versionsUtil = new Versions($config, $httpDownloader);
  5726. $requestedChannel = null;
  5727. foreach (Versions::$channels as $channel) {
  5728. if ($input->getOption($channel)) {
  5729. $requestedChannel = $channel;
  5730. $versionsUtil->setChannel($channel);
  5731. break;
  5732. }
  5733. }
  5734. if ($input->getOption('set-channel-only')) {
  5735. return 0;
  5736. }
  5737. $cacheDir = $config->get('cache-dir');
  5738. $rollbackDir = $config->get('data-dir');
  5739. $home = $config->get('home');
  5740. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  5741. if ($input->getOption('update-keys')) {
  5742. return $this->fetchKeys($io, $config);
  5743. }
  5744. if (!file_exists($localFilename)) {
  5745. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  5746. }
  5747. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  5748. if (!is_writable($tmpDir)) {
  5749. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  5750. }
  5751. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  5752. $composeUser = posix_getpwuid(posix_geteuid());
  5753. $homeOwner = posix_getpwuid(fileowner($home));
  5754. if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  5755. $io->writeError('<warning>You are running composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  5756. }
  5757. }
  5758. if ($input->getOption('rollback')) {
  5759. return $this->rollback($output, $rollbackDir, $localFilename);
  5760. }
  5761. $latest = $versionsUtil->getLatest();
  5762. $latestStable = $versionsUtil->getLatest('stable');
  5763. try {
  5764. $latestPreview = $versionsUtil->getLatest('preview');
  5765. } catch (\UnexpectedValueException $e) {
  5766. $latestPreview = $latestStable;
  5767. }
  5768. $latestVersion = $latest['version'];
  5769. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  5770. $currentMajorVersion = preg_replace('{^(\d+).*}', '$1', Composer::getVersion());
  5771. $updateMajorVersion = preg_replace('{^(\d+).*}', '$1', $updateVersion);
  5772. $previewMajorVersion = preg_replace('{^(\d+).*}', '$1', $latestPreview['version']);
  5773. if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
  5774. if ($currentMajorVersion < $updateMajorVersion) {
  5775. $skippedVersion = $updateVersion;
  5776. $versionsUtil->setChannel($currentMajorVersion);
  5777. $latest = $versionsUtil->getLatest();
  5778. $latestStable = $versionsUtil->getLatest('stable');
  5779. $latestVersion = $latest['version'];
  5780. $updateVersion = $latestVersion;
  5781. $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>');
  5782. } elseif ($currentMajorVersion < $previewMajorVersion) {
  5783. $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>');
  5784. }
  5785. }
  5786. if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
  5787. $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>');
  5788. }
  5789. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  5790. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  5791. return 1;
  5792. }
  5793. $channelString = $versionsUtil->getChannel();
  5794. if (is_numeric($channelString)) {
  5795. $channelString .= '.x';
  5796. }
  5797. if (Composer::VERSION === $updateVersion) {
  5798. $io->writeError(
  5799. sprintf(
  5800. '<info>You are already using composer version %s (%s channel).</info>',
  5801. $updateVersion,
  5802. $channelString
  5803. )
  5804. );
  5805. if ($input->getOption('clean-backups')) {
  5806. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  5807. }
  5808. return 0;
  5809. }
  5810. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp.phar';
  5811. $backupFile = sprintf(
  5812. '%s/%s-%s%s',
  5813. $rollbackDir,
  5814. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  5815. preg_replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  5816. self::OLD_INSTALL_EXT
  5817. );
  5818. $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion);
  5819. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  5820. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  5821. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  5822. $io->writeError(' ', false);
  5823. $httpDownloader->copy($remoteFilename, $tempFilename);
  5824. $io->writeError('');
  5825. if (!file_exists($tempFilename) || !$signature) {
  5826. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  5827. return 1;
  5828. }
  5829. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  5830. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  5831. } else {
  5832. if (!extension_loaded('openssl')) {
  5833. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  5834. . '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.');
  5835. }
  5836. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  5837. if (!file_exists($sigFile)) {
  5838. file_put_contents(
  5839. $home.'/keys.dev.pub',
  5840. <<<DEVPUBKEY
  5841. -----BEGIN PUBLIC KEY-----
  5842. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  5843. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  5844. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  5845. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  5846. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  5847. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  5848. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  5849. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  5850. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  5851. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  5852. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  5853. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  5854. -----END PUBLIC KEY-----
  5855. DEVPUBKEY
  5856. );
  5857. file_put_contents(
  5858. $home.'/keys.tags.pub',
  5859. <<<TAGSPUBKEY
  5860. -----BEGIN PUBLIC KEY-----
  5861. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  5862. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  5863. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  5864. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  5865. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  5866. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  5867. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  5868. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  5869. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  5870. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  5871. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  5872. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  5873. -----END PUBLIC KEY-----
  5874. TAGSPUBKEY
  5875. );
  5876. }
  5877. $pubkeyid = openssl_pkey_get_public($sigFile);
  5878. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  5879. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  5880. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  5881. }
  5882. $signature = json_decode($signature, true);
  5883. $signature = base64_decode($signature['sha384']);
  5884. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  5885. if (PHP_VERSION_ID < 80000) {
  5886. openssl_free_key($pubkeyid);
  5887. }
  5888. if (!$verified) {
  5889. 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');
  5890. }
  5891. }
  5892. if ($input->getOption('clean-backups')) {
  5893. $this->cleanBackups($rollbackDir);
  5894. }
  5895. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  5896. @unlink($tempFilename);
  5897. return 1;
  5898. }
  5899. if (file_exists($backupFile)) {
  5900. $io->writeError(sprintf(
  5901. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  5902. Composer::VERSION
  5903. ));
  5904. } else {
  5905. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  5906. }
  5907. return 0;
  5908. }
  5909. protected function fetchKeys(IOInterface $io, Config $config)
  5910. {
  5911. if (!$io->isInteractive()) {
  5912. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  5913. }
  5914. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  5915. $validator = function ($value) {
  5916. if (!preg_match('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  5917. throw new \UnexpectedValueException('Invalid input');
  5918. }
  5919. return trim($value)."\n";
  5920. };
  5921. $devKey = '';
  5922. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  5923. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  5924. while ($line = $io->ask('')) {
  5925. $devKey .= trim($line)."\n";
  5926. if (trim($line) === '-----END PUBLIC KEY-----') {
  5927. break;
  5928. }
  5929. }
  5930. }
  5931. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  5932. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5933. $tagsKey = '';
  5934. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  5935. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  5936. while ($line = $io->ask('')) {
  5937. $tagsKey .= trim($line)."\n";
  5938. if (trim($line) === '-----END PUBLIC KEY-----') {
  5939. break;
  5940. }
  5941. }
  5942. }
  5943. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  5944. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5945. $io->write('Public keys stored in '.$config->get('home'));
  5946. }
  5947. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  5948. {
  5949. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  5950. if (!$rollbackVersion) {
  5951. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  5952. }
  5953. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  5954. if (!is_file($oldFile)) {
  5955. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  5956. }
  5957. if (!is_readable($oldFile)) {
  5958. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  5959. }
  5960. $io = $this->getIO();
  5961. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  5962. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  5963. return 1;
  5964. }
  5965. return 0;
  5966. }
  5967. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  5968. {
  5969. $io = $this->getIO();
  5970. @chmod($newFilename, fileperms($localFilename));
  5971. if (!$this->validatePhar($newFilename, $error)) {
  5972. $io->writeError('<error>The '.($backupTarget ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  5973. if ($backupTarget) {
  5974. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  5975. }
  5976. return false;
  5977. }
  5978. if ($backupTarget) {
  5979. @copy($localFilename, $backupTarget);
  5980. }
  5981. try {
  5982. rename($newFilename, $localFilename);
  5983. return true;
  5984. } catch (\Exception $e) {
  5985. if (!is_writable(dirname($localFilename))
  5986. && $io->isInteractive()
  5987. && $this->isWindowsNonAdminUser()) {
  5988. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  5989. }
  5990. $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
  5991. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  5992. }
  5993. }
  5994. protected function cleanBackups($rollbackDir, $except = null)
  5995. {
  5996. $finder = $this->getOldInstallationFinder($rollbackDir);
  5997. $io = $this->getIO();
  5998. $fs = new Filesystem;
  5999. foreach ($finder as $file) {
  6000. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  6001. continue;
  6002. }
  6003. $file = (string) $file;
  6004. $io->writeError('<info>Removing: '.$file.'</info>');
  6005. $fs->remove($file);
  6006. }
  6007. }
  6008. protected function getLastBackupVersion($rollbackDir)
  6009. {
  6010. $finder = $this->getOldInstallationFinder($rollbackDir);
  6011. $finder->sortByName();
  6012. $files = iterator_to_array($finder);
  6013. if (count($files)) {
  6014. return basename(end($files), self::OLD_INSTALL_EXT);
  6015. }
  6016. return false;
  6017. }
  6018. protected function getOldInstallationFinder($rollbackDir)
  6019. {
  6020. return Finder::create()
  6021. ->depth(0)
  6022. ->files()
  6023. ->name('*' . self::OLD_INSTALL_EXT)
  6024. ->in($rollbackDir);
  6025. }
  6026. protected function validatePhar($pharFile, &$error)
  6027. {
  6028. if (ini_get('phar.readonly')) {
  6029. return true;
  6030. }
  6031. try {
  6032. $phar = new \Phar($pharFile);
  6033. unset($phar);
  6034. $result = true;
  6035. } catch (\Exception $e) {
  6036. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  6037. throw $e;
  6038. }
  6039. $error = $e->getMessage();
  6040. $result = false;
  6041. }
  6042. return $result;
  6043. }
  6044. protected function isWindowsNonAdminUser()
  6045. {
  6046. if (!Platform::isWindows()) {
  6047. return false;
  6048. }
  6049. exec('fltmc.exe filters', $output, $exitCode);
  6050. return $exitCode !== 0;
  6051. }
  6052. protected function tryAsWindowsAdmin($localFilename, $newFilename)
  6053. {
  6054. $io = $this->getIO();
  6055. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6056. $helpMessage = 'Please run the self-update command as an Administrator.';
  6057. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6058. if (!$io->askConfirmation($question, false)) {
  6059. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6060. return false;
  6061. }
  6062. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6063. $script = $tmpFile.'.vbs';
  6064. rename($tmpFile, $script);
  6065. $checksum = hash_file('sha256', $newFilename);
  6066. $source = str_replace('/', '\\', $newFilename);
  6067. $destination = str_replace('/', '\\', $localFilename);
  6068. $vbs = <<<EOT
  6069. Set UAC = CreateObject("Shell.Application")
  6070. UAC.ShellExecute "cmd.exe", "/c move /y ""$source"" ""$destination""", "", "runas", 0
  6071. Wscript.Sleep(300)
  6072. EOT;
  6073. file_put_contents($script, $vbs);
  6074. exec('"'.$script.'"');
  6075. @unlink($script);
  6076. if ($result = (hash_file('sha256', $localFilename) === $checksum)) {
  6077. $io->writeError('<info>Operation succeeded.</info>');
  6078. } else {
  6079. $io->writeError('<error>Operation failed (file not written). '.$helpMessage.'</error>');
  6080. }
  6081. return $result;
  6082. }
  6083. }
  6084. <?php
  6085. namespace Composer\Command;
  6086. use Composer\Composer;
  6087. use Composer\DependencyResolver\DefaultPolicy;
  6088. use Composer\Json\JsonFile;
  6089. use Composer\Package\BasePackage;
  6090. use Composer\Package\CompletePackageInterface;
  6091. use Composer\Package\Link;
  6092. use Composer\Package\AliasPackage;
  6093. use Composer\Package\PackageInterface;
  6094. use Composer\Package\Version\VersionParser;
  6095. use Composer\Package\Version\VersionSelector;
  6096. use Composer\Plugin\CommandEvent;
  6097. use Composer\Plugin\PluginEvents;
  6098. use Composer\Repository\InstalledArrayRepository;
  6099. use Composer\Repository\ComposerRepository;
  6100. use Composer\Repository\CompositeRepository;
  6101. use Composer\Repository\PlatformRepository;
  6102. use Composer\Repository\RepositoryFactory;
  6103. use Composer\Repository\InstalledRepository;
  6104. use Composer\Repository\RepositoryInterface;
  6105. use Composer\Repository\RepositorySet;
  6106. use Composer\Repository\RootPackageRepository;
  6107. use Composer\Semver\Constraint\ConstraintInterface;
  6108. use Composer\Semver\Semver;
  6109. use Composer\Spdx\SpdxLicenses;
  6110. use Composer\Util\Platform;
  6111. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  6112. use Symfony\Component\Console\Input\InputArgument;
  6113. use Symfony\Component\Console\Input\InputInterface;
  6114. use Symfony\Component\Console\Input\InputOption;
  6115. use Symfony\Component\Console\Output\OutputInterface;
  6116. use Symfony\Component\Console\Terminal;
  6117. class ShowCommand extends BaseCommand
  6118. {
  6119. protected $versionParser;
  6120. protected $colors;
  6121. private $repositorySet;
  6122. protected function configure()
  6123. {
  6124. $this
  6125. ->setName('show')
  6126. ->setAliases(array('info'))
  6127. ->setDescription('Shows information about packages.')
  6128. ->setDefinition(array(
  6129. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  6130. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  6131. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  6132. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  6133. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  6134. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  6135. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  6136. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  6137. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  6138. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  6139. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  6140. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  6141. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  6142. 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.'),
  6143. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  6144. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6145. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6146. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6147. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6148. ))
  6149. ->setHelp(
  6150. <<<EOT
  6151. The show command displays detailed information about a package, or
  6152. lists all packages available.
  6153. Read more at https://getcomposer.org/doc/03-cli.md#show
  6154. EOT
  6155. )
  6156. ;
  6157. }
  6158. protected function execute(InputInterface $input, OutputInterface $output)
  6159. {
  6160. $this->versionParser = new VersionParser;
  6161. if ($input->getOption('tree')) {
  6162. $this->initStyles($output);
  6163. }
  6164. $composer = $this->getComposer(false);
  6165. $io = $this->getIO();
  6166. if ($input->getOption('installed')) {
  6167. $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>');
  6168. }
  6169. if ($input->getOption('outdated')) {
  6170. $input->setOption('latest', true);
  6171. } elseif ($input->getOption('ignore')) {
  6172. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  6173. }
  6174. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  6175. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  6176. return 1;
  6177. }
  6178. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  6179. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  6180. return 1;
  6181. }
  6182. if ($input->getOption('tree') && $input->getOption('latest')) {
  6183. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  6184. return 1;
  6185. }
  6186. if ($input->getOption('tree') && $input->getOption('path')) {
  6187. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  6188. return 1;
  6189. }
  6190. $format = $input->getOption('format');
  6191. if (!in_array($format, array('text', 'json'))) {
  6192. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6193. return 1;
  6194. }
  6195. $platformOverrides = array();
  6196. if ($composer) {
  6197. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  6198. }
  6199. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  6200. $lockedRepo = null;
  6201. if ($input->getOption('self')) {
  6202. $package = $this->getComposer()->getPackage();
  6203. if ($input->getOption('name-only')) {
  6204. $io->write($package->getName());
  6205. return 0;
  6206. }
  6207. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  6208. } elseif ($input->getOption('platform')) {
  6209. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  6210. } elseif ($input->getOption('available')) {
  6211. $installedRepo = new InstalledRepository(array($platformRepo));
  6212. if ($composer) {
  6213. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  6214. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  6215. } else {
  6216. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6217. $repos = new CompositeRepository($defaultRepos);
  6218. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6219. }
  6220. } elseif ($input->getOption('all') && $composer) {
  6221. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6222. $locker = $composer->getLocker();
  6223. if ($locker->isLocked()) {
  6224. $lockedRepo = $locker->getLockedRepository(true);
  6225. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  6226. } else {
  6227. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  6228. }
  6229. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6230. } elseif ($input->getOption('all')) {
  6231. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6232. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6233. $installedRepo = new InstalledRepository(array($platformRepo));
  6234. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  6235. } elseif ($input->getOption('locked')) {
  6236. if (!$composer || !$composer->getLocker()->isLocked()) {
  6237. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  6238. }
  6239. $locker = $composer->getLocker();
  6240. $lockedRepo = $locker->getLockedRepository(true);
  6241. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  6242. } else {
  6243. if (!$composer) {
  6244. $composer = $this->getComposer();
  6245. }
  6246. $rootPkg = $composer->getPackage();
  6247. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  6248. if ($input->getOption('no-dev')) {
  6249. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  6250. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) { return clone $pkg; }, $packages))));
  6251. }
  6252. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  6253. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  6254. }
  6255. }
  6256. if ($composer) {
  6257. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  6258. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6259. }
  6260. if ($input->getOption('latest') && null === $composer) {
  6261. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  6262. $input->setOption('latest', false);
  6263. }
  6264. $packageFilter = $input->getArgument('package');
  6265. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  6266. if (empty($package)) {
  6267. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  6268. if (empty($package)) {
  6269. $options = $input->getOptions();
  6270. if (!isset($options['working-dir']) || !file_exists('composer.json')) {
  6271. if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
  6272. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
  6273. }
  6274. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
  6275. }
  6276. $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
  6277. return 1;
  6278. }
  6279. } else {
  6280. $versions = array($package->getPrettyVersion() => $package->getVersion());
  6281. }
  6282. $exitCode = 0;
  6283. if ($input->getOption('tree')) {
  6284. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  6285. if ('json' === $format) {
  6286. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  6287. } else {
  6288. $this->displayPackageTree(array($arrayTree));
  6289. }
  6290. } else {
  6291. $latestPackage = null;
  6292. if ($input->getOption('latest')) {
  6293. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'));
  6294. }
  6295. if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) {
  6296. $exitCode = 1;
  6297. }
  6298. if ($input->getOption('path')) {
  6299. $io->write($package->getName(), false);
  6300. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  6301. return $exitCode;
  6302. }
  6303. if ('json' === $format) {
  6304. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  6305. } else {
  6306. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  6307. }
  6308. }
  6309. return $exitCode;
  6310. }
  6311. if ($input->getOption('tree')) {
  6312. $rootRequires = $this->getRootRequires();
  6313. $packages = $installedRepo->getPackages();
  6314. usort($packages, 'strcmp');
  6315. $arrayTree = array();
  6316. foreach ($packages as $package) {
  6317. if (in_array($package->getName(), $rootRequires, true)) {
  6318. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  6319. }
  6320. }
  6321. if ('json' === $format) {
  6322. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  6323. } else {
  6324. $this->displayPackageTree($arrayTree);
  6325. }
  6326. return 0;
  6327. }
  6328. if ($repos instanceof CompositeRepository) {
  6329. $repos = $repos->getRepositories();
  6330. } elseif (!is_array($repos)) {
  6331. $repos = array($repos);
  6332. }
  6333. $packages = array();
  6334. $packageFilterRegex = null;
  6335. if (null !== $packageFilter) {
  6336. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  6337. }
  6338. $packageListFilter = array();
  6339. if ($input->getOption('direct')) {
  6340. $packageListFilter = $this->getRootRequires();
  6341. }
  6342. if (class_exists('Symfony\Component\Console\Terminal')) {
  6343. $terminal = new Terminal();
  6344. $width = $terminal->getWidth();
  6345. } else {
  6346. list($width) = $this->getApplication()->getTerminalDimensions();
  6347. }
  6348. if (null === $width) {
  6349. $width = PHP_INT_MAX;
  6350. }
  6351. if (Platform::isWindows()) {
  6352. $width--;
  6353. } else {
  6354. $width = max(80, $width);
  6355. }
  6356. if ($input->getOption('path') && null === $composer) {
  6357. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  6358. $input->setOption('path', false);
  6359. }
  6360. foreach ($repos as $repo) {
  6361. if ($repo === $platformRepo) {
  6362. $type = 'platform';
  6363. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  6364. $type = 'locked';
  6365. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  6366. $type = 'installed';
  6367. } else {
  6368. $type = 'available';
  6369. }
  6370. if ($repo instanceof ComposerRepository) {
  6371. foreach ($repo->getPackageNames($packageFilter) as $name) {
  6372. $packages[$type][$name] = $name;
  6373. }
  6374. } else {
  6375. foreach ($repo->getPackages() as $package) {
  6376. if (!isset($packages[$type][$package->getName()])
  6377. || !is_object($packages[$type][$package->getName()])
  6378. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  6379. ) {
  6380. while ($package instanceof AliasPackage) {
  6381. $package = $package->getAliasOf();
  6382. }
  6383. if (!$packageFilterRegex || preg_match($packageFilterRegex, $package->getName())) {
  6384. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  6385. $packages[$type][$package->getName()] = $package;
  6386. }
  6387. }
  6388. }
  6389. }
  6390. }
  6391. }
  6392. $showAllTypes = $input->getOption('all');
  6393. $showLatest = $input->getOption('latest');
  6394. $showMinorOnly = $input->getOption('minor-only');
  6395. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  6396. $indent = $showAllTypes ? ' ' : '';
  6397. $latestPackages = array();
  6398. $exitCode = 0;
  6399. $viewData = array();
  6400. $viewMetaData = array();
  6401. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  6402. if (isset($packages[$type])) {
  6403. ksort($packages[$type]);
  6404. $nameLength = $versionLength = $latestLength = 0;
  6405. if ($showLatest && $showVersion) {
  6406. foreach ($packages[$type] as $package) {
  6407. if (is_object($package)) {
  6408. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly);
  6409. if ($latestPackage === false) {
  6410. continue;
  6411. }
  6412. $latestPackages[$package->getPrettyName()] = $latestPackage;
  6413. }
  6414. }
  6415. }
  6416. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  6417. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  6418. $writeLatest = $writeVersion && $showLatest;
  6419. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  6420. $hasOutdatedPackages = false;
  6421. $viewData[$type] = array();
  6422. foreach ($packages[$type] as $package) {
  6423. $packageViewData = array();
  6424. if (is_object($package)) {
  6425. $latestPackage = null;
  6426. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  6427. $latestPackage = $latestPackages[$package->getPrettyName()];
  6428. }
  6429. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackage->isAbandoned();
  6430. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  6431. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  6432. continue;
  6433. }
  6434. if ($input->getOption('outdated') || $input->getOption('strict')) {
  6435. $hasOutdatedPackages = true;
  6436. }
  6437. $packageViewData['name'] = $package->getPrettyName();
  6438. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  6439. if ($writeVersion) {
  6440. $packageViewData['version'] = $package->getFullPrettyVersion();
  6441. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  6442. }
  6443. if ($writeLatest && $latestPackage) {
  6444. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  6445. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  6446. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  6447. }
  6448. if ($writeDescription) {
  6449. $packageViewData['description'] = $package->getDescription();
  6450. }
  6451. if ($writePath) {
  6452. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  6453. }
  6454. if ($latestPackage && $latestPackage->isAbandoned()) {
  6455. $replacement = is_string($latestPackage->getReplacementPackage())
  6456. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  6457. : 'No replacement was suggested';
  6458. $packageWarning = sprintf(
  6459. 'Package %s is abandoned, you should avoid using it. %s.',
  6460. $package->getPrettyName(),
  6461. $replacement
  6462. );
  6463. $packageViewData['warning'] = $packageWarning;
  6464. }
  6465. } else {
  6466. $packageViewData['name'] = $package;
  6467. $nameLength = max($nameLength, strlen($package));
  6468. }
  6469. $viewData[$type][] = $packageViewData;
  6470. }
  6471. $viewMetaData[$type] = array(
  6472. 'nameLength' => $nameLength,
  6473. 'versionLength' => $versionLength,
  6474. 'latestLength' => $latestLength,
  6475. );
  6476. if ($input->getOption('strict') && $hasOutdatedPackages) {
  6477. $exitCode = 1;
  6478. break;
  6479. }
  6480. }
  6481. }
  6482. if ('json' === $format) {
  6483. $io->write(JsonFile::encode($viewData));
  6484. } else {
  6485. foreach ($viewData as $type => $packages) {
  6486. $nameLength = $viewMetaData[$type]['nameLength'];
  6487. $versionLength = $viewMetaData[$type]['versionLength'];
  6488. $latestLength = $viewMetaData[$type]['latestLength'];
  6489. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  6490. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  6491. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  6492. if ($writeLatest && !$io->isDecorated()) {
  6493. $latestLength += 2;
  6494. }
  6495. if ($showAllTypes) {
  6496. if ('available' === $type) {
  6497. $io->write('<comment>' . $type . '</comment>:');
  6498. } else {
  6499. $io->write('<info>' . $type . '</info>:');
  6500. }
  6501. }
  6502. foreach ($packages as $package) {
  6503. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  6504. if (isset($package['version']) && $writeVersion) {
  6505. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  6506. }
  6507. if (isset($package['latest']) && $writeLatest) {
  6508. $latestVersion = $package['latest'];
  6509. $updateStatus = $package['latest-status'];
  6510. $style = $this->updateStatusToVersionStyle($updateStatus);
  6511. if (!$io->isDecorated()) {
  6512. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  6513. }
  6514. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  6515. }
  6516. if (isset($package['description']) && $writeDescription) {
  6517. $description = strtok($package['description'], "\r\n");
  6518. $remaining = $width - $nameLength - $versionLength - 4;
  6519. if ($writeLatest) {
  6520. $remaining -= $latestLength;
  6521. }
  6522. if (strlen($description) > $remaining) {
  6523. $description = substr($description, 0, $remaining - 3) . '...';
  6524. }
  6525. $io->write(' ' . $description, false);
  6526. }
  6527. if (isset($package['path'])) {
  6528. $io->write(' ' . $package['path'], false);
  6529. }
  6530. $io->write('');
  6531. if (isset($package['warning'])) {
  6532. $io->write('<warning>' . $package['warning'] . '</warning>');
  6533. }
  6534. }
  6535. if ($showAllTypes) {
  6536. $io->write('');
  6537. }
  6538. }
  6539. }
  6540. return $exitCode;
  6541. }
  6542. protected function getRootRequires()
  6543. {
  6544. $rootPackage = $this->getComposer()->getPackage();
  6545. return array_map(
  6546. 'strtolower',
  6547. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  6548. );
  6549. }
  6550. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  6551. {
  6552. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  6553. }
  6554. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
  6555. {
  6556. $name = strtolower($name);
  6557. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  6558. $policy = new DefaultPolicy();
  6559. $repositorySet = new RepositorySet('dev');
  6560. $repositorySet->allowInstalledRepositories();
  6561. $repositorySet->addRepository($repos);
  6562. $matchedPackage = null;
  6563. $versions = array();
  6564. if (PlatformRepository::isPlatformPackage($name)) {
  6565. $pool = $repositorySet->createPoolWithAllPackages();
  6566. } else {
  6567. $pool = $repositorySet->createPoolForPackage($name);
  6568. }
  6569. $matches = $pool->whatProvides($name, $constraint);
  6570. foreach ($matches as $index => $package) {
  6571. if (null === $version && $installedRepo->hasPackage($package)) {
  6572. $matchedPackage = $package;
  6573. }
  6574. $versions[$package->getPrettyVersion()] = $package->getVersion();
  6575. $matches[$index] = $package->getId();
  6576. }
  6577. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  6578. $matchedPackage = $pool->literalToPackage($preferred[0]);
  6579. }
  6580. return array($matchedPackage, $versions);
  6581. }
  6582. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6583. {
  6584. $io = $this->getIO();
  6585. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  6586. $this->printLinks($package, Link::TYPE_REQUIRE);
  6587. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  6588. if ($package->getSuggests()) {
  6589. $io->write("\n<info>suggests</info>");
  6590. foreach ($package->getSuggests() as $suggested => $reason) {
  6591. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  6592. }
  6593. }
  6594. $this->printLinks($package, Link::TYPE_PROVIDE);
  6595. $this->printLinks($package, Link::TYPE_CONFLICT);
  6596. $this->printLinks($package, Link::TYPE_REPLACE);
  6597. }
  6598. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6599. {
  6600. $io = $this->getIO();
  6601. $io->write('<info>name</info> : ' . $package->getPrettyName());
  6602. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  6603. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  6604. $this->printVersions($package, $versions, $installedRepo);
  6605. if ($latestPackage) {
  6606. $style = $this->getVersionStyle($latestPackage, $package);
  6607. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  6608. } else {
  6609. $latestPackage = $package;
  6610. }
  6611. $io->write('<info>type</info> : ' . $package->getType());
  6612. $this->printLicenses($package);
  6613. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  6614. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  6615. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  6616. if ($installedRepo->hasPackage($package)) {
  6617. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  6618. }
  6619. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  6620. if ($latestPackage->isAbandoned()) {
  6621. $replacement = ($latestPackage->getReplacementPackage() !== null)
  6622. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  6623. : null;
  6624. $io->writeError(
  6625. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  6626. );
  6627. }
  6628. if ($package->getSupport()) {
  6629. $io->write("\n<info>support</info>");
  6630. foreach ($package->getSupport() as $type => $value) {
  6631. $io->write('<comment>' . $type . '</comment> : '.$value);
  6632. }
  6633. }
  6634. if ($package->getAutoload()) {
  6635. $io->write("\n<info>autoload</info>");
  6636. foreach ($package->getAutoload() as $type => $autoloads) {
  6637. $io->write('<comment>' . $type . '</comment>');
  6638. if ($type === 'psr-0' || $type === 'psr-4') {
  6639. foreach ($autoloads as $name => $path) {
  6640. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  6641. }
  6642. } elseif ($type === 'classmap') {
  6643. $io->write(implode(', ', $autoloads));
  6644. }
  6645. }
  6646. if ($package->getIncludePaths()) {
  6647. $io->write('<comment>include-path</comment>');
  6648. $io->write(implode(', ', $package->getIncludePaths()));
  6649. }
  6650. }
  6651. }
  6652. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
  6653. {
  6654. $versions = array_keys($versions);
  6655. $versions = Semver::rsort($versions);
  6656. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  6657. foreach ($installedPackages as $installedPackage) {
  6658. $installedVersion = $installedPackage->getPrettyVersion();
  6659. $key = array_search($installedVersion, $versions);
  6660. if (false !== $key) {
  6661. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  6662. }
  6663. }
  6664. }
  6665. $versions = implode(', ', $versions);
  6666. $this->getIO()->write('<info>versions</info> : ' . $versions);
  6667. }
  6668. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  6669. {
  6670. $title = $title ?: $linkType;
  6671. $io = $this->getIO();
  6672. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  6673. $io->write("\n<info>" . $title . "</info>");
  6674. foreach ($links as $link) {
  6675. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  6676. }
  6677. }
  6678. }
  6679. protected function printLicenses(CompletePackageInterface $package)
  6680. {
  6681. $spdxLicenses = new SpdxLicenses();
  6682. $licenses = $package->getLicense();
  6683. $io = $this->getIO();
  6684. foreach ($licenses as $licenseId) {
  6685. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6686. if (!$license) {
  6687. $out = $licenseId;
  6688. } else {
  6689. if ($license[1] === true) {
  6690. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  6691. } else {
  6692. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  6693. }
  6694. }
  6695. $io->write('<info>license</info> : ' . $out);
  6696. }
  6697. }
  6698. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6699. {
  6700. $json = array(
  6701. 'name' => $package->getPrettyName(),
  6702. 'description' => $package->getDescription(),
  6703. 'keywords' => $package->getKeywords() ?: array(),
  6704. 'type' => $package->getType(),
  6705. 'homepage' => $package->getHomepage(),
  6706. 'names' => $package->getNames()
  6707. );
  6708. $json = $this->appendVersions($json, $versions);
  6709. $json = $this->appendLicenses($json, $package);
  6710. if ($latestPackage) {
  6711. $json['latest'] = $latestPackage->getPrettyVersion();
  6712. } else {
  6713. $latestPackage = $package;
  6714. }
  6715. if ($package->getSourceType()) {
  6716. $json['source'] = array(
  6717. 'type' => $package->getSourceType(),
  6718. 'url' => $package->getSourceUrl(),
  6719. 'reference' => $package->getSourceReference()
  6720. );
  6721. }
  6722. if ($package->getDistType()) {
  6723. $json['dist'] = array(
  6724. 'type' => $package->getDistType(),
  6725. 'url' => $package->getDistUrl(),
  6726. 'reference' => $package->getDistReference()
  6727. );
  6728. }
  6729. if ($installedRepo->hasPackage($package)) {
  6730. $json['path'] = realpath($this->getComposer()->getInstallationManager()->getInstallPath($package));
  6731. if ($json['path'] === false) {
  6732. unset($json['path']);
  6733. }
  6734. }
  6735. if ($latestPackage->isAbandoned()) {
  6736. $json['replacement'] = $latestPackage->getReplacementPackage();
  6737. }
  6738. if ($package->getSuggests()) {
  6739. $json['suggests'] = $package->getSuggests();
  6740. }
  6741. if ($package->getSupport()) {
  6742. $json['support'] = $package->getSupport();
  6743. }
  6744. $json = $this->appendAutoload($json, $package);
  6745. if ($package->getIncludePaths()) {
  6746. $json['include_path'] = $package->getIncludePaths();
  6747. }
  6748. $json = $this->appendLinks($json, $package);
  6749. $this->getIO()->write(JsonFile::encode($json));
  6750. }
  6751. private function appendVersions($json, array $versions)
  6752. {
  6753. uasort($versions, 'version_compare');
  6754. $versions = array_keys(array_reverse($versions));
  6755. $json['versions'] = $versions;
  6756. return $json;
  6757. }
  6758. private function appendLicenses($json, CompletePackageInterface $package)
  6759. {
  6760. if ($licenses = $package->getLicense()) {
  6761. $spdxLicenses = new SpdxLicenses();
  6762. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  6763. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6764. if (!$license) {
  6765. return $licenseId;
  6766. }
  6767. return array(
  6768. 'name' => $license[0],
  6769. 'osi' => $licenseId,
  6770. 'url' => $license[2]
  6771. );
  6772. }, $licenses);
  6773. }
  6774. return $json;
  6775. }
  6776. private function appendAutoload($json, CompletePackageInterface $package)
  6777. {
  6778. if ($package->getAutoload()) {
  6779. $autoload = array();
  6780. foreach ($package->getAutoload() as $type => $autoloads) {
  6781. if ($type === 'psr-0' || $type === 'psr-4') {
  6782. $psr = array();
  6783. foreach ($autoloads as $name => $path) {
  6784. if (!$path) {
  6785. $path = '.';
  6786. }
  6787. $psr[$name ?: '*'] = $path;
  6788. }
  6789. $autoload[$type] = $psr;
  6790. } elseif ($type === 'classmap') {
  6791. $autoload['classmap'] = $autoloads;
  6792. }
  6793. }
  6794. $json['autoload'] = $autoload;
  6795. }
  6796. return $json;
  6797. }
  6798. private function appendLinks($json, CompletePackageInterface $package)
  6799. {
  6800. foreach (Link::$TYPES as $linkType) {
  6801. $json = $this->appendLink($json, $package, $linkType);
  6802. }
  6803. return $json;
  6804. }
  6805. private function appendLink($json, CompletePackageInterface $package, $linkType)
  6806. {
  6807. $links = $package->{'get' . ucfirst($linkType)}();
  6808. if ($links) {
  6809. $json[$linkType] = array();
  6810. foreach ($links as $link) {
  6811. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  6812. }
  6813. }
  6814. return $json;
  6815. }
  6816. protected function initStyles(OutputInterface $output)
  6817. {
  6818. $this->colors = array(
  6819. 'green',
  6820. 'yellow',
  6821. 'cyan',
  6822. 'magenta',
  6823. 'blue',
  6824. );
  6825. foreach ($this->colors as $color) {
  6826. $style = new OutputFormatterStyle($color);
  6827. $output->getFormatter()->setStyle($color, $style);
  6828. }
  6829. }
  6830. protected function displayPackageTree(array $arrayTree)
  6831. {
  6832. $io = $this->getIO();
  6833. foreach ($arrayTree as $package) {
  6834. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  6835. $io->write(' ' . $package['version'], false);
  6836. $io->write(' ' . strtok($package['description'], "\r\n"));
  6837. if (isset($package['requires'])) {
  6838. $requires = $package['requires'];
  6839. $treeBar = '├';
  6840. $j = 0;
  6841. $total = count($requires);
  6842. foreach ($requires as $require) {
  6843. $requireName = $require['name'];
  6844. $j++;
  6845. if ($j === $total) {
  6846. $treeBar = 'â””';
  6847. }
  6848. $level = 1;
  6849. $color = $this->colors[$level];
  6850. $info = sprintf(
  6851. '%s──<%s>%s</%s> %s',
  6852. $treeBar,
  6853. $color,
  6854. $requireName,
  6855. $color,
  6856. $require['version']
  6857. );
  6858. $this->writeTreeLine($info);
  6859. $treeBar = str_replace('â””', ' ', $treeBar);
  6860. $packagesInTree = array($package['name'], $requireName);
  6861. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  6862. }
  6863. }
  6864. }
  6865. }
  6866. protected function generatePackageTree(
  6867. PackageInterface $package,
  6868. InstalledRepository $installedRepo,
  6869. RepositoryInterface $remoteRepos
  6870. ) {
  6871. $requires = $package->getRequires();
  6872. ksort($requires);
  6873. $children = array();
  6874. foreach ($requires as $requireName => $require) {
  6875. $packagesInTree = array($package->getName(), $requireName);
  6876. $treeChildDesc = array(
  6877. 'name' => $requireName,
  6878. 'version' => $require->getPrettyConstraint(),
  6879. );
  6880. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  6881. if ($deepChildren) {
  6882. $treeChildDesc['requires'] = $deepChildren;
  6883. }
  6884. $children[] = $treeChildDesc;
  6885. }
  6886. $tree = array(
  6887. 'name' => $package->getPrettyName(),
  6888. 'version' => $package->getPrettyVersion(),
  6889. 'description' => $package->getDescription(),
  6890. );
  6891. if ($children) {
  6892. $tree['requires'] = $children;
  6893. }
  6894. return $tree;
  6895. }
  6896. protected function displayTree(
  6897. $package,
  6898. array $packagesInTree,
  6899. $previousTreeBar = '├',
  6900. $level = 1
  6901. ) {
  6902. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  6903. if (is_array($package) && isset($package['requires'])) {
  6904. $requires = $package['requires'];
  6905. $treeBar = $previousTreeBar . ' ├';
  6906. $i = 0;
  6907. $total = count($requires);
  6908. foreach ($requires as $require) {
  6909. $currentTree = $packagesInTree;
  6910. $i++;
  6911. if ($i === $total) {
  6912. $treeBar = $previousTreeBar . ' â””';
  6913. }
  6914. $colorIdent = $level % count($this->colors);
  6915. $color = $this->colors[$colorIdent];
  6916. $circularWarn = in_array(
  6917. $require['name'],
  6918. $currentTree,
  6919. true
  6920. ) ? '(circular dependency aborted here)' : '';
  6921. $info = rtrim(sprintf(
  6922. '%s──<%s>%s</%s> %s %s',
  6923. $treeBar,
  6924. $color,
  6925. $require['name'],
  6926. $color,
  6927. $require['version'],
  6928. $circularWarn
  6929. ));
  6930. $this->writeTreeLine($info);
  6931. $treeBar = str_replace('â””', ' ', $treeBar);
  6932. $currentTree[] = $require['name'];
  6933. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  6934. }
  6935. }
  6936. }
  6937. protected function addTree(
  6938. $name,
  6939. $package,
  6940. InstalledRepository $installedRepo,
  6941. RepositoryInterface $remoteRepos,
  6942. array $packagesInTree
  6943. ) {
  6944. $children = array();
  6945. list($package) = $this->getPackage(
  6946. $installedRepo,
  6947. $remoteRepos,
  6948. $name,
  6949. $package->getPrettyConstraint() === 'self.version' ? $package->getConstraint() : $package->getPrettyConstraint()
  6950. );
  6951. if (is_object($package)) {
  6952. $requires = $package->getRequires();
  6953. ksort($requires);
  6954. foreach ($requires as $requireName => $require) {
  6955. $currentTree = $packagesInTree;
  6956. $treeChildDesc = array(
  6957. 'name' => $requireName,
  6958. 'version' => $require->getPrettyConstraint(),
  6959. );
  6960. if (!in_array($requireName, $currentTree, true)) {
  6961. $currentTree[] = $requireName;
  6962. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  6963. if ($deepChildren) {
  6964. $treeChildDesc['requires'] = $deepChildren;
  6965. }
  6966. }
  6967. $children[] = $treeChildDesc;
  6968. }
  6969. }
  6970. return $children;
  6971. }
  6972. private function updateStatusToVersionStyle($updateStatus)
  6973. {
  6974. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  6975. }
  6976. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  6977. {
  6978. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  6979. return 'up-to-date';
  6980. }
  6981. $constraint = $package->getVersion();
  6982. if (0 !== strpos($constraint, 'dev-')) {
  6983. $constraint = '^'.$constraint;
  6984. }
  6985. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  6986. return 'semver-safe-update';
  6987. }
  6988. return 'update-possible';
  6989. }
  6990. private function writeTreeLine($line)
  6991. {
  6992. $io = $this->getIO();
  6993. if (!$io->isDecorated()) {
  6994. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  6995. }
  6996. $io->write($line);
  6997. }
  6998. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, $minorOnly = false)
  6999. {
  7000. $name = $package->getName();
  7001. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  7002. $stability = $composer->getPackage()->getMinimumStability();
  7003. $flags = $composer->getPackage()->getStabilityFlags();
  7004. if (isset($flags[$name])) {
  7005. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  7006. }
  7007. $bestStability = $stability;
  7008. if ($composer->getPackage()->getPreferStable()) {
  7009. $bestStability = $package->getStability();
  7010. }
  7011. $targetVersion = null;
  7012. if (0 === strpos($package->getVersion(), 'dev-')) {
  7013. $targetVersion = $package->getVersion();
  7014. }
  7015. if ($targetVersion === null && $minorOnly) {
  7016. $targetVersion = '^' . $package->getVersion();
  7017. }
  7018. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability);
  7019. while ($candidate instanceof AliasPackage) {
  7020. $candidate = $candidate->getAliasOf();
  7021. }
  7022. return $candidate;
  7023. }
  7024. private function getRepositorySet(Composer $composer)
  7025. {
  7026. if (!$this->repositorySet) {
  7027. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  7028. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  7029. }
  7030. return $this->repositorySet;
  7031. }
  7032. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  7033. {
  7034. $requires = $package->getRequires();
  7035. foreach ($repo->getPackages() as $candidate) {
  7036. foreach ($candidate->getNames() as $name) {
  7037. if (isset($requires[$name])) {
  7038. if (!in_array($candidate, $bucket, true)) {
  7039. $bucket[] = $candidate;
  7040. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  7041. }
  7042. break;
  7043. }
  7044. }
  7045. }
  7046. return $bucket;
  7047. }
  7048. }
  7049. <?php
  7050. namespace Composer\Command;
  7051. use Symfony\Component\Console\Input\InputInterface;
  7052. use Symfony\Component\Console\Input\InputOption;
  7053. use Symfony\Component\Console\Output\OutputInterface;
  7054. use Composer\Downloader\ChangeReportInterface;
  7055. use Composer\Downloader\DvcsDownloaderInterface;
  7056. use Composer\Downloader\VcsCapableDownloaderInterface;
  7057. use Composer\Package\Dumper\ArrayDumper;
  7058. use Composer\Package\Version\VersionGuesser;
  7059. use Composer\Package\Version\VersionParser;
  7060. use Composer\Plugin\CommandEvent;
  7061. use Composer\Plugin\PluginEvents;
  7062. use Composer\Script\ScriptEvents;
  7063. use Composer\Util\ProcessExecutor;
  7064. class StatusCommand extends BaseCommand
  7065. {
  7066. const EXIT_CODE_ERRORS = 1;
  7067. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  7068. const EXIT_CODE_VERSION_CHANGES = 4;
  7069. protected function configure()
  7070. {
  7071. $this
  7072. ->setName('status')
  7073. ->setDescription('Shows a list of locally modified packages.')
  7074. ->setDefinition(array(
  7075. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  7076. ))
  7077. ->setHelp(
  7078. <<<EOT
  7079. The status command displays a list of dependencies that have
  7080. been modified locally.
  7081. Read more at https://getcomposer.org/doc/03-cli.md#status
  7082. EOT
  7083. )
  7084. ;
  7085. }
  7086. protected function execute(InputInterface $input, OutputInterface $output)
  7087. {
  7088. $composer = $this->getComposer();
  7089. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  7090. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7091. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  7092. $exitCode = $this->doExecute($input);
  7093. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  7094. return $exitCode;
  7095. }
  7096. private function doExecute(InputInterface $input)
  7097. {
  7098. $composer = $this->getComposer();
  7099. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  7100. $dm = $composer->getDownloadManager();
  7101. $im = $composer->getInstallationManager();
  7102. $errors = array();
  7103. $io = $this->getIO();
  7104. $unpushedChanges = array();
  7105. $vcsVersionChanges = array();
  7106. $parser = new VersionParser;
  7107. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  7108. $dumper = new ArrayDumper;
  7109. foreach ($installedRepo->getCanonicalPackages() as $package) {
  7110. $downloader = $dm->getDownloaderForPackage($package);
  7111. $targetDir = $im->getInstallPath($package);
  7112. if ($downloader instanceof ChangeReportInterface) {
  7113. if (is_link($targetDir)) {
  7114. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  7115. }
  7116. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  7117. $errors[$targetDir] = $changes;
  7118. }
  7119. }
  7120. if ($downloader instanceof VcsCapableDownloaderInterface) {
  7121. if ($downloader->getVcsReference($package, $targetDir)) {
  7122. switch ($package->getInstallationSource()) {
  7123. case 'source':
  7124. $previousRef = $package->getSourceReference();
  7125. break;
  7126. case 'dist':
  7127. $previousRef = $package->getDistReference();
  7128. break;
  7129. default:
  7130. $previousRef = null;
  7131. }
  7132. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  7133. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  7134. $vcsVersionChanges[$targetDir] = array(
  7135. 'previous' => array(
  7136. 'version' => $package->getPrettyVersion(),
  7137. 'ref' => $previousRef,
  7138. ),
  7139. 'current' => array(
  7140. 'version' => $currentVersion['pretty_version'],
  7141. 'ref' => $currentVersion['commit'],
  7142. ),
  7143. );
  7144. }
  7145. }
  7146. }
  7147. if ($downloader instanceof DvcsDownloaderInterface) {
  7148. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  7149. $unpushedChanges[$targetDir] = $unpushed;
  7150. }
  7151. }
  7152. }
  7153. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  7154. $io->writeError('<info>No local changes</info>');
  7155. return 0;
  7156. }
  7157. if ($errors) {
  7158. $io->writeError('<error>You have changes in the following dependencies:</error>');
  7159. foreach ($errors as $path => $changes) {
  7160. if ($input->getOption('verbose')) {
  7161. $indentedChanges = implode("\n", array_map(function ($line) {
  7162. return ' ' . ltrim($line);
  7163. }, explode("\n", $changes)));
  7164. $io->write('<info>'.$path.'</info>:');
  7165. $io->write($indentedChanges);
  7166. } else {
  7167. $io->write($path);
  7168. }
  7169. }
  7170. }
  7171. if ($unpushedChanges) {
  7172. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  7173. foreach ($unpushedChanges as $path => $changes) {
  7174. if ($input->getOption('verbose')) {
  7175. $indentedChanges = implode("\n", array_map(function ($line) {
  7176. return ' ' . ltrim($line);
  7177. }, explode("\n", $changes)));
  7178. $io->write('<info>'.$path.'</info>:');
  7179. $io->write($indentedChanges);
  7180. } else {
  7181. $io->write($path);
  7182. }
  7183. }
  7184. }
  7185. if ($vcsVersionChanges) {
  7186. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  7187. foreach ($vcsVersionChanges as $path => $changes) {
  7188. if ($input->getOption('verbose')) {
  7189. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  7190. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  7191. if ($io->isVeryVerbose()) {
  7192. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  7193. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  7194. }
  7195. $io->write('<info>'.$path.'</info>:');
  7196. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  7197. } else {
  7198. $io->write($path);
  7199. }
  7200. }
  7201. }
  7202. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  7203. $io->writeError('Use --verbose (-v) to see a list of files');
  7204. }
  7205. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  7206. }
  7207. }
  7208. <?php
  7209. namespace Composer\Command;
  7210. use Composer\Repository\PlatformRepository;
  7211. use Composer\Repository\RootPackageRepository;
  7212. use Composer\Repository\InstalledRepository;
  7213. use Composer\Installer\SuggestedPackagesReporter;
  7214. use Symfony\Component\Console\Input\InputArgument;
  7215. use Symfony\Component\Console\Input\InputInterface;
  7216. use Symfony\Component\Console\Input\InputOption;
  7217. use Symfony\Component\Console\Output\OutputInterface;
  7218. class SuggestsCommand extends BaseCommand
  7219. {
  7220. protected function configure()
  7221. {
  7222. $this
  7223. ->setName('suggests')
  7224. ->setDescription('Shows package suggestions.')
  7225. ->setDefinition(array(
  7226. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  7227. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  7228. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  7229. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  7230. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  7231. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  7232. ))
  7233. ->setHelp(
  7234. <<<EOT
  7235. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  7236. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  7237. EOT
  7238. )
  7239. ;
  7240. }
  7241. protected function execute(InputInterface $input, OutputInterface $output)
  7242. {
  7243. $composer = $this->getComposer();
  7244. $installedRepos = array(
  7245. new RootPackageRepository(clone $composer->getPackage()),
  7246. );
  7247. $locker = $composer->getLocker();
  7248. if ($locker->isLocked()) {
  7249. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  7250. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7251. } else {
  7252. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  7253. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  7254. }
  7255. $installedRepo = new InstalledRepository($installedRepos);
  7256. $reporter = new SuggestedPackagesReporter($this->getIO());
  7257. $filter = $input->getArgument('packages');
  7258. $packages = $installedRepo->getPackages();
  7259. $packages[] = $composer->getPackage();
  7260. foreach ($packages as $package) {
  7261. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  7262. continue;
  7263. }
  7264. $reporter->addSuggestionsFromPackage($package);
  7265. }
  7266. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7267. if ($input->getOption('by-suggestion')) {
  7268. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  7269. }
  7270. if ($input->getOption('by-package')) {
  7271. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7272. }
  7273. if ($input->getOption('list')) {
  7274. $mode = SuggestedPackagesReporter::MODE_LIST;
  7275. }
  7276. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  7277. return 0;
  7278. }
  7279. }
  7280. <?php
  7281. namespace Composer\Command;
  7282. use Composer\Composer;
  7283. use Composer\DependencyResolver\Request;
  7284. use Composer\Installer;
  7285. use Composer\IO\IOInterface;
  7286. use Composer\Plugin\CommandEvent;
  7287. use Composer\Plugin\PluginEvents;
  7288. use Composer\Package\Version\VersionParser;
  7289. use Composer\Semver\Constraint\MultiConstraint;
  7290. use Composer\Package\Link;
  7291. use Symfony\Component\Console\Helper\Table;
  7292. use Symfony\Component\Console\Input\InputInterface;
  7293. use Symfony\Component\Console\Input\InputOption;
  7294. use Symfony\Component\Console\Input\InputArgument;
  7295. use Symfony\Component\Console\Output\OutputInterface;
  7296. use Symfony\Component\Console\Question\Question;
  7297. class UpdateCommand extends BaseCommand
  7298. {
  7299. protected function configure()
  7300. {
  7301. $this
  7302. ->setName('update')
  7303. ->setAliases(array('u', 'upgrade'))
  7304. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  7305. ->setDefinition(array(
  7306. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  7307. 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'),
  7308. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  7309. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  7310. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  7311. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  7312. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  7313. 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.'),
  7314. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  7315. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  7316. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  7317. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  7318. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7319. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  7320. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  7321. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  7322. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  7323. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  7324. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  7325. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  7326. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  7327. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  7328. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  7329. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  7330. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  7331. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  7332. ))
  7333. ->setHelp(
  7334. <<<EOT
  7335. The <info>update</info> command reads the composer.json file from the
  7336. current directory, processes it, and updates, removes or installs all the
  7337. dependencies.
  7338. <info>php composer.phar update</info>
  7339. To limit the update operation to a few packages, you can list the package(s)
  7340. you want to update as such:
  7341. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  7342. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  7343. from a specific vendor:
  7344. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  7345. To run an update with more restrictive constraints you can use:
  7346. <info>php composer.phar update --with vendor/package:1.0.*</info>
  7347. To run a partial update with more restrictive constraints you can use the shorthand:
  7348. <info>php composer.phar update vendor/package:1.0.*</info>
  7349. To select packages names interactively with auto-completion use <info>-i</info>.
  7350. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  7351. EOT
  7352. )
  7353. ;
  7354. }
  7355. protected function execute(InputInterface $input, OutputInterface $output)
  7356. {
  7357. $io = $this->getIO();
  7358. if ($input->getOption('dev')) {
  7359. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  7360. }
  7361. if ($input->getOption('no-suggest')) {
  7362. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  7363. }
  7364. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  7365. $packages = $input->getArgument('packages');
  7366. $reqs = $this->formatRequirements($input->getOption('with'));
  7367. if ($packages) {
  7368. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg) {
  7369. return preg_match('{\S+[ =:]\S+}', $pkg) > 0;
  7370. });
  7371. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  7372. $reqs[$package] = $constraint;
  7373. }
  7374. foreach ($allowlistPackagesWithRequirements as $package) {
  7375. $packageName = preg_replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  7376. $index = array_search($package, $packages);
  7377. $packages[$index] = $packageName;
  7378. }
  7379. }
  7380. $rootRequires = $composer->getPackage()->getRequires();
  7381. $rootDevRequires = $composer->getPackage()->getDevRequires();
  7382. foreach ($reqs as $package => $constraint) {
  7383. if (isset($rootRequires[$package])) {
  7384. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  7385. } elseif (isset($rootDevRequires[$package])) {
  7386. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  7387. } else {
  7388. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  7389. }
  7390. }
  7391. $composer->getPackage()->setRequires($rootRequires);
  7392. $composer->getPackage()->setDevRequires($rootDevRequires);
  7393. if ($input->getOption('interactive')) {
  7394. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  7395. }
  7396. if ($input->getOption('root-reqs')) {
  7397. $requires = array_keys($rootRequires);
  7398. if (!$input->getOption('no-dev')) {
  7399. $requires = array_merge($requires, array_keys($rootDevRequires));
  7400. }
  7401. if (!empty($packages)) {
  7402. $packages = array_intersect($packages, $requires);
  7403. } else {
  7404. $packages = $requires;
  7405. }
  7406. }
  7407. $filteredPackages = array_filter($packages, function ($package) {
  7408. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  7409. });
  7410. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  7411. $packages = $filteredPackages;
  7412. if ($updateMirrors && !empty($packages)) {
  7413. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  7414. return -1;
  7415. }
  7416. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  7417. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7418. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7419. $install = Installer::create($io, $composer);
  7420. $config = $composer->getConfig();
  7421. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  7422. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  7423. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  7424. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7425. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  7426. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7427. if ($input->getOption('with-all-dependencies')) {
  7428. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7429. } elseif ($input->getOption('with-dependencies')) {
  7430. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7431. }
  7432. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  7433. $install
  7434. ->setDryRun($input->getOption('dry-run'))
  7435. ->setVerbose($input->getOption('verbose'))
  7436. ->setPreferSource($preferSource)
  7437. ->setPreferDist($preferDist)
  7438. ->setDevMode(!$input->getOption('no-dev'))
  7439. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  7440. ->setRunScripts(!$input->getOption('no-scripts'))
  7441. ->setOptimizeAutoloader($optimize)
  7442. ->setClassMapAuthoritative($authoritative)
  7443. ->setApcuAutoloader($apcu, $apcuPrefix)
  7444. ->setUpdate(true)
  7445. ->setInstall(!$input->getOption('no-install'))
  7446. ->setUpdateMirrors($updateMirrors)
  7447. ->setUpdateAllowList($packages)
  7448. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7449. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  7450. ->setPreferStable($input->getOption('prefer-stable'))
  7451. ->setPreferLowest($input->getOption('prefer-lowest'))
  7452. ;
  7453. if ($input->getOption('no-plugins')) {
  7454. $install->disablePlugins();
  7455. }
  7456. return $install->run();
  7457. }
  7458. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  7459. {
  7460. if (!$input->isInteractive()) {
  7461. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  7462. }
  7463. $requires = array_merge(
  7464. $composer->getPackage()->getRequires(),
  7465. $composer->getPackage()->getDevRequires()
  7466. );
  7467. $autocompleterValues = array();
  7468. foreach ($requires as $require) {
  7469. $target = $require->getTarget();
  7470. $autocompleterValues[strtolower($target)] = $target;
  7471. }
  7472. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  7473. foreach ($installedPackages as $package) {
  7474. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  7475. }
  7476. $helper = $this->getHelper('question');
  7477. $question = new Question('<comment>Enter package name: </comment>', null);
  7478. $io->writeError('<info>Press enter without value to end submission</info>');
  7479. do {
  7480. $autocompleterValues = array_diff($autocompleterValues, $packages);
  7481. $question->setAutocompleterValues($autocompleterValues);
  7482. $addedPackage = $helper->ask($input, $output, $question);
  7483. if (!is_string($addedPackage) || empty($addedPackage)) {
  7484. break;
  7485. }
  7486. $addedPackage = strtolower($addedPackage);
  7487. if (!in_array($addedPackage, $packages)) {
  7488. $packages[] = $addedPackage;
  7489. }
  7490. } while (true);
  7491. $packages = array_filter($packages);
  7492. if (!$packages) {
  7493. throw new \InvalidArgumentException('You must enter minimum one package.');
  7494. }
  7495. $table = new Table($output);
  7496. $table->setHeaders(array('Selected packages'));
  7497. foreach ($packages as $package) {
  7498. $table->addRow(array($package));
  7499. }
  7500. $table->render();
  7501. if ($io->askConfirmation(sprintf(
  7502. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  7503. 1 === count($packages) ? '' : 's'
  7504. ))) {
  7505. return $packages;
  7506. }
  7507. throw new \RuntimeException('Installation aborted.');
  7508. }
  7509. private function appendConstraintToLink(Link $link, $constraint)
  7510. {
  7511. $parser = new VersionParser;
  7512. $oldPrettyString = $link->getConstraint()->getPrettyString();
  7513. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  7514. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  7515. return new Link(
  7516. $link->getSource(),
  7517. $link->getTarget(),
  7518. $newConstraint,
  7519. $link->getDescription(),
  7520. $link->getPrettyConstraint() . ', ' . $constraint
  7521. );
  7522. }
  7523. }
  7524. <?php
  7525. namespace Composer\Command;
  7526. use Composer\Factory;
  7527. use Composer\Package\Loader\ValidatingArrayLoader;
  7528. use Composer\Plugin\CommandEvent;
  7529. use Composer\Plugin\PluginEvents;
  7530. use Composer\Util\ConfigValidator;
  7531. use Symfony\Component\Console\Input\InputArgument;
  7532. use Symfony\Component\Console\Input\InputInterface;
  7533. use Symfony\Component\Console\Input\InputOption;
  7534. use Symfony\Component\Console\Output\OutputInterface;
  7535. class ValidateCommand extends BaseCommand
  7536. {
  7537. protected function configure()
  7538. {
  7539. $this
  7540. ->setName('validate')
  7541. ->setDescription('Validates a composer.json and composer.lock.')
  7542. ->setDefinition(array(
  7543. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  7544. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  7545. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  7546. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  7547. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  7548. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  7549. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  7550. ))
  7551. ->setHelp(
  7552. <<<EOT
  7553. The validate command validates a given composer.json and composer.lock
  7554. Exit codes in case of errors are:
  7555. 1 validation warning(s), only when --strict is given
  7556. 2 validation error(s)
  7557. 3 file unreadable or missing
  7558. Read more at https://getcomposer.org/doc/03-cli.md#validate
  7559. EOT
  7560. );
  7561. }
  7562. protected function execute(InputInterface $input, OutputInterface $output)
  7563. {
  7564. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  7565. $io = $this->getIO();
  7566. if (!file_exists($file)) {
  7567. $io->writeError('<error>' . $file . ' not found.</error>');
  7568. return 3;
  7569. }
  7570. if (!is_readable($file)) {
  7571. $io->writeError('<error>' . $file . ' is not readable.</error>');
  7572. return 3;
  7573. }
  7574. $validator = new ConfigValidator($io);
  7575. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  7576. $checkPublish = !$input->getOption('no-check-publish');
  7577. $checkLock = !$input->getOption('no-check-lock');
  7578. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  7579. $isStrict = $input->getOption('strict');
  7580. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7581. $lockErrors = array();
  7582. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  7583. $locker = $composer->getLocker();
  7584. if ($locker->isLocked() && !$locker->isFresh()) {
  7585. $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>`.';
  7586. }
  7587. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  7588. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7589. if ($input->getOption('with-dependencies')) {
  7590. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7591. foreach ($localRepo->getPackages() as $package) {
  7592. $path = $composer->getInstallationManager()->getInstallPath($package);
  7593. $file = $path . '/composer.json';
  7594. if (is_dir($path) && file_exists($file)) {
  7595. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7596. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  7597. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7598. $exitCode = max($depCode, $exitCode);
  7599. }
  7600. }
  7601. }
  7602. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  7603. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7604. return max($eventCode, $exitCode);
  7605. }
  7606. private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false)
  7607. {
  7608. $doPrintSchemaUrl = false;
  7609. if ($errors) {
  7610. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  7611. } elseif ($publishErrors) {
  7612. $io->writeError('<info>' . $name . ' is valid for simple usage with composer but has</info>');
  7613. $io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
  7614. $doPrintSchemaUrl = $printSchemaUrl;
  7615. } elseif ($warnings) {
  7616. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  7617. $doPrintSchemaUrl = $printSchemaUrl;
  7618. } else {
  7619. $io->write('<info>' . $name . ' is valid</info>');
  7620. }
  7621. if ($doPrintSchemaUrl) {
  7622. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  7623. }
  7624. $extraWarnings = array();
  7625. if ($checkPublish) {
  7626. $errors = array_merge($errors, $publishErrors);
  7627. } else {
  7628. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  7629. }
  7630. if ($checkLock) {
  7631. $errors = array_merge($errors, $lockErrors);
  7632. } else {
  7633. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  7634. }
  7635. $messages = array(
  7636. 'error' => $errors,
  7637. 'warning' => array_merge($warnings, $extraWarnings),
  7638. );
  7639. foreach ($messages as $style => $msgs) {
  7640. foreach ($msgs as $msg) {
  7641. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  7642. }
  7643. }
  7644. }
  7645. }
  7646. <?php
  7647. namespace Composer;
  7648. use Composer\Package\RootPackageInterface;
  7649. use Composer\Package\Locker;
  7650. use Composer\Util\Loop;
  7651. use Composer\Repository\RepositoryManager;
  7652. use Composer\Installer\InstallationManager;
  7653. use Composer\Plugin\PluginManager;
  7654. use Composer\Downloader\DownloadManager;
  7655. use Composer\EventDispatcher\EventDispatcher;
  7656. use Composer\Autoload\AutoloadGenerator;
  7657. use Composer\Package\Archiver\ArchiveManager;
  7658. class Composer
  7659. {
  7660. const VERSION = '2.0.7';
  7661. const BRANCH_ALIAS_VERSION = '';
  7662. const RELEASE_DATE = '2020-11-13 17:31:06';
  7663. const SOURCE_VERSION = '';
  7664. const RUNTIME_API_VERSION = '2.0.0';
  7665. public static function getVersion()
  7666. {
  7667. if (self::VERSION === '@package_version'.'@') {
  7668. return self::SOURCE_VERSION;
  7669. }
  7670. if (self::BRANCH_ALIAS_VERSION !== '' && preg_match('{^[a-f0-9]{40}$}', self::VERSION)) {
  7671. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  7672. }
  7673. return self::VERSION;
  7674. }
  7675. private $package;
  7676. private $locker;
  7677. private $loop;
  7678. private $repositoryManager;
  7679. private $downloadManager;
  7680. private $installationManager;
  7681. private $pluginManager;
  7682. private $config;
  7683. private $eventDispatcher;
  7684. private $autoloadGenerator;
  7685. private $archiveManager;
  7686. public function setPackage(RootPackageInterface $package)
  7687. {
  7688. $this->package = $package;
  7689. }
  7690. public function getPackage()
  7691. {
  7692. return $this->package;
  7693. }
  7694. public function setConfig(Config $config)
  7695. {
  7696. $this->config = $config;
  7697. }
  7698. public function getConfig()
  7699. {
  7700. return $this->config;
  7701. }
  7702. public function setLocker(Locker $locker)
  7703. {
  7704. $this->locker = $locker;
  7705. }
  7706. public function getLocker()
  7707. {
  7708. return $this->locker;
  7709. }
  7710. public function setLoop(Loop $loop)
  7711. {
  7712. $this->loop = $loop;
  7713. }
  7714. public function getLoop()
  7715. {
  7716. return $this->loop;
  7717. }
  7718. public function setRepositoryManager(RepositoryManager $manager)
  7719. {
  7720. $this->repositoryManager = $manager;
  7721. }
  7722. public function getRepositoryManager()
  7723. {
  7724. return $this->repositoryManager;
  7725. }
  7726. public function setDownloadManager(DownloadManager $manager)
  7727. {
  7728. $this->downloadManager = $manager;
  7729. }
  7730. public function getDownloadManager()
  7731. {
  7732. return $this->downloadManager;
  7733. }
  7734. public function setArchiveManager(ArchiveManager $manager)
  7735. {
  7736. $this->archiveManager = $manager;
  7737. }
  7738. public function getArchiveManager()
  7739. {
  7740. return $this->archiveManager;
  7741. }
  7742. public function setInstallationManager(InstallationManager $manager)
  7743. {
  7744. $this->installationManager = $manager;
  7745. }
  7746. public function getInstallationManager()
  7747. {
  7748. return $this->installationManager;
  7749. }
  7750. public function setPluginManager(PluginManager $manager)
  7751. {
  7752. $this->pluginManager = $manager;
  7753. }
  7754. public function getPluginManager()
  7755. {
  7756. return $this->pluginManager;
  7757. }
  7758. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  7759. {
  7760. $this->eventDispatcher = $eventDispatcher;
  7761. }
  7762. public function getEventDispatcher()
  7763. {
  7764. return $this->eventDispatcher;
  7765. }
  7766. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  7767. {
  7768. $this->autoloadGenerator = $autoloadGenerator;
  7769. }
  7770. public function getAutoloadGenerator()
  7771. {
  7772. return $this->autoloadGenerator;
  7773. }
  7774. }
  7775. <?php
  7776. namespace Composer;
  7777. use Composer\Config\ConfigSourceInterface;
  7778. use Composer\Downloader\TransportException;
  7779. use Composer\IO\IOInterface;
  7780. use Composer\Util\Platform;
  7781. use Composer\Util\ProcessExecutor;
  7782. class Config
  7783. {
  7784. const RELATIVE_PATHS = 1;
  7785. public static $defaultConfig = array(
  7786. 'process-timeout' => 300,
  7787. 'use-include-path' => false,
  7788. 'preferred-install' => 'auto',
  7789. 'notify-on-install' => true,
  7790. 'github-protocols' => array('https', 'ssh', 'git'),
  7791. 'vendor-dir' => 'vendor',
  7792. 'bin-dir' => '{$vendor-dir}/bin',
  7793. 'cache-dir' => '{$home}/cache',
  7794. 'data-dir' => '{$home}',
  7795. 'cache-files-dir' => '{$cache-dir}/files',
  7796. 'cache-repo-dir' => '{$cache-dir}/repo',
  7797. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  7798. 'cache-ttl' => 15552000,
  7799. 'cache-files-ttl' => null,
  7800. 'cache-files-maxsize' => '300MiB',
  7801. 'cache-read-only' => false,
  7802. 'bin-compat' => 'auto',
  7803. 'discard-changes' => false,
  7804. 'autoloader-suffix' => null,
  7805. 'sort-packages' => false,
  7806. 'optimize-autoloader' => false,
  7807. 'classmap-authoritative' => false,
  7808. 'apcu-autoloader' => false,
  7809. 'prepend-autoloader' => true,
  7810. 'github-domains' => array('github.com'),
  7811. 'bitbucket-expose-hostname' => true,
  7812. 'disable-tls' => false,
  7813. 'secure-http' => true,
  7814. 'cafile' => null,
  7815. 'capath' => null,
  7816. 'github-expose-hostname' => true,
  7817. 'gitlab-domains' => array('gitlab.com'),
  7818. 'store-auths' => 'prompt',
  7819. 'platform' => array(),
  7820. 'archive-format' => 'tar',
  7821. 'archive-dir' => '.',
  7822. 'htaccess-protect' => true,
  7823. 'use-github-api' => true,
  7824. 'lock' => true,
  7825. 'platform-check' => 'php-only',
  7826. );
  7827. public static $defaultRepositories = array(
  7828. 'packagist.org' => array(
  7829. 'type' => 'composer',
  7830. 'url' => 'https?://repo.packagist.org',
  7831. 'allow_ssl_downgrade' => true,
  7832. ),
  7833. );
  7834. private $config;
  7835. private $baseDir;
  7836. private $repositories;
  7837. private $configSource;
  7838. private $authConfigSource;
  7839. private $useEnvironment;
  7840. private $warnedHosts = array();
  7841. public function __construct($useEnvironment = true, $baseDir = null)
  7842. {
  7843. $this->config = static::$defaultConfig;
  7844. $this->repositories = static::$defaultRepositories;
  7845. $this->useEnvironment = (bool) $useEnvironment;
  7846. $this->baseDir = $baseDir;
  7847. }
  7848. public function setConfigSource(ConfigSourceInterface $source)
  7849. {
  7850. $this->configSource = $source;
  7851. }
  7852. public function getConfigSource()
  7853. {
  7854. return $this->configSource;
  7855. }
  7856. public function setAuthConfigSource(ConfigSourceInterface $source)
  7857. {
  7858. $this->authConfigSource = $source;
  7859. }
  7860. public function getAuthConfigSource()
  7861. {
  7862. return $this->authConfigSource;
  7863. }
  7864. public function merge($config)
  7865. {
  7866. if (!empty($config['config']) && is_array($config['config'])) {
  7867. foreach ($config['config'] as $key => $val) {
  7868. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer')) && isset($this->config[$key])) {
  7869. $this->config[$key] = array_merge($this->config[$key], $val);
  7870. } elseif (in_array($key, array('gitlab-domains', 'github-domains')) && isset($this->config[$key])) {
  7871. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  7872. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  7873. if (is_array($val) || is_array($this->config[$key])) {
  7874. if (is_string($val)) {
  7875. $val = array('*' => $val);
  7876. }
  7877. if (is_string($this->config[$key])) {
  7878. $this->config[$key] = array('*' => $this->config[$key]);
  7879. }
  7880. $this->config[$key] = array_merge($this->config[$key], $val);
  7881. if (isset($this->config[$key]['*'])) {
  7882. $wildcard = $this->config[$key]['*'];
  7883. unset($this->config[$key]['*']);
  7884. $this->config[$key]['*'] = $wildcard;
  7885. }
  7886. } else {
  7887. $this->config[$key] = $val;
  7888. }
  7889. } else {
  7890. $this->config[$key] = $val;
  7891. }
  7892. }
  7893. }
  7894. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  7895. $this->repositories = array_reverse($this->repositories, true);
  7896. $newRepos = array_reverse($config['repositories'], true);
  7897. foreach ($newRepos as $name => $repository) {
  7898. if (false === $repository) {
  7899. $this->disableRepoByName($name);
  7900. continue;
  7901. }
  7902. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  7903. $this->disableRepoByName(key($repository));
  7904. continue;
  7905. }
  7906. if (is_int($name)) {
  7907. $this->repositories[] = $repository;
  7908. } else {
  7909. if ($name === 'packagist') {
  7910. $this->repositories[$name . '.org'] = $repository;
  7911. } else {
  7912. $this->repositories[$name] = $repository;
  7913. }
  7914. }
  7915. }
  7916. $this->repositories = array_reverse($this->repositories, true);
  7917. }
  7918. }
  7919. public function getRepositories()
  7920. {
  7921. return $this->repositories;
  7922. }
  7923. public function get($key, $flags = 0)
  7924. {
  7925. switch ($key) {
  7926. case 'vendor-dir':
  7927. case 'bin-dir':
  7928. case 'process-timeout':
  7929. case 'data-dir':
  7930. case 'cache-dir':
  7931. case 'cache-files-dir':
  7932. case 'cache-repo-dir':
  7933. case 'cache-vcs-dir':
  7934. case 'cafile':
  7935. case 'capath':
  7936. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7937. $val = $this->getComposerEnv($env);
  7938. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  7939. $val = Platform::expandPath($val);
  7940. if (substr($key, -4) !== '-dir') {
  7941. return $val;
  7942. }
  7943. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  7944. case 'cache-read-only':
  7945. case 'htaccess-protect':
  7946. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7947. $val = $this->getComposerEnv($env);
  7948. if (false === $val) {
  7949. $val = $this->config[$key];
  7950. }
  7951. return $val !== 'false' && (bool) $val;
  7952. case 'disable-tls':
  7953. case 'secure-http':
  7954. case 'use-github-api':
  7955. case 'lock':
  7956. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  7957. return false;
  7958. }
  7959. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  7960. case 'cache-ttl':
  7961. return (int) $this->config[$key];
  7962. case 'cache-files-maxsize':
  7963. if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  7964. throw new \RuntimeException(
  7965. "Could not parse the value of '$key': {$this->config[$key]}"
  7966. );
  7967. }
  7968. $size = $matches[1];
  7969. if (isset($matches[2])) {
  7970. switch (strtolower($matches[2])) {
  7971. case 'g':
  7972. $size *= 1024;
  7973. case 'm':
  7974. $size *= 1024;
  7975. case 'k':
  7976. $size *= 1024;
  7977. break;
  7978. }
  7979. }
  7980. return $size;
  7981. case 'cache-files-ttl':
  7982. if (isset($this->config[$key])) {
  7983. return (int) $this->config[$key];
  7984. }
  7985. return (int) $this->config['cache-ttl'];
  7986. case 'home':
  7987. $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  7988. return rtrim($this->process($val, $flags), '/\\');
  7989. case 'bin-compat':
  7990. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  7991. if (!in_array($value, array('auto', 'full'))) {
  7992. throw new \RuntimeException(
  7993. "Invalid value for 'bin-compat': {$value}. Expected auto, full"
  7994. );
  7995. }
  7996. return $value;
  7997. case 'discard-changes':
  7998. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  7999. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  8000. throw new \RuntimeException(
  8001. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  8002. );
  8003. }
  8004. if ('stash' === $env) {
  8005. return 'stash';
  8006. }
  8007. return $env !== 'false' && (bool) $env;
  8008. }
  8009. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  8010. throw new \RuntimeException(
  8011. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  8012. );
  8013. }
  8014. return $this->config[$key];
  8015. case 'github-protocols':
  8016. $protos = $this->config['github-protocols'];
  8017. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  8018. unset($protos[$index]);
  8019. }
  8020. if (reset($protos) === 'http') {
  8021. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  8022. }
  8023. return $protos;
  8024. default:
  8025. if (!isset($this->config[$key])) {
  8026. return null;
  8027. }
  8028. return $this->process($this->config[$key], $flags);
  8029. }
  8030. }
  8031. public function all($flags = 0)
  8032. {
  8033. $all = array(
  8034. 'repositories' => $this->getRepositories(),
  8035. );
  8036. foreach (array_keys($this->config) as $key) {
  8037. $all['config'][$key] = $this->get($key, $flags);
  8038. }
  8039. return $all;
  8040. }
  8041. public function raw()
  8042. {
  8043. return array(
  8044. 'repositories' => $this->getRepositories(),
  8045. 'config' => $this->config,
  8046. );
  8047. }
  8048. public function has($key)
  8049. {
  8050. return array_key_exists($key, $this->config);
  8051. }
  8052. private function process($value, $flags)
  8053. {
  8054. $config = $this;
  8055. if (!is_string($value)) {
  8056. return $value;
  8057. }
  8058. return preg_replace_callback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  8059. return $config->get($match[1], $flags);
  8060. }, $value);
  8061. }
  8062. private function realpath($path)
  8063. {
  8064. if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  8065. return $path;
  8066. }
  8067. return $this->baseDir . '/' . $path;
  8068. }
  8069. private function getComposerEnv($var)
  8070. {
  8071. if ($this->useEnvironment) {
  8072. return getenv($var);
  8073. }
  8074. return false;
  8075. }
  8076. private function disableRepoByName($name)
  8077. {
  8078. if (isset($this->repositories[$name])) {
  8079. unset($this->repositories[$name]);
  8080. } elseif ($name === 'packagist') {
  8081. unset($this->repositories['packagist.org']);
  8082. }
  8083. }
  8084. public function prohibitUrlByConfig($url, IOInterface $io = null)
  8085. {
  8086. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  8087. return;
  8088. }
  8089. $scheme = parse_url($url, PHP_URL_SCHEME);
  8090. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  8091. if ($this->get('secure-http')) {
  8092. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  8093. }
  8094. if ($io) {
  8095. $host = parse_url($url, PHP_URL_HOST);
  8096. if (!isset($this->warnedHosts[$host])) {
  8097. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  8098. }
  8099. $this->warnedHosts[$host] = true;
  8100. }
  8101. }
  8102. }
  8103. public static function disableProcessTimeout()
  8104. {
  8105. ProcessExecutor::setTimeout(0);
  8106. }
  8107. }
  8108. <?php
  8109. namespace Composer\Config;
  8110. interface ConfigSourceInterface
  8111. {
  8112. public function addRepository($name, $config, $append = true);
  8113. public function removeRepository($name);
  8114. public function addConfigSetting($name, $value);
  8115. public function removeConfigSetting($name);
  8116. public function addProperty($name, $value);
  8117. public function removeProperty($name);
  8118. public function addLink($type, $name, $value);
  8119. public function removeLink($type, $name);
  8120. public function getName();
  8121. }
  8122. <?php
  8123. namespace Composer\Config;
  8124. use Composer\Json\JsonFile;
  8125. use Composer\Json\JsonManipulator;
  8126. use Composer\Util\Silencer;
  8127. class JsonConfigSource implements ConfigSourceInterface
  8128. {
  8129. private $file;
  8130. private $authConfig;
  8131. public function __construct(JsonFile $file, $authConfig = false)
  8132. {
  8133. $this->file = $file;
  8134. $this->authConfig = $authConfig;
  8135. }
  8136. public function getName()
  8137. {
  8138. return $this->file->getPath();
  8139. }
  8140. public function addRepository($name, $config, $append = true)
  8141. {
  8142. $this->manipulateJson('addRepository', $name, $config, $append, function (&$config, $repo, $repoConfig) use ($append) {
  8143. if (isset($config['repositories'])) {
  8144. foreach ($config['repositories'] as $index => $val) {
  8145. if ($index === $repo) {
  8146. continue;
  8147. }
  8148. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  8149. unset($config['repositories'][$index]);
  8150. $config['repositories']['packagist.org'] = false;
  8151. break;
  8152. }
  8153. }
  8154. }
  8155. if ($append) {
  8156. $config['repositories'][$repo] = $repoConfig;
  8157. } else {
  8158. $config['repositories'] = array($repo => $repoConfig) + $config['repositories'];
  8159. }
  8160. });
  8161. }
  8162. public function removeRepository($name)
  8163. {
  8164. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  8165. unset($config['repositories'][$repo]);
  8166. });
  8167. }
  8168. public function addConfigSetting($name, $value)
  8169. {
  8170. $authConfig = $this->authConfig;
  8171. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  8172. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8173. list($key, $host) = explode('.', $key, 2);
  8174. if ($authConfig) {
  8175. $config[$key][$host] = $val;
  8176. } else {
  8177. $config['config'][$key][$host] = $val;
  8178. }
  8179. } else {
  8180. $config['config'][$key] = $val;
  8181. }
  8182. });
  8183. }
  8184. public function removeConfigSetting($name)
  8185. {
  8186. $authConfig = $this->authConfig;
  8187. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  8188. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8189. list($key, $host) = explode('.', $key, 2);
  8190. if ($authConfig) {
  8191. unset($config[$key][$host]);
  8192. } else {
  8193. unset($config['config'][$key][$host]);
  8194. }
  8195. } else {
  8196. unset($config['config'][$key]);
  8197. }
  8198. });
  8199. }
  8200. public function addProperty($name, $value)
  8201. {
  8202. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  8203. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8204. $bits = explode('.', $key);
  8205. $last = array_pop($bits);
  8206. $arr = &$config[reset($bits)];
  8207. foreach ($bits as $bit) {
  8208. if (!isset($arr[$bit])) {
  8209. $arr[$bit] = array();
  8210. }
  8211. $arr = &$arr[$bit];
  8212. }
  8213. $arr[$last] = $val;
  8214. } else {
  8215. $config[$key] = $val;
  8216. }
  8217. });
  8218. }
  8219. public function removeProperty($name)
  8220. {
  8221. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  8222. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8223. $bits = explode('.', $key);
  8224. $last = array_pop($bits);
  8225. $arr = &$config[reset($bits)];
  8226. foreach ($bits as $bit) {
  8227. if (!isset($arr[$bit])) {
  8228. return;
  8229. }
  8230. $arr = &$arr[$bit];
  8231. }
  8232. unset($arr[$last]);
  8233. } else {
  8234. unset($config[$key]);
  8235. }
  8236. });
  8237. }
  8238. public function addLink($type, $name, $value)
  8239. {
  8240. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  8241. $config[$type][$name] = $value;
  8242. });
  8243. }
  8244. public function removeLink($type, $name)
  8245. {
  8246. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  8247. unset($config[$type][$name]);
  8248. });
  8249. $this->manipulateJson('removeMainKeyIfEmpty', $type, function (&$config, $type) {
  8250. if (0 === count($config[$type])) {
  8251. unset($config[$type]);
  8252. }
  8253. });
  8254. }
  8255. protected function manipulateJson($method, $args, $fallback)
  8256. {
  8257. $args = func_get_args();
  8258. array_shift($args);
  8259. $fallback = array_pop($args);
  8260. if ($this->file->exists()) {
  8261. if (!is_writable($this->file->getPath())) {
  8262. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  8263. }
  8264. if (!is_readable($this->file->getPath())) {
  8265. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  8266. }
  8267. $contents = file_get_contents($this->file->getPath());
  8268. } elseif ($this->authConfig) {
  8269. $contents = "{\n}\n";
  8270. } else {
  8271. $contents = "{\n \"config\": {\n }\n}\n";
  8272. }
  8273. $manipulator = new JsonManipulator($contents);
  8274. $newFile = !$this->file->exists();
  8275. if ($this->authConfig && $method === 'addConfigSetting') {
  8276. $method = 'addSubNode';
  8277. list($mainNode, $name) = explode('.', $args[0], 2);
  8278. $args = array($mainNode, $name, $args[1]);
  8279. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  8280. $method = 'removeSubNode';
  8281. list($mainNode, $name) = explode('.', $args[0], 2);
  8282. $args = array($mainNode, $name);
  8283. }
  8284. if (call_user_func_array(array($manipulator, $method), $args)) {
  8285. file_put_contents($this->file->getPath(), $manipulator->getContents());
  8286. } else {
  8287. $config = $this->file->read();
  8288. $this->arrayUnshiftRef($args, $config);
  8289. call_user_func_array($fallback, $args);
  8290. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev') as $linkType) {
  8291. if (isset($config[$linkType]) && $config[$linkType] === array()) {
  8292. $config[$linkType] = new \stdClass;
  8293. }
  8294. }
  8295. $this->file->write($config);
  8296. }
  8297. if ($newFile) {
  8298. Silencer::call('chmod', $this->file->getPath(), 0600);
  8299. }
  8300. }
  8301. private function arrayUnshiftRef(&$array, &$value)
  8302. {
  8303. $return = array_unshift($array, '');
  8304. $array[0] = &$value;
  8305. return $return;
  8306. }
  8307. }
  8308. <?php
  8309. namespace Composer\Console;
  8310. use Composer\IO\NullIO;
  8311. use Composer\Util\Platform;
  8312. use Composer\Util\Silencer;
  8313. use Symfony\Component\Console\Application as BaseApplication;
  8314. use Symfony\Component\Console\Exception\CommandNotFoundException;
  8315. use Symfony\Component\Console\Helper\HelperSet;
  8316. use Symfony\Component\Console\Helper\QuestionHelper;
  8317. use Symfony\Component\Console\Input\InputInterface;
  8318. use Symfony\Component\Console\Input\InputOption;
  8319. use Symfony\Component\Console\Output\OutputInterface;
  8320. use Seld\JsonLint\ParsingException;
  8321. use Composer\Command;
  8322. use Composer\Composer;
  8323. use Composer\Factory;
  8324. use Composer\IO\IOInterface;
  8325. use Composer\IO\ConsoleIO;
  8326. use Composer\Json\JsonValidationException;
  8327. use Composer\Util\ErrorHandler;
  8328. use Composer\Util\HttpDownloader;
  8329. use Composer\EventDispatcher\ScriptExecutionException;
  8330. use Composer\Exception\NoSslException;
  8331. class Application extends BaseApplication
  8332. {
  8333. protected $composer;
  8334. protected $io;
  8335. private static $logo = ' ______
  8336. / ____/___ ____ ___ ____ ____ ________ _____
  8337. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  8338. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  8339. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  8340. /_/
  8341. ';
  8342. private $hasPluginCommands = false;
  8343. private $disablePluginsByDefault = false;
  8344. private $initialWorkingDirectory;
  8345. public function __construct()
  8346. {
  8347. static $shutdownRegistered = false;
  8348. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  8349. ini_set('xdebug.show_exception_trace', false);
  8350. ini_set('xdebug.scream', false);
  8351. }
  8352. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  8353. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  8354. }
  8355. if (!$shutdownRegistered) {
  8356. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  8357. pcntl_async_signals(true);
  8358. pcntl_signal(SIGINT, function ($sig) {
  8359. exit(130);
  8360. });
  8361. }
  8362. $shutdownRegistered = true;
  8363. register_shutdown_function(function () {
  8364. $lastError = error_get_last();
  8365. if ($lastError && $lastError['message'] &&
  8366. (strpos($lastError['message'], 'Allowed memory') !== false ||
  8367. strpos($lastError['message'], 'exceeded memory') !== false )) {
  8368. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  8369. }
  8370. });
  8371. }
  8372. $this->io = new NullIO();
  8373. $this->initialWorkingDirectory = getcwd();
  8374. parent::__construct('Composer', Composer::getVersion());
  8375. }
  8376. public function run(InputInterface $input = null, OutputInterface $output = null)
  8377. {
  8378. if (null === $output) {
  8379. $output = Factory::createOutput();
  8380. }
  8381. return parent::run($input, $output);
  8382. }
  8383. public function doRun(InputInterface $input, OutputInterface $output)
  8384. {
  8385. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  8386. if (getenv('COMPOSER_NO_INTERACTION') || !Platform::isTty(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'))) {
  8387. $input->setInteractive(false);
  8388. }
  8389. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  8390. new QuestionHelper(),
  8391. )));
  8392. ErrorHandler::register($io);
  8393. if ($input->hasParameterOption('--no-cache')) {
  8394. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  8395. $_SERVER['COMPOSER_CACHE_DIR'] = Platform::isWindows() ? 'nul' : '/dev/null';
  8396. putenv('COMPOSER_CACHE_DIR='.$_SERVER['COMPOSER_CACHE_DIR']);
  8397. }
  8398. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  8399. $oldWorkingDir = getcwd();
  8400. chdir($newWorkDir);
  8401. $this->initialWorkingDirectory = $newWorkDir;
  8402. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  8403. }
  8404. $commandName = '';
  8405. if ($name = $this->getCommandName($input)) {
  8406. try {
  8407. $commandName = $this->find($name)->getName();
  8408. } catch (CommandNotFoundException $e) {
  8409. $commandName = false;
  8410. } catch (\InvalidArgumentException $e) {
  8411. }
  8412. }
  8413. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile())) {
  8414. $dir = dirname(getcwd());
  8415. $home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
  8416. while (dirname($dir) !== $dir && $dir !== $home) {
  8417. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  8418. if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  8419. $oldWorkingDir = getcwd();
  8420. chdir($dir);
  8421. }
  8422. break;
  8423. }
  8424. $dir = dirname($dir);
  8425. }
  8426. }
  8427. if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) {
  8428. try {
  8429. foreach ($this->getPluginCommands() as $command) {
  8430. if ($this->has($command->getName())) {
  8431. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  8432. } else {
  8433. $this->add($command);
  8434. }
  8435. }
  8436. } catch (NoSslException $e) {
  8437. } catch (ParsingException $e) {
  8438. $details = $e->getDetails();
  8439. $file = realpath(Factory::getComposerFile());
  8440. $line = null;
  8441. if ($details && isset($details['line'])) {
  8442. $line = $details['line'];
  8443. }
  8444. $ghe = new GithubActionError($this->io);
  8445. $ghe->emit($e->getMessage(), $file, $line);
  8446. throw $e;
  8447. }
  8448. $this->hasPluginCommands = true;
  8449. }
  8450. $isProxyCommand = false;
  8451. if ($name = $this->getCommandName($input)) {
  8452. try {
  8453. $command = $this->find($name);
  8454. $commandName = $command->getName();
  8455. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  8456. } catch (\InvalidArgumentException $e) {
  8457. }
  8458. }
  8459. if (!$isProxyCommand) {
  8460. $io->writeError(sprintf(
  8461. 'Running %s (%s) with %s on %s',
  8462. Composer::getVersion(),
  8463. Composer::RELEASE_DATE,
  8464. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  8465. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  8466. ), true, IOInterface::DEBUG);
  8467. if (PHP_VERSION_ID < 50302) {
  8468. $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>');
  8469. }
  8470. if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  8471. $io->writeError('<warning>You are running composer with Xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug</warning>');
  8472. }
  8473. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  8474. $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']));
  8475. }
  8476. if (
  8477. !Platform::isWindows()
  8478. && function_exists('exec')
  8479. && !getenv('COMPOSER_ALLOW_SUPERUSER')
  8480. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  8481. ) {
  8482. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  8483. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  8484. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  8485. if ($io->isInteractive()) {
  8486. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  8487. return 1;
  8488. }
  8489. }
  8490. }
  8491. if ($uid = (int) getenv('SUDO_UID')) {
  8492. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  8493. }
  8494. }
  8495. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  8496. }
  8497. Silencer::call(function () use ($io) {
  8498. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  8499. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  8500. $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()));
  8501. }
  8502. });
  8503. $file = Factory::getComposerFile();
  8504. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  8505. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  8506. foreach ($composer['scripts'] as $script => $dummy) {
  8507. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  8508. if ($this->has($script)) {
  8509. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  8510. } else {
  8511. $description = null;
  8512. if (isset($composer['scripts-descriptions'][$script])) {
  8513. $description = $composer['scripts-descriptions'][$script];
  8514. }
  8515. $this->add(new Command\ScriptAliasCommand($script, $description));
  8516. }
  8517. }
  8518. }
  8519. }
  8520. }
  8521. }
  8522. try {
  8523. if ($input->hasParameterOption('--profile')) {
  8524. $startTime = microtime(true);
  8525. $this->io->enableDebugging($startTime);
  8526. }
  8527. $result = parent::doRun($input, $output);
  8528. if (isset($oldWorkingDir)) {
  8529. chdir($oldWorkingDir);
  8530. }
  8531. if (isset($startTime)) {
  8532. $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');
  8533. }
  8534. restore_error_handler();
  8535. return $result;
  8536. } catch (ScriptExecutionException $e) {
  8537. return (int) $e->getCode();
  8538. } catch (\Exception $e) {
  8539. $ghe = new GithubActionError($this->io);
  8540. $ghe->emit($e->getMessage());
  8541. $this->hintCommonErrors($e);
  8542. restore_error_handler();
  8543. throw $e;
  8544. }
  8545. }
  8546. private function getNewWorkingDir(InputInterface $input)
  8547. {
  8548. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  8549. if (false !== $workingDir && !is_dir($workingDir)) {
  8550. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  8551. }
  8552. return $workingDir;
  8553. }
  8554. private function hintCommonErrors($exception)
  8555. {
  8556. $io = $this->getIO();
  8557. Silencer::suppress();
  8558. try {
  8559. $composer = $this->getComposer(false, true);
  8560. if ($composer) {
  8561. $config = $composer->getConfig();
  8562. $minSpaceFree = 1024 * 1024;
  8563. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  8564. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  8565. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  8566. ) {
  8567. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  8568. }
  8569. }
  8570. } catch (\Exception $e) {
  8571. }
  8572. Silencer::restore();
  8573. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  8574. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  8575. $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);
  8576. }
  8577. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  8578. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  8579. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  8580. }
  8581. if ($hints = HttpDownloader::getExceptionHints($exception)) {
  8582. foreach ($hints as $hint) {
  8583. $io->writeError($hint, true, IOInterface::QUIET);
  8584. }
  8585. }
  8586. }
  8587. public function getComposer($required = true, $disablePlugins = null)
  8588. {
  8589. if (null === $disablePlugins) {
  8590. $disablePlugins = $this->disablePluginsByDefault;
  8591. }
  8592. if (null === $this->composer) {
  8593. try {
  8594. $this->composer = Factory::create($this->io, null, $disablePlugins);
  8595. } catch (\InvalidArgumentException $e) {
  8596. if ($required) {
  8597. $this->io->writeError($e->getMessage());
  8598. exit(1);
  8599. }
  8600. } catch (JsonValidationException $e) {
  8601. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  8602. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  8603. throw new JsonValidationException($message);
  8604. }
  8605. }
  8606. return $this->composer;
  8607. }
  8608. public function resetComposer()
  8609. {
  8610. $this->composer = null;
  8611. if ($this->getIO() && method_exists($this->getIO(), 'resetAuthentications')) {
  8612. $this->getIO()->resetAuthentications();
  8613. }
  8614. }
  8615. public function getIO()
  8616. {
  8617. return $this->io;
  8618. }
  8619. public function getHelp()
  8620. {
  8621. return self::$logo . parent::getHelp();
  8622. }
  8623. protected function getDefaultCommands()
  8624. {
  8625. $commands = array_merge(parent::getDefaultCommands(), array(
  8626. new Command\AboutCommand(),
  8627. new Command\ConfigCommand(),
  8628. new Command\DependsCommand(),
  8629. new Command\ProhibitsCommand(),
  8630. new Command\InitCommand(),
  8631. new Command\InstallCommand(),
  8632. new Command\CreateProjectCommand(),
  8633. new Command\UpdateCommand(),
  8634. new Command\SearchCommand(),
  8635. new Command\ValidateCommand(),
  8636. new Command\ShowCommand(),
  8637. new Command\SuggestsCommand(),
  8638. new Command\RequireCommand(),
  8639. new Command\DumpAutoloadCommand(),
  8640. new Command\StatusCommand(),
  8641. new Command\ArchiveCommand(),
  8642. new Command\DiagnoseCommand(),
  8643. new Command\RunScriptCommand(),
  8644. new Command\LicensesCommand(),
  8645. new Command\GlobalCommand(),
  8646. new Command\ClearCacheCommand(),
  8647. new Command\RemoveCommand(),
  8648. new Command\HomeCommand(),
  8649. new Command\ExecCommand(),
  8650. new Command\OutdatedCommand(),
  8651. new Command\CheckPlatformReqsCommand(),
  8652. new Command\FundCommand(),
  8653. ));
  8654. if (strpos(__FILE__, 'phar:') === 0) {
  8655. $commands[] = new Command\SelfUpdateCommand();
  8656. }
  8657. return $commands;
  8658. }
  8659. public function getLongVersion()
  8660. {
  8661. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  8662. return sprintf(
  8663. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  8664. $this->getName(),
  8665. Composer::BRANCH_ALIAS_VERSION,
  8666. $this->getVersion(),
  8667. Composer::RELEASE_DATE
  8668. );
  8669. }
  8670. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  8671. }
  8672. protected function getDefaultInputDefinition()
  8673. {
  8674. $definition = parent::getDefaultInputDefinition();
  8675. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  8676. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  8677. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  8678. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  8679. return $definition;
  8680. }
  8681. private function getPluginCommands()
  8682. {
  8683. $commands = array();
  8684. $composer = $this->getComposer(false, false);
  8685. if (null === $composer) {
  8686. $composer = Factory::createGlobal($this->io);
  8687. }
  8688. if (null !== $composer) {
  8689. $pm = $composer->getPluginManager();
  8690. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  8691. $newCommands = $capability->getCommands();
  8692. if (!is_array($newCommands)) {
  8693. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  8694. }
  8695. foreach ($newCommands as $command) {
  8696. if (!$command instanceof Command\BaseCommand) {
  8697. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  8698. }
  8699. }
  8700. $commands = array_merge($commands, $newCommands);
  8701. }
  8702. }
  8703. return $commands;
  8704. }
  8705. public function getInitialWorkingDirectory()
  8706. {
  8707. return $this->initialWorkingDirectory;
  8708. }
  8709. }
  8710. <?php
  8711. namespace Composer\Console;
  8712. use Composer\IO\IOInterface;
  8713. final class GithubActionError
  8714. {
  8715. protected $io;
  8716. public function __construct(IOInterface $io)
  8717. {
  8718. $this->io = $io;
  8719. }
  8720. public function emit($message, $file = null, $line = null)
  8721. {
  8722. if (getenv('GITHUB_ACTIONS') && !getenv('COMPOSER_TESTS_ARE_RUNNING')) {
  8723. $message = str_replace("\n", '%0A', $message);
  8724. if ($file && $line) {
  8725. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  8726. } elseif ($file) {
  8727. $this->io->write("::error file=". $file ."::". $message);
  8728. } else {
  8729. $this->io->write("::error ::". $message);
  8730. }
  8731. }
  8732. }
  8733. }
  8734. <?php
  8735. namespace Composer\Console;
  8736. use Symfony\Component\Console\Formatter\OutputFormatter;
  8737. class HtmlOutputFormatter extends OutputFormatter
  8738. {
  8739. private static $availableForegroundColors = array(
  8740. 30 => 'black',
  8741. 31 => 'red',
  8742. 32 => 'green',
  8743. 33 => 'yellow',
  8744. 34 => 'blue',
  8745. 35 => 'magenta',
  8746. 36 => 'cyan',
  8747. 37 => 'white',
  8748. );
  8749. private static $availableBackgroundColors = array(
  8750. 40 => 'black',
  8751. 41 => 'red',
  8752. 42 => 'green',
  8753. 43 => 'yellow',
  8754. 44 => 'blue',
  8755. 45 => 'magenta',
  8756. 46 => 'cyan',
  8757. 47 => 'white',
  8758. );
  8759. private static $availableOptions = array(
  8760. 1 => 'bold',
  8761. 4 => 'underscore',
  8762. );
  8763. public function __construct(array $styles = array())
  8764. {
  8765. parent::__construct(true, $styles);
  8766. }
  8767. public function format($message)
  8768. {
  8769. $formatted = parent::format($message);
  8770. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  8771. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  8772. }
  8773. private function formatHtml($matches)
  8774. {
  8775. $out = '<span style="';
  8776. foreach (explode(';', $matches[1]) as $code) {
  8777. if (isset(self::$availableForegroundColors[$code])) {
  8778. $out .= 'color:'.self::$availableForegroundColors[$code].';';
  8779. } elseif (isset(self::$availableBackgroundColors[$code])) {
  8780. $out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
  8781. } elseif (isset(self::$availableOptions[$code])) {
  8782. switch (self::$availableOptions[$code]) {
  8783. case 'bold':
  8784. $out .= 'font-weight:bold;';
  8785. break;
  8786. case 'underscore':
  8787. $out .= 'text-decoration:underline;';
  8788. break;
  8789. }
  8790. }
  8791. }
  8792. return $out.'">'.$matches[2].'</span>';
  8793. }
  8794. }
  8795. <?php
  8796. namespace Composer\DependencyResolver;
  8797. class Decisions implements \Iterator, \Countable
  8798. {
  8799. const DECISION_LITERAL = 0;
  8800. const DECISION_REASON = 1;
  8801. protected $pool;
  8802. protected $decisionMap;
  8803. protected $decisionQueue = array();
  8804. public function __construct($pool)
  8805. {
  8806. $this->pool = $pool;
  8807. $this->decisionMap = array();
  8808. }
  8809. public function decide($literal, $level, $why)
  8810. {
  8811. $this->addDecision($literal, $level);
  8812. $this->decisionQueue[] = array(
  8813. self::DECISION_LITERAL => $literal,
  8814. self::DECISION_REASON => $why,
  8815. );
  8816. }
  8817. public function satisfy($literal)
  8818. {
  8819. $packageId = abs($literal);
  8820. return (
  8821. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  8822. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  8823. );
  8824. }
  8825. public function conflict($literal)
  8826. {
  8827. $packageId = abs($literal);
  8828. return (
  8829. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  8830. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  8831. );
  8832. }
  8833. public function decided($literalOrPackageId)
  8834. {
  8835. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  8836. }
  8837. public function undecided($literalOrPackageId)
  8838. {
  8839. return empty($this->decisionMap[abs($literalOrPackageId)]);
  8840. }
  8841. public function decidedInstall($literalOrPackageId)
  8842. {
  8843. $packageId = abs($literalOrPackageId);
  8844. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  8845. }
  8846. public function decisionLevel($literalOrPackageId)
  8847. {
  8848. $packageId = abs($literalOrPackageId);
  8849. if (isset($this->decisionMap[$packageId])) {
  8850. return abs($this->decisionMap[$packageId]);
  8851. }
  8852. return 0;
  8853. }
  8854. public function decisionRule($literalOrPackageId)
  8855. {
  8856. $packageId = abs($literalOrPackageId);
  8857. foreach ($this->decisionQueue as $i => $decision) {
  8858. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  8859. return $decision[self::DECISION_REASON];
  8860. }
  8861. }
  8862. return null;
  8863. }
  8864. public function atOffset($queueOffset)
  8865. {
  8866. return $this->decisionQueue[$queueOffset];
  8867. }
  8868. public function validOffset($queueOffset)
  8869. {
  8870. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  8871. }
  8872. public function lastReason()
  8873. {
  8874. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  8875. }
  8876. public function lastLiteral()
  8877. {
  8878. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  8879. }
  8880. public function reset()
  8881. {
  8882. while ($decision = array_pop($this->decisionQueue)) {
  8883. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8884. }
  8885. }
  8886. public function resetToOffset($offset)
  8887. {
  8888. while (\count($this->decisionQueue) > $offset + 1) {
  8889. $decision = array_pop($this->decisionQueue);
  8890. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8891. }
  8892. }
  8893. public function revertLast()
  8894. {
  8895. $this->decisionMap[abs($this->lastLiteral())] = 0;
  8896. array_pop($this->decisionQueue);
  8897. }
  8898. public function count()
  8899. {
  8900. return \count($this->decisionQueue);
  8901. }
  8902. public function rewind()
  8903. {
  8904. end($this->decisionQueue);
  8905. }
  8906. public function current()
  8907. {
  8908. return current($this->decisionQueue);
  8909. }
  8910. public function key()
  8911. {
  8912. return key($this->decisionQueue);
  8913. }
  8914. public function next()
  8915. {
  8916. return prev($this->decisionQueue);
  8917. }
  8918. public function valid()
  8919. {
  8920. return false !== current($this->decisionQueue);
  8921. }
  8922. public function isEmpty()
  8923. {
  8924. return \count($this->decisionQueue) === 0;
  8925. }
  8926. protected function addDecision($literal, $level)
  8927. {
  8928. $packageId = abs($literal);
  8929. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  8930. if ($previousDecision != 0) {
  8931. $literalString = $this->pool->literalToPrettyString($literal, array());
  8932. $package = $this->pool->literalToPackage($literal);
  8933. throw new SolverBugException(
  8934. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  8935. );
  8936. }
  8937. if ($literal > 0) {
  8938. $this->decisionMap[$packageId] = $level;
  8939. } else {
  8940. $this->decisionMap[$packageId] = -$level;
  8941. }
  8942. }
  8943. public function __toString()
  8944. {
  8945. $decisionMap = $this->decisionMap;
  8946. ksort($decisionMap);
  8947. $str = '[';
  8948. foreach ($decisionMap as $packageId => $level) {
  8949. $str .= $packageId.':'.$level.',';
  8950. }
  8951. $str .= ']';
  8952. return $str;
  8953. }
  8954. }
  8955. <?php
  8956. namespace Composer\DependencyResolver;
  8957. use Composer\Package\PackageInterface;
  8958. use Composer\Package\AliasPackage;
  8959. use Composer\Package\BasePackage;
  8960. use Composer\Semver\Constraint\Constraint;
  8961. class DefaultPolicy implements PolicyInterface
  8962. {
  8963. private $preferStable;
  8964. private $preferLowest;
  8965. public function __construct($preferStable = false, $preferLowest = false)
  8966. {
  8967. $this->preferStable = $preferStable;
  8968. $this->preferLowest = $preferLowest;
  8969. }
  8970. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  8971. {
  8972. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  8973. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  8974. }
  8975. $constraint = new Constraint($operator, $b->getVersion());
  8976. $version = new Constraint('==', $a->getVersion());
  8977. return $constraint->matchSpecific($version, true);
  8978. }
  8979. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
  8980. {
  8981. $packages = $this->groupLiteralsByName($pool, $literals);
  8982. $policy = $this;
  8983. foreach ($packages as &$nameLiterals) {
  8984. usort($nameLiterals, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  8985. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  8986. });
  8987. }
  8988. foreach ($packages as &$sortedLiterals) {
  8989. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  8990. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  8991. }
  8992. $selected = \call_user_func_array('array_merge', array_values($packages));
  8993. usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  8994. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  8995. });
  8996. return $selected;
  8997. }
  8998. protected function groupLiteralsByName(Pool $pool, $literals)
  8999. {
  9000. $packages = array();
  9001. foreach ($literals as $literal) {
  9002. $packageName = $pool->literalToPackage($literal)->getName();
  9003. if (!isset($packages[$packageName])) {
  9004. $packages[$packageName] = array();
  9005. }
  9006. $packages[$packageName][] = $literal;
  9007. }
  9008. return $packages;
  9009. }
  9010. public function compareByPriority(Pool $pool, PackageInterface $a, PackageInterface $b, $requiredPackage = null, $ignoreReplace = false)
  9011. {
  9012. if ($a->getName() === $b->getName()) {
  9013. $aAliased = $a instanceof AliasPackage;
  9014. $bAliased = $b instanceof AliasPackage;
  9015. if ($aAliased && !$bAliased) {
  9016. return -1;
  9017. }
  9018. if (!$aAliased && $bAliased) {
  9019. return 1;
  9020. }
  9021. }
  9022. if (!$ignoreReplace) {
  9023. if ($this->replaces($a, $b)) {
  9024. return 1;
  9025. }
  9026. if ($this->replaces($b, $a)) {
  9027. return -1;
  9028. }
  9029. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  9030. $requiredVendor = substr($requiredPackage, 0, $pos);
  9031. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  9032. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  9033. if ($bIsSameVendor !== $aIsSameVendor) {
  9034. return $aIsSameVendor ? -1 : 1;
  9035. }
  9036. }
  9037. }
  9038. if ($a->id === $b->id) {
  9039. return 0;
  9040. }
  9041. return ($a->id < $b->id) ? -1 : 1;
  9042. }
  9043. protected function replaces(PackageInterface $source, PackageInterface $target)
  9044. {
  9045. foreach ($source->getReplaces() as $link) {
  9046. if ($link->getTarget() === $target->getName()
  9047. ) {
  9048. return true;
  9049. }
  9050. }
  9051. return false;
  9052. }
  9053. protected function pruneToBestVersion(Pool $pool, $literals)
  9054. {
  9055. $operator = $this->preferLowest ? '<' : '>';
  9056. $bestLiterals = array($literals[0]);
  9057. $bestPackage = $pool->literalToPackage($literals[0]);
  9058. foreach ($literals as $i => $literal) {
  9059. if (0 === $i) {
  9060. continue;
  9061. }
  9062. $package = $pool->literalToPackage($literal);
  9063. if ($this->versionCompare($package, $bestPackage, $operator)) {
  9064. $bestPackage = $package;
  9065. $bestLiterals = array($literal);
  9066. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  9067. $bestLiterals[] = $literal;
  9068. }
  9069. }
  9070. return $bestLiterals;
  9071. }
  9072. protected function pruneRemoteAliases(Pool $pool, array $literals)
  9073. {
  9074. $hasLocalAlias = false;
  9075. foreach ($literals as $literal) {
  9076. $package = $pool->literalToPackage($literal);
  9077. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9078. $hasLocalAlias = true;
  9079. break;
  9080. }
  9081. }
  9082. if (!$hasLocalAlias) {
  9083. return $literals;
  9084. }
  9085. $selected = array();
  9086. foreach ($literals as $literal) {
  9087. $package = $pool->literalToPackage($literal);
  9088. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9089. $selected[] = $literal;
  9090. }
  9091. }
  9092. return $selected;
  9093. }
  9094. }
  9095. <?php
  9096. namespace Composer\DependencyResolver;
  9097. use Composer\Package\PackageInterface;
  9098. use Composer\Package\Link;
  9099. class GenericRule extends Rule
  9100. {
  9101. protected $literals;
  9102. public function __construct(array $literals, $reason, $reasonData)
  9103. {
  9104. parent::__construct($reason, $reasonData);
  9105. sort($literals);
  9106. $this->literals = $literals;
  9107. }
  9108. public function getLiterals()
  9109. {
  9110. return $this->literals;
  9111. }
  9112. public function getHash()
  9113. {
  9114. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  9115. return $data['hash'];
  9116. }
  9117. public function equals(Rule $rule)
  9118. {
  9119. return $this->literals === $rule->getLiterals();
  9120. }
  9121. public function isAssertion()
  9122. {
  9123. return 1 === \count($this->literals);
  9124. }
  9125. public function __toString()
  9126. {
  9127. $result = $this->isDisabled() ? 'disabled(' : '(';
  9128. foreach ($this->literals as $i => $literal) {
  9129. if ($i != 0) {
  9130. $result .= '|';
  9131. }
  9132. $result .= $literal;
  9133. }
  9134. $result .= ')';
  9135. return $result;
  9136. }
  9137. }
  9138. <?php
  9139. namespace Composer\DependencyResolver;
  9140. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  9141. use Composer\DependencyResolver\Operation\UninstallOperation;
  9142. use Composer\Package\AliasPackage;
  9143. use Composer\Package\Link;
  9144. use Composer\Package\PackageInterface;
  9145. use Composer\Repository\PlatformRepository;
  9146. use Composer\Repository\RepositoryInterface;
  9147. use Composer\Semver\Constraint\Constraint;
  9148. class LocalRepoTransaction extends Transaction
  9149. {
  9150. public function __construct(RepositoryInterface $lockedRepository, $localRepository)
  9151. {
  9152. parent::__construct(
  9153. $localRepository->getPackages(),
  9154. $lockedRepository->getPackages()
  9155. );
  9156. }
  9157. }
  9158. <?php
  9159. namespace Composer\DependencyResolver;
  9160. use Composer\DependencyResolver\Operation\OperationInterface;
  9161. use Composer\Package\AliasPackage;
  9162. use Composer\Package\RootAliasPackage;
  9163. use Composer\Package\RootPackageInterface;
  9164. use Composer\Repository\ArrayRepository;
  9165. use Composer\Repository\RepositoryInterface;
  9166. use Composer\Test\Repository\ArrayRepositoryTest;
  9167. class LockTransaction extends Transaction
  9168. {
  9169. protected $presentMap;
  9170. protected $unlockableMap;
  9171. protected $resultPackages;
  9172. public function __construct(Pool $pool, $presentMap, $unlockableMap, $decisions)
  9173. {
  9174. $this->presentMap = $presentMap;
  9175. $this->unlockableMap = $unlockableMap;
  9176. $this->setResultPackages($pool, $decisions);
  9177. parent::__construct($this->presentMap, $this->resultPackages['all']);
  9178. }
  9179. public function setResultPackages(Pool $pool, Decisions $decisions)
  9180. {
  9181. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  9182. foreach ($decisions as $i => $decision) {
  9183. $literal = $decision[Decisions::DECISION_LITERAL];
  9184. if ($literal > 0) {
  9185. $package = $pool->literalToPackage($literal);
  9186. $this->resultPackages['all'][] = $package;
  9187. if (!isset($this->unlockableMap[$package->id])) {
  9188. $this->resultPackages['non-dev'][] = $package;
  9189. }
  9190. }
  9191. }
  9192. }
  9193. public function setNonDevPackages(LockTransaction $extractionResult)
  9194. {
  9195. $packages = $extractionResult->getNewLockPackages(false);
  9196. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  9197. $this->resultPackages['non-dev'] = array();
  9198. foreach ($packages as $package) {
  9199. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  9200. if ($package->getName() == $resultPackage->getName()) {
  9201. $this->resultPackages['non-dev'][] = $resultPackage;
  9202. unset($this->resultPackages['dev'][$i]);
  9203. }
  9204. }
  9205. }
  9206. }
  9207. public function getNewLockPackages($devMode, $updateMirrors = false)
  9208. {
  9209. $packages = array();
  9210. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  9211. if (!($package instanceof AliasPackage) && !($package instanceof RootAliasPackage)) {
  9212. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  9213. foreach ($this->presentMap as $presentPackage) {
  9214. if ($package->getName() == $presentPackage->getName() &&
  9215. $package->getVersion() == $presentPackage->getVersion() &&
  9216. $presentPackage->getSourceReference() &&
  9217. $presentPackage->getSourceType() === $package->getSourceType()
  9218. ) {
  9219. $package->setSourceDistReferences($presentPackage->getSourceReference());
  9220. }
  9221. }
  9222. }
  9223. $packages[] = $package;
  9224. }
  9225. }
  9226. return $packages;
  9227. }
  9228. public function getAliases($aliases)
  9229. {
  9230. $usedAliases = array();
  9231. foreach ($this->resultPackages['all'] as $package) {
  9232. if ($package instanceof AliasPackage) {
  9233. foreach ($aliases as $index => $alias) {
  9234. if ($alias['package'] === $package->getName()) {
  9235. $usedAliases[] = $alias;
  9236. unset($aliases[$index]);
  9237. }
  9238. }
  9239. }
  9240. }
  9241. usort($usedAliases, function ($a, $b) {
  9242. return strcmp($a['package'], $b['package']);
  9243. });
  9244. return $usedAliases;
  9245. }
  9246. }
  9247. <?php
  9248. namespace Composer\DependencyResolver;
  9249. use Composer\Package\PackageInterface;
  9250. use Composer\Package\Link;
  9251. class MultiConflictRule extends Rule
  9252. {
  9253. protected $literals;
  9254. public function __construct(array $literals, $reason, $reasonData)
  9255. {
  9256. parent::__construct($reason, $reasonData);
  9257. if (\count($literals) < 3) {
  9258. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  9259. }
  9260. sort($literals);
  9261. $this->literals = $literals;
  9262. }
  9263. public function getLiterals()
  9264. {
  9265. return $this->literals;
  9266. }
  9267. public function getHash()
  9268. {
  9269. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  9270. return $data['hash'];
  9271. }
  9272. public function equals(Rule $rule)
  9273. {
  9274. if ($rule instanceof MultiConflictRule) {
  9275. return $this->literals === $rule->getLiterals();
  9276. }
  9277. return false;
  9278. }
  9279. public function isAssertion()
  9280. {
  9281. return false;
  9282. }
  9283. public function disable()
  9284. {
  9285. 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.");
  9286. }
  9287. public function __toString()
  9288. {
  9289. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  9290. foreach ($this->literals as $i => $literal) {
  9291. if ($i != 0) {
  9292. $result .= '|';
  9293. }
  9294. $result .= $literal;
  9295. }
  9296. $result .= '))';
  9297. return $result;
  9298. }
  9299. }
  9300. <?php
  9301. namespace Composer\DependencyResolver\Operation;
  9302. use Composer\Package\PackageInterface;
  9303. class InstallOperation extends SolverOperation implements OperationInterface
  9304. {
  9305. const TYPE = 'install';
  9306. protected $package;
  9307. public function __construct(PackageInterface $package)
  9308. {
  9309. $this->package = $package;
  9310. }
  9311. public function getPackage()
  9312. {
  9313. return $this->package;
  9314. }
  9315. public function show($lock)
  9316. {
  9317. return self::format($this->package, $lock);
  9318. }
  9319. public static function format(PackageInterface $package, $lock = false)
  9320. {
  9321. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9322. }
  9323. }
  9324. <?php
  9325. namespace Composer\DependencyResolver\Operation;
  9326. use Composer\Package\AliasPackage;
  9327. use Composer\Package\PackageInterface;
  9328. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  9329. {
  9330. const TYPE = 'markAliasInstalled';
  9331. protected $package;
  9332. public function __construct(AliasPackage $package)
  9333. {
  9334. $this->package = $package;
  9335. }
  9336. public function getPackage()
  9337. {
  9338. return $this->package;
  9339. }
  9340. public function show($lock)
  9341. {
  9342. 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>)';
  9343. }
  9344. }
  9345. <?php
  9346. namespace Composer\DependencyResolver\Operation;
  9347. use Composer\Package\AliasPackage;
  9348. use Composer\Package\PackageInterface;
  9349. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  9350. {
  9351. const TYPE = 'markAliasUninstalled';
  9352. protected $package;
  9353. public function __construct(AliasPackage $package)
  9354. {
  9355. $this->package = $package;
  9356. }
  9357. public function getPackage()
  9358. {
  9359. return $this->package;
  9360. }
  9361. public function show($lock)
  9362. {
  9363. 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>)';
  9364. }
  9365. }
  9366. <?php
  9367. namespace Composer\DependencyResolver\Operation;
  9368. interface OperationInterface
  9369. {
  9370. public function getOperationType();
  9371. public function show($lock);
  9372. public function __toString();
  9373. }
  9374. <?php
  9375. namespace Composer\DependencyResolver\Operation;
  9376. use Composer\Package\PackageInterface;
  9377. abstract class SolverOperation implements OperationInterface
  9378. {
  9379. const TYPE = null;
  9380. public function getOperationType()
  9381. {
  9382. return static::TYPE;
  9383. }
  9384. public function __toString()
  9385. {
  9386. return $this->show(false);
  9387. }
  9388. }
  9389. <?php
  9390. namespace Composer\DependencyResolver\Operation;
  9391. use Composer\Package\PackageInterface;
  9392. class UninstallOperation extends SolverOperation implements OperationInterface
  9393. {
  9394. const TYPE = 'uninstall';
  9395. protected $package;
  9396. public function __construct(PackageInterface $package)
  9397. {
  9398. $this->package = $package;
  9399. }
  9400. public function getPackage()
  9401. {
  9402. return $this->package;
  9403. }
  9404. public function show($lock)
  9405. {
  9406. return self::format($this->package, $lock);
  9407. }
  9408. public static function format(PackageInterface $package, $lock = false)
  9409. {
  9410. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9411. }
  9412. }
  9413. <?php
  9414. namespace Composer\DependencyResolver\Operation;
  9415. use Composer\Package\PackageInterface;
  9416. use Composer\Package\Version\VersionParser;
  9417. class UpdateOperation extends SolverOperation implements OperationInterface
  9418. {
  9419. const TYPE = 'update';
  9420. protected $initialPackage;
  9421. protected $targetPackage;
  9422. public function __construct(PackageInterface $initial, PackageInterface $target)
  9423. {
  9424. $this->initialPackage = $initial;
  9425. $this->targetPackage = $target;
  9426. }
  9427. public function getInitialPackage()
  9428. {
  9429. return $this->initialPackage;
  9430. }
  9431. public function getTargetPackage()
  9432. {
  9433. return $this->targetPackage;
  9434. }
  9435. public function show($lock)
  9436. {
  9437. return self::format($this->initialPackage, $this->targetPackage, $lock);
  9438. }
  9439. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
  9440. {
  9441. $fromVersion = $initialPackage->getFullPrettyVersion();
  9442. $toVersion = $targetPackage->getFullPrettyVersion();
  9443. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  9444. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9445. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9446. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  9447. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9448. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9449. }
  9450. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  9451. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  9452. }
  9453. }
  9454. <?php
  9455. namespace Composer\DependencyResolver;
  9456. use Composer\Package\PackageInterface;
  9457. interface PolicyInterface
  9458. {
  9459. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  9460. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
  9461. }
  9462. <?php
  9463. namespace Composer\DependencyResolver;
  9464. use Composer\Package\AliasPackage;
  9465. use Composer\Package\Version\VersionParser;
  9466. use Composer\Semver\CompilingMatcher;
  9467. use Composer\Semver\Constraint\ConstraintInterface;
  9468. use Composer\Semver\Constraint\Constraint;
  9469. use Composer\Package\PackageInterface;
  9470. class Pool implements \Countable
  9471. {
  9472. protected $packages = array();
  9473. protected $packageByName = array();
  9474. protected $versionParser;
  9475. protected $providerCache = array();
  9476. protected $unacceptableFixedOrLockedPackages;
  9477. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array())
  9478. {
  9479. $this->versionParser = new VersionParser;
  9480. $this->setPackages($packages);
  9481. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  9482. }
  9483. private function setPackages(array $packages)
  9484. {
  9485. $id = 1;
  9486. foreach ($packages as $package) {
  9487. $this->packages[] = $package;
  9488. $package->id = $id++;
  9489. foreach ($package->getNames() as $provided) {
  9490. $this->packageByName[$provided][] = $package;
  9491. }
  9492. }
  9493. }
  9494. public function getPackages()
  9495. {
  9496. return $this->packages;
  9497. }
  9498. public function packageById($id)
  9499. {
  9500. return $this->packages[$id - 1];
  9501. }
  9502. public function count()
  9503. {
  9504. return \count($this->packages);
  9505. }
  9506. public function whatProvides($name, ConstraintInterface $constraint = null)
  9507. {
  9508. $key = (string) $constraint;
  9509. if (isset($this->providerCache[$name][$key])) {
  9510. return $this->providerCache[$name][$key];
  9511. }
  9512. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  9513. }
  9514. private function computeWhatProvides($name, $constraint)
  9515. {
  9516. if (!isset($this->packageByName[$name])) {
  9517. return array();
  9518. }
  9519. $matches = array();
  9520. foreach ($this->packageByName[$name] as $candidate) {
  9521. if ($this->match($candidate, $name, $constraint)) {
  9522. $matches[] = $candidate;
  9523. }
  9524. }
  9525. return $matches;
  9526. }
  9527. public function literalToPackage($literal)
  9528. {
  9529. $packageId = abs($literal);
  9530. return $this->packageById($packageId);
  9531. }
  9532. public function literalToPrettyString($literal, $installedMap)
  9533. {
  9534. $package = $this->literalToPackage($literal);
  9535. if (isset($installedMap[$package->id])) {
  9536. $prefix = ($literal > 0 ? 'keep' : 'remove');
  9537. } else {
  9538. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  9539. }
  9540. return $prefix.' '.$package->getPrettyString();
  9541. }
  9542. public function match($candidate, $name, ConstraintInterface $constraint = null)
  9543. {
  9544. $candidateName = $candidate->getName();
  9545. $candidateVersion = $candidate->getVersion();
  9546. if ($candidateName === $name) {
  9547. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  9548. }
  9549. $provides = $candidate->getProvides();
  9550. $replaces = $candidate->getReplaces();
  9551. if (isset($replaces[0]) || isset($provides[0])) {
  9552. foreach ($provides as $link) {
  9553. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9554. return true;
  9555. }
  9556. }
  9557. foreach ($replaces as $link) {
  9558. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9559. return true;
  9560. }
  9561. }
  9562. return false;
  9563. }
  9564. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  9565. return true;
  9566. }
  9567. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  9568. return true;
  9569. }
  9570. return false;
  9571. }
  9572. public function isUnacceptableFixedOrLockedPackage(PackageInterface $package)
  9573. {
  9574. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  9575. }
  9576. public function __toString()
  9577. {
  9578. $str = "Pool:\n";
  9579. foreach ($this->packages as $package) {
  9580. $str .= '- '.str_pad($package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  9581. }
  9582. return $str;
  9583. }
  9584. }
  9585. <?php
  9586. namespace Composer\DependencyResolver;
  9587. use Composer\EventDispatcher\EventDispatcher;
  9588. use Composer\IO\IOInterface;
  9589. use Composer\Package\AliasPackage;
  9590. use Composer\Package\BasePackage;
  9591. use Composer\Package\PackageInterface;
  9592. use Composer\Package\Version\StabilityFilter;
  9593. use Composer\Plugin\PluginEvents;
  9594. use Composer\Plugin\PrePoolCreateEvent;
  9595. use Composer\Repository\PlatformRepository;
  9596. use Composer\Repository\RootPackageRepository;
  9597. use Composer\Semver\CompilingMatcher;
  9598. use Composer\Semver\Constraint\Constraint;
  9599. use Composer\Semver\Constraint\ConstraintInterface;
  9600. use Composer\Semver\Constraint\MatchAllConstraint;
  9601. use Composer\Semver\Constraint\MultiConstraint;
  9602. use Composer\Semver\Intervals;
  9603. class PoolBuilder
  9604. {
  9605. private $acceptableStabilities;
  9606. private $stabilityFlags;
  9607. private $rootAliases;
  9608. private $rootReferences;
  9609. private $eventDispatcher;
  9610. private $io;
  9611. private $aliasMap = array();
  9612. private $packagesToLoad = array();
  9613. private $loadedPackages = array();
  9614. private $loadedPerRepo = array();
  9615. private $packages = array();
  9616. private $unacceptableFixedOrLockedPackages = array();
  9617. private $updateAllowList = array();
  9618. private $skippedLoad = array();
  9619. private $maxExtendedReqs = array();
  9620. private $updateAllowWarned = array();
  9621. private $indexCounter = 0;
  9622. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null)
  9623. {
  9624. $this->acceptableStabilities = $acceptableStabilities;
  9625. $this->stabilityFlags = $stabilityFlags;
  9626. $this->rootAliases = $rootAliases;
  9627. $this->rootReferences = $rootReferences;
  9628. $this->eventDispatcher = $eventDispatcher;
  9629. $this->io = $io;
  9630. }
  9631. public function buildPool(array $repositories, Request $request)
  9632. {
  9633. if ($request->getUpdateAllowList()) {
  9634. $this->updateAllowList = $request->getUpdateAllowList();
  9635. $this->warnAboutNonMatchingUpdateAllowList($request);
  9636. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  9637. if (!$this->isUpdateAllowed($lockedPackage)) {
  9638. $request->lockPackage($lockedPackage);
  9639. $lockedName = $lockedPackage->getName();
  9640. $this->skippedLoad[$lockedName] = $lockedName;
  9641. foreach ($lockedPackage->getReplaces() as $link) {
  9642. $this->skippedLoad[$link->getTarget()] = $lockedName;
  9643. }
  9644. }
  9645. }
  9646. }
  9647. foreach ($request->getFixedOrLockedPackages() as $package) {
  9648. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  9649. foreach ($package->getReplaces() as $link) {
  9650. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  9651. }
  9652. if (
  9653. $package->getRepository() instanceof RootPackageRepository
  9654. || $package->getRepository() instanceof PlatformRepository
  9655. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  9656. ) {
  9657. $this->loadPackage($request, $package, false);
  9658. } else {
  9659. $this->unacceptableFixedOrLockedPackages[] = $package;
  9660. }
  9661. }
  9662. foreach ($request->getRequires() as $packageName => $constraint) {
  9663. if (isset($this->loadedPackages[$packageName])) {
  9664. continue;
  9665. }
  9666. $this->packagesToLoad[$packageName] = $constraint;
  9667. $this->maxExtendedReqs[$packageName] = true;
  9668. }
  9669. foreach ($this->packagesToLoad as $name => $constraint) {
  9670. if (isset($this->loadedPackages[$name])) {
  9671. unset($this->packagesToLoad[$name]);
  9672. }
  9673. }
  9674. while (!empty($this->packagesToLoad)) {
  9675. $this->loadPackagesMarkedForLoading($request, $repositories);
  9676. }
  9677. foreach ($this->packages as $i => $package) {
  9678. if (!$package instanceof AliasPackage) {
  9679. $constraint = new Constraint('==', $package->getVersion());
  9680. $aliasedPackages = array($i => $package);
  9681. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9682. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  9683. }
  9684. $found = false;
  9685. foreach ($aliasedPackages as $packageOrAlias) {
  9686. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  9687. $found = true;
  9688. }
  9689. }
  9690. if (!$found) {
  9691. foreach ($aliasedPackages as $index => $packageOrAlias) {
  9692. unset($this->packages[$index]);
  9693. }
  9694. }
  9695. }
  9696. }
  9697. if ($this->eventDispatcher) {
  9698. $prePoolCreateEvent = new PrePoolCreateEvent(
  9699. PluginEvents::PRE_POOL_CREATE,
  9700. $repositories,
  9701. $request,
  9702. $this->acceptableStabilities,
  9703. $this->stabilityFlags,
  9704. $this->rootAliases,
  9705. $this->rootReferences,
  9706. $this->packages,
  9707. $this->unacceptableFixedOrLockedPackages
  9708. );
  9709. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  9710. $this->packages = $prePoolCreateEvent->getPackages();
  9711. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  9712. }
  9713. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  9714. $this->aliasMap = array();
  9715. $this->packagesToLoad = array();
  9716. $this->loadedPackages = array();
  9717. $this->loadedPerRepo = array();
  9718. $this->packages = array();
  9719. $this->unacceptableFixedOrLockedPackages = array();
  9720. $this->maxExtendedReqs = array();
  9721. $this->skippedLoad = array();
  9722. $this->indexCounter = 0;
  9723. Intervals::clear();
  9724. return $pool;
  9725. }
  9726. private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
  9727. {
  9728. if (PlatformRepository::isPlatformPackage($name)) {
  9729. return;
  9730. }
  9731. if (isset($this->maxExtendedReqs[$name])) {
  9732. return;
  9733. }
  9734. $rootRequires = $request->getRequires();
  9735. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  9736. $constraint = $rootRequires[$name];
  9737. }
  9738. if (!isset($this->loadedPackages[$name])) {
  9739. if (isset($this->packagesToLoad[$name])) {
  9740. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  9741. return;
  9742. }
  9743. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  9744. }
  9745. $this->packagesToLoad[$name] = $constraint;
  9746. return;
  9747. }
  9748. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  9749. return;
  9750. }
  9751. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  9752. unset($this->loadedPackages[$name]);
  9753. }
  9754. private function loadPackagesMarkedForLoading(Request $request, $repositories)
  9755. {
  9756. foreach ($this->packagesToLoad as $name => $constraint) {
  9757. $this->loadedPackages[$name] = $constraint;
  9758. }
  9759. $packageBatch = $this->packagesToLoad;
  9760. $this->packagesToLoad = array();
  9761. foreach ($repositories as $repoIndex => $repository) {
  9762. if (empty($packageBatch)) {
  9763. break;
  9764. }
  9765. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  9766. continue;
  9767. }
  9768. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
  9769. foreach ($result['namesFound'] as $name) {
  9770. unset($packageBatch[$name]);
  9771. }
  9772. foreach ($result['packages'] as $package) {
  9773. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  9774. $this->loadPackage($request, $package);
  9775. }
  9776. }
  9777. }
  9778. private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true)
  9779. {
  9780. $index = $this->indexCounter++;
  9781. $this->packages[$index] = $package;
  9782. if ($package instanceof AliasPackage) {
  9783. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  9784. }
  9785. $name = $package->getName();
  9786. if (isset($this->rootReferences[$name])) {
  9787. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  9788. $package->setSourceDistReferences($this->rootReferences[$name]);
  9789. }
  9790. }
  9791. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  9792. $alias = $this->rootAliases[$name][$package->getVersion()];
  9793. if ($package instanceof AliasPackage) {
  9794. $basePackage = $package->getAliasOf();
  9795. } else {
  9796. $basePackage = $package;
  9797. }
  9798. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  9799. $aliasPackage->setRootPackageAlias(true);
  9800. $newIndex = $this->indexCounter++;
  9801. $this->packages[$newIndex] = $aliasPackage;
  9802. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  9803. }
  9804. foreach ($package->getRequires() as $link) {
  9805. $require = $link->getTarget();
  9806. $linkConstraint = $link->getConstraint();
  9807. if ($propagateUpdate) {
  9808. if ($request->getUpdateAllowTransitiveDependencies() && isset($this->skippedLoad[$require])) {
  9809. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$require])) {
  9810. $this->unlockPackage($request, $require);
  9811. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9812. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $require) && !isset($this->updateAllowWarned[$require])) {
  9813. $this->updateAllowWarned[$require] = true;
  9814. $this->io->writeError('<warning>Dependency "'.$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>');
  9815. }
  9816. } else {
  9817. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9818. }
  9819. } else {
  9820. if (!isset($this->skippedLoad[$require])) {
  9821. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9822. }
  9823. }
  9824. }
  9825. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9826. foreach ($package->getReplaces() as $link) {
  9827. $replace = $link->getTarget();
  9828. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  9829. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
  9830. $this->unlockPackage($request, $replace);
  9831. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  9832. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
  9833. $this->updateAllowWarned[$replace] = true;
  9834. $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>');
  9835. }
  9836. }
  9837. }
  9838. }
  9839. }
  9840. private function isRootRequire(Request $request, $name)
  9841. {
  9842. $rootRequires = $request->getRequires();
  9843. return isset($rootRequires[$name]);
  9844. }
  9845. private function isUpdateAllowed(PackageInterface $package)
  9846. {
  9847. foreach ($this->updateAllowList as $pattern => $void) {
  9848. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9849. if (preg_match($patternRegexp, $package->getName())) {
  9850. return true;
  9851. }
  9852. }
  9853. return false;
  9854. }
  9855. private function warnAboutNonMatchingUpdateAllowList(Request $request)
  9856. {
  9857. foreach ($this->updateAllowList as $pattern => $void) {
  9858. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9859. foreach ($request->getLockedRepository()->getPackages() as $package) {
  9860. if (preg_match($patternRegexp, $package->getName())) {
  9861. continue 2;
  9862. }
  9863. }
  9864. foreach ($request->getRequires() as $packageName => $constraint) {
  9865. if (preg_match($patternRegexp, $packageName)) {
  9866. continue 2;
  9867. }
  9868. }
  9869. if (strpos($pattern, '*') !== false) {
  9870. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  9871. } else {
  9872. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  9873. }
  9874. }
  9875. }
  9876. private function unlockPackage(Request $request, $name)
  9877. {
  9878. foreach ($request->getLockedPackages() as $lockedPackage) {
  9879. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  9880. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  9881. $request->unlockPackage($lockedPackage);
  9882. $this->removeLoadedPackage($request, $lockedPackage, $index);
  9883. }
  9884. }
  9885. }
  9886. if (
  9887. $this->skippedLoad[$name] !== $name
  9888. && isset($this->skippedLoad[$this->skippedLoad[$name]])
  9889. ) {
  9890. $this->unlockPackage($request, $this->skippedLoad[$name]);
  9891. }
  9892. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name]);
  9893. }
  9894. private function removeLoadedPackage(Request $request, PackageInterface $package, $index)
  9895. {
  9896. unset($this->packages[$index]);
  9897. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9898. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  9899. $request->unlockPackage($aliasPackage);
  9900. unset($this->packages[$aliasIndex]);
  9901. }
  9902. unset($this->aliasMap[spl_object_hash($package)]);
  9903. }
  9904. }
  9905. }
  9906. <?php
  9907. namespace Composer\DependencyResolver;
  9908. use Composer\Package\CompletePackageInterface;
  9909. use Composer\Package\AliasPackage;
  9910. use Composer\Repository\RepositorySet;
  9911. use Composer\Repository\LockArrayRepository;
  9912. use Composer\Semver\Constraint\Constraint;
  9913. use Composer\Package\Version\VersionParser;
  9914. class Problem
  9915. {
  9916. protected $reasonSeen;
  9917. protected $reasons = array();
  9918. protected $section = 0;
  9919. public function addRule(Rule $rule)
  9920. {
  9921. $this->addReason(spl_object_hash($rule), $rule);
  9922. }
  9923. public function getReasons()
  9924. {
  9925. return $this->reasons;
  9926. }
  9927. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  9928. {
  9929. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  9930. if (count($reasons) === 1) {
  9931. reset($reasons);
  9932. $rule = current($reasons);
  9933. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  9934. throw new \LogicException("Single reason problems must contain a request rule.");
  9935. }
  9936. $reasonData = $rule->getReasonData();
  9937. $packageName = $reasonData['packageName'];
  9938. $constraint = $reasonData['constraint'];
  9939. if (isset($constraint)) {
  9940. $packages = $pool->whatProvides($packageName, $constraint);
  9941. } else {
  9942. $packages = array();
  9943. }
  9944. if (empty($packages)) {
  9945. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  9946. }
  9947. }
  9948. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  9949. }
  9950. public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  9951. {
  9952. $messages = array();
  9953. $templates = array();
  9954. $parser = new VersionParser;
  9955. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  9956. foreach ($rules as $rule) {
  9957. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  9958. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && preg_match('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  9959. $template = preg_replace('{^\S+ \S+ }', '%s%s ', $message);
  9960. $messages[] = $template;
  9961. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  9962. } elseif ($message !== '') {
  9963. $messages[] = $message;
  9964. }
  9965. }
  9966. $result = array();
  9967. foreach (array_unique($messages) as $message) {
  9968. if (isset($templates[$message])) {
  9969. foreach ($templates[$message] as $package => $versions) {
  9970. uksort($versions, 'version_compare');
  9971. if (!$isVerbose) {
  9972. $versions = self::condenseVersionList($versions, 1);
  9973. }
  9974. if (count($versions) > 1) {
  9975. $message = preg_replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  9976. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  9977. } else {
  9978. $result[] = sprintf($message, $package, ' '.reset($versions));
  9979. }
  9980. }
  9981. } else {
  9982. $result[] = $message;
  9983. }
  9984. }
  9985. return "\n$indent- ".implode("\n$indent- ", $result);
  9986. }
  9987. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  9988. {
  9989. foreach ($this->reasons as $sectionRules) {
  9990. foreach ($sectionRules as $rule) {
  9991. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  9992. return true;
  9993. }
  9994. }
  9995. }
  9996. }
  9997. protected function addReason($id, Rule $reason)
  9998. {
  9999. if (!isset($this->reasonSeen[$id])) {
  10000. $this->reasonSeen[$id] = true;
  10001. $this->reasons[$this->section][] = $reason;
  10002. }
  10003. }
  10004. public function nextSection()
  10005. {
  10006. $this->section++;
  10007. }
  10008. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, $constraint = null)
  10009. {
  10010. if ($packageName === 'php' || $packageName === 'php-64bit' || $packageName === 'hhvm') {
  10011. $version = phpversion();
  10012. $available = $pool->whatProvides($packageName);
  10013. if (count($available)) {
  10014. $firstAvailable = reset($available);
  10015. $version = $firstAvailable->getPrettyVersion();
  10016. $extra = $firstAvailable->getExtra();
  10017. if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  10018. $version .= '; ' . str_replace('Package ', '', $firstAvailable->getDescription());
  10019. }
  10020. }
  10021. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  10022. if (defined('HHVM_VERSION') || (count($available) && $packageName === 'hhvm')) {
  10023. return array($msg, 'your HHVM version does not satisfy that requirement.');
  10024. }
  10025. if ($packageName === 'hhvm') {
  10026. return array($msg, 'you are running this with PHP and not HHVM.');
  10027. }
  10028. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  10029. }
  10030. if (0 === stripos($packageName, 'ext-')) {
  10031. if (false !== strpos($packageName, ' ')) {
  10032. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  10033. }
  10034. $ext = substr($packageName, 4);
  10035. $error = extension_loaded($ext) ? 'it has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'it is missing from your system';
  10036. return array("- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ', $error.'. Install or enable PHP\'s '.$ext.' extension.');
  10037. }
  10038. if (0 === stripos($packageName, 'lib-')) {
  10039. if (strtolower($packageName) === 'lib-icu') {
  10040. $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.';
  10041. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  10042. }
  10043. 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.');
  10044. }
  10045. $lockedPackage = null;
  10046. foreach ($request->getLockedPackages() as $package) {
  10047. if ($package->getName() === $packageName) {
  10048. $lockedPackage = $package;
  10049. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10050. 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.');
  10051. }
  10052. break;
  10053. }
  10054. }
  10055. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  10056. $rootReqs = $repositorySet->getRootRequires();
  10057. if (isset($rootReqs[$packageName])) {
  10058. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName) {
  10059. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  10060. });
  10061. if (0 === count($filtered)) {
  10062. 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().').');
  10063. }
  10064. }
  10065. if ($lockedPackage) {
  10066. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  10067. $filtered = array_filter($packages, function ($p) use ($fixedConstraint) {
  10068. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  10069. });
  10070. if (0 === count($filtered)) {
  10071. 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.');
  10072. }
  10073. }
  10074. $nonLockedPackages = array_filter($packages, function ($p) {
  10075. return !$p->getRepository() instanceof LockArrayRepository;
  10076. });
  10077. if (!$nonLockedPackages) {
  10078. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.');
  10079. }
  10080. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these conflict' : 'it conflicts').' with another require.');
  10081. }
  10082. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10083. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10084. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'minimum-stability');
  10085. }
  10086. 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.');
  10087. }
  10088. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10089. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10090. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'constraint');
  10091. }
  10092. 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.');
  10093. }
  10094. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  10095. $illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  10096. 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.');
  10097. }
  10098. if ($providers = $repositorySet->getProviders($packageName)) {
  10099. $maxProviders = 20;
  10100. $providersStr = implode(array_map(function ($p) {
  10101. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  10102. return " - ${p['name']}".$description."\n";
  10103. }, count($providers) > $maxProviders+1 ? array_slice($providers, 0, $maxProviders) : $providers));
  10104. if (count($providers) > $maxProviders+1) {
  10105. $providersStr .= ' ... and '.(count($providers)-$maxProviders).' more.'."\n";
  10106. }
  10107. 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.");
  10108. }
  10109. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  10110. }
  10111. public static function getPackageList(array $packages, $isVerbose)
  10112. {
  10113. $prepared = array();
  10114. $hasDefaultBranch = array();
  10115. foreach ($packages as $package) {
  10116. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  10117. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  10118. if ($package->isDefaultBranch()) {
  10119. $hasDefaultBranch[$package->getName()] = true;
  10120. }
  10121. }
  10122. foreach ($prepared as $name => $package) {
  10123. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  10124. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  10125. }
  10126. uksort($package['versions'], 'version_compare');
  10127. if (!$isVerbose) {
  10128. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  10129. }
  10130. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  10131. }
  10132. return implode(', ', $prepared);
  10133. }
  10134. private static function condenseVersionList(array $versions, $max)
  10135. {
  10136. if (count($versions) <= $max) {
  10137. return $versions;
  10138. }
  10139. $filtered = array();
  10140. $byMajor = array();
  10141. foreach ($versions as $version => $pretty) {
  10142. $byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  10143. }
  10144. foreach ($byMajor as $versionsForMajor) {
  10145. if (count($versionsForMajor) > $max) {
  10146. $filtered[] = $versionsForMajor[0];
  10147. $filtered[] = '...';
  10148. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  10149. } else {
  10150. $filtered = array_merge($filtered, $versionsForMajor);
  10151. }
  10152. }
  10153. return $filtered;
  10154. }
  10155. private static function hasMultipleNames(array $packages)
  10156. {
  10157. $name = null;
  10158. foreach ($packages as $package) {
  10159. if ($name === null || $name === $package->getName()) {
  10160. $name = $package->getName();
  10161. } else {
  10162. return true;
  10163. }
  10164. }
  10165. return false;
  10166. }
  10167. private static function computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, array $higherRepoPackages, array $allReposPackages, $reason)
  10168. {
  10169. $nextRepoPackages = array();
  10170. $nextRepo = null;
  10171. foreach ($allReposPackages as $package) {
  10172. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  10173. $nextRepoPackages[] = $package;
  10174. $nextRepo = $package->getRepository();
  10175. } else {
  10176. break;
  10177. }
  10178. }
  10179. 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.');
  10180. }
  10181. protected static function constraintToText($constraint)
  10182. {
  10183. return $constraint ? ' '.$constraint->getPrettyString() : '';
  10184. }
  10185. }
  10186. <?php
  10187. namespace Composer\DependencyResolver;
  10188. use Composer\Package\Package;
  10189. use Composer\Package\PackageInterface;
  10190. use Composer\Package\RootAliasPackage;
  10191. use Composer\Repository\LockArrayRepository;
  10192. use Composer\Semver\Constraint\ConstraintInterface;
  10193. use Composer\Semver\Constraint\MatchAllConstraint;
  10194. class Request
  10195. {
  10196. const UPDATE_ONLY_LISTED = 0;
  10197. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  10198. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  10199. protected $lockedRepository;
  10200. protected $requires = array();
  10201. protected $fixedPackages = array();
  10202. protected $lockedPackages = array();
  10203. protected $fixedLockedPackages = array();
  10204. protected $updateAllowList = array();
  10205. protected $updateAllowTransitiveDependencies = false;
  10206. public function __construct(LockArrayRepository $lockedRepository = null)
  10207. {
  10208. $this->lockedRepository = $lockedRepository;
  10209. }
  10210. public function requireName($packageName, ConstraintInterface $constraint = null)
  10211. {
  10212. $packageName = strtolower($packageName);
  10213. if ($constraint === null) {
  10214. $constraint = new MatchAllConstraint();
  10215. }
  10216. if (isset($this->requires[$packageName])) {
  10217. 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');
  10218. }
  10219. $this->requires[$packageName] = $constraint;
  10220. }
  10221. public function fixPackage(PackageInterface $package)
  10222. {
  10223. $this->fixedPackages[spl_object_hash($package)] = $package;
  10224. }
  10225. public function lockPackage(PackageInterface $package)
  10226. {
  10227. $this->lockedPackages[spl_object_hash($package)] = $package;
  10228. }
  10229. public function fixLockedPackage(PackageInterface $package)
  10230. {
  10231. $this->fixedPackages[spl_object_hash($package)] = $package;
  10232. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  10233. }
  10234. public function unlockPackage(PackageInterface $package)
  10235. {
  10236. unset($this->lockedPackages[spl_object_hash($package)]);
  10237. }
  10238. public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)
  10239. {
  10240. $this->updateAllowList = $updateAllowList;
  10241. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  10242. }
  10243. public function getUpdateAllowList()
  10244. {
  10245. return $this->updateAllowList;
  10246. }
  10247. public function getUpdateAllowTransitiveDependencies()
  10248. {
  10249. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  10250. }
  10251. public function getUpdateAllowTransitiveRootDependencies()
  10252. {
  10253. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  10254. }
  10255. public function getRequires()
  10256. {
  10257. return $this->requires;
  10258. }
  10259. public function getFixedPackages()
  10260. {
  10261. return $this->fixedPackages;
  10262. }
  10263. public function isFixedPackage(PackageInterface $package)
  10264. {
  10265. return isset($this->fixedPackages[spl_object_hash($package)]);
  10266. }
  10267. public function getLockedPackages()
  10268. {
  10269. return $this->lockedPackages;
  10270. }
  10271. public function isLockedPackage(PackageInterface $package)
  10272. {
  10273. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  10274. }
  10275. public function getFixedOrLockedPackages()
  10276. {
  10277. return array_merge($this->fixedPackages, $this->lockedPackages);
  10278. }
  10279. public function getPresentMap($packageIds = false)
  10280. {
  10281. $presentMap = array();
  10282. if ($this->lockedRepository) {
  10283. foreach ($this->lockedRepository->getPackages() as $package) {
  10284. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10285. }
  10286. }
  10287. foreach ($this->fixedPackages as $package) {
  10288. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10289. }
  10290. return $presentMap;
  10291. }
  10292. public function getFixedPackagesMap()
  10293. {
  10294. $fixedPackagesMap = array();
  10295. foreach ($this->fixedPackages as $package) {
  10296. $fixedPackagesMap[$package->id] = $package;
  10297. }
  10298. return $fixedPackagesMap;
  10299. }
  10300. public function getLockedRepository()
  10301. {
  10302. return $this->lockedRepository;
  10303. }
  10304. }
  10305. <?php
  10306. namespace Composer\DependencyResolver;
  10307. use Composer\Package\CompletePackage;
  10308. use Composer\Package\Link;
  10309. use Composer\Package\PackageInterface;
  10310. use Composer\Package\AliasPackage;
  10311. use Composer\Repository\RepositorySet;
  10312. use Composer\Repository\PlatformRepository;
  10313. use Composer\Package\Version\VersionParser;
  10314. use Composer\Semver\Constraint\Constraint;
  10315. abstract class Rule
  10316. {
  10317. const RULE_ROOT_REQUIRE = 2;
  10318. const RULE_FIXED = 3;
  10319. const RULE_PACKAGE_CONFLICT = 6;
  10320. const RULE_PACKAGE_REQUIRES = 7;
  10321. const RULE_PACKAGE_SAME_NAME = 10;
  10322. const RULE_LEARNED = 12;
  10323. const RULE_PACKAGE_ALIAS = 13;
  10324. const RULE_PACKAGE_ROOT_ALIAS = 14;
  10325. const BITFIELD_TYPE = 0;
  10326. const BITFIELD_REASON = 8;
  10327. const BITFIELD_DISABLED = 16;
  10328. protected $bitfield;
  10329. protected $request;
  10330. protected $reasonData;
  10331. public function __construct($reason, $reasonData)
  10332. {
  10333. $this->reasonData = $reasonData;
  10334. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  10335. ($reason << self::BITFIELD_REASON) |
  10336. (255 << self::BITFIELD_TYPE);
  10337. }
  10338. abstract public function getLiterals();
  10339. abstract public function getHash();
  10340. abstract public function equals(Rule $rule);
  10341. public function getReason()
  10342. {
  10343. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  10344. }
  10345. public function getReasonData()
  10346. {
  10347. return $this->reasonData;
  10348. }
  10349. public function getRequiredPackage()
  10350. {
  10351. $reason = $this->getReason();
  10352. if ($reason === self::RULE_ROOT_REQUIRE) {
  10353. return $this->reasonData['packageName'];
  10354. }
  10355. if ($reason === self::RULE_FIXED) {
  10356. return $this->reasonData['package']->getName();
  10357. }
  10358. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  10359. return $this->reasonData->getTarget();
  10360. }
  10361. }
  10362. public function setType($type)
  10363. {
  10364. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  10365. }
  10366. public function getType()
  10367. {
  10368. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  10369. }
  10370. public function disable()
  10371. {
  10372. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  10373. }
  10374. public function enable()
  10375. {
  10376. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  10377. }
  10378. public function isDisabled()
  10379. {
  10380. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10381. }
  10382. public function isEnabled()
  10383. {
  10384. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10385. }
  10386. abstract public function isAssertion();
  10387. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10388. {
  10389. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  10390. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  10391. return false;
  10392. }
  10393. if ($request->getLockedRepository()) {
  10394. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10395. if ($package->getName() === $this->reasonData->getTarget()) {
  10396. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10397. return true;
  10398. }
  10399. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  10400. return true;
  10401. }
  10402. if (!$request->isLockedPackage($package)) {
  10403. return true;
  10404. }
  10405. break;
  10406. }
  10407. }
  10408. }
  10409. }
  10410. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  10411. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  10412. return false;
  10413. }
  10414. if ($request->getLockedRepository()) {
  10415. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10416. if ($package->getName() === $this->reasonData['packageName']) {
  10417. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10418. return true;
  10419. }
  10420. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  10421. return true;
  10422. }
  10423. break;
  10424. }
  10425. }
  10426. }
  10427. }
  10428. return false;
  10429. }
  10430. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10431. {
  10432. $literals = $this->getLiterals();
  10433. switch ($this->getReason()) {
  10434. case self::RULE_ROOT_REQUIRE:
  10435. $packageName = $this->reasonData['packageName'];
  10436. $constraint = $this->reasonData['constraint'];
  10437. $packages = $pool->whatProvides($packageName, $constraint);
  10438. if (!$packages) {
  10439. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  10440. }
  10441. $packagesNonAlias = array_values(array_filter($packages, function ($p) {
  10442. return !($p instanceof AliasPackage);
  10443. }));
  10444. if (count($packagesNonAlias) === 1) {
  10445. $package = $packagesNonAlias[0];
  10446. if ($request->isLockedPackage($package)) {
  10447. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  10448. }
  10449. }
  10450. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose).'.';
  10451. case self::RULE_FIXED:
  10452. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  10453. if ($request->isLockedPackage($package)) {
  10454. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  10455. }
  10456. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  10457. case self::RULE_PACKAGE_CONFLICT:
  10458. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10459. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10460. return $package2->getPrettyString().' conflicts with '.$package1->getPrettyString().'.';
  10461. case self::RULE_PACKAGE_REQUIRES:
  10462. $sourceLiteral = array_shift($literals);
  10463. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  10464. $requires = array();
  10465. foreach ($literals as $literal) {
  10466. $requires[] = $pool->literalToPackage($literal);
  10467. }
  10468. $text = $this->reasonData->getPrettyString($sourcePackage);
  10469. if ($requires) {
  10470. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose) . '.';
  10471. } else {
  10472. $targetName = $this->reasonData->getTarget();
  10473. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  10474. return $text . ' -> ' . $reason[1];
  10475. }
  10476. return $text;
  10477. case self::RULE_PACKAGE_SAME_NAME:
  10478. $packageNames = array();
  10479. foreach ($literals as $literal) {
  10480. $package = $pool->literalToPackage($literal);
  10481. $packageNames[$package->getName()] = true;
  10482. }
  10483. $replacedName = $this->reasonData;
  10484. if (count($packageNames) > 1) {
  10485. $reason = null;
  10486. if (!isset($packageNames[$replacedName])) {
  10487. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  10488. } else {
  10489. $replacerNames = $packageNames;
  10490. unset($replacerNames[$replacedName]);
  10491. $replacerNames = array_keys($replacerNames);
  10492. if (count($replacerNames) == 1) {
  10493. $reason = $replacerNames[0] . ' replaces ';
  10494. } else {
  10495. $reason = '['.implode(', ', $replacerNames).'] replace ';
  10496. }
  10497. $reason .= $replacedName.' and thus cannot coexist with it.';
  10498. }
  10499. $installedPackages = array();
  10500. $removablePackages = array();
  10501. foreach ($literals as $literal) {
  10502. if (isset($installedMap[abs($literal)])) {
  10503. $installedPackages[] = $pool->literalToPackage($literal);
  10504. } else {
  10505. $removablePackages[] = $pool->literalToPackage($literal);
  10506. }
  10507. }
  10508. if ($installedPackages && $removablePackages) {
  10509. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose).'. '.$reason;
  10510. }
  10511. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose).'. '.$reason;
  10512. }
  10513. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.';
  10514. case self::RULE_LEARNED:
  10515. $learnedString = ' (conflict analysis result)';
  10516. if (count($literals) === 1) {
  10517. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  10518. } else {
  10519. $groups = array();
  10520. foreach ($literals as $literal) {
  10521. $package = $pool->literalToPackage($literal);
  10522. if (isset($installedMap[$package->id])) {
  10523. $group = $literal > 0 ? 'keep' : 'remove';
  10524. } else {
  10525. $group = $literal > 0 ? 'install' : 'don\'t install';
  10526. }
  10527. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  10528. }
  10529. $ruleTexts = array();
  10530. foreach ($groups as $group => $packages) {
  10531. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  10532. }
  10533. $ruleText = implode(' | ', $ruleTexts);
  10534. }
  10535. return 'Conclusion: '.$ruleText.$learnedString;
  10536. case self::RULE_PACKAGE_ALIAS:
  10537. case self::RULE_PACKAGE_ROOT_ALIAS:
  10538. if ($this->getReason() === self::RULE_PACKAGE_ALIAS) {
  10539. $aliasPackage = $pool->literalToPackage($literals[0]);
  10540. $otherLiteral = 1;
  10541. } else {
  10542. $aliasPackage = $pool->literalToPackage($literals[1]);
  10543. $otherLiteral = 0;
  10544. }
  10545. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10546. return '';
  10547. }
  10548. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[$otherLiteral]));
  10549. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  10550. default:
  10551. $ruleText = '';
  10552. foreach ($literals as $i => $literal) {
  10553. if ($i != 0) {
  10554. $ruleText .= '|';
  10555. }
  10556. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  10557. }
  10558. return '('.$ruleText.')';
  10559. }
  10560. }
  10561. protected function formatPackagesUnique($pool, array $packages, $isVerbose)
  10562. {
  10563. foreach ($packages as $index => $package) {
  10564. if (!\is_object($package)) {
  10565. $packages[$index] = $pool->literalToPackage($package);
  10566. }
  10567. }
  10568. return Problem::getPackageList($packages, $isVerbose);
  10569. }
  10570. private function deduplicateDefaultBranchAlias(PackageInterface $package)
  10571. {
  10572. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10573. $package = $package->getAliasOf();
  10574. }
  10575. return $package;
  10576. }
  10577. }
  10578. <?php
  10579. namespace Composer\DependencyResolver;
  10580. use Composer\Package\PackageInterface;
  10581. use Composer\Package\Link;
  10582. class Rule2Literals extends Rule
  10583. {
  10584. protected $literal1;
  10585. protected $literal2;
  10586. public function __construct($literal1, $literal2, $reason, $reasonData)
  10587. {
  10588. parent::__construct($reason, $reasonData);
  10589. if ($literal1 < $literal2) {
  10590. $this->literal1 = $literal1;
  10591. $this->literal2 = $literal2;
  10592. } else {
  10593. $this->literal1 = $literal2;
  10594. $this->literal2 = $literal1;
  10595. }
  10596. }
  10597. public function getLiterals()
  10598. {
  10599. return array($this->literal1, $this->literal2);
  10600. }
  10601. public function getHash()
  10602. {
  10603. return $this->literal1.','.$this->literal2;
  10604. }
  10605. public function equals(Rule $rule)
  10606. {
  10607. if ($rule instanceof self) {
  10608. if ($this->literal1 !== $rule->literal1) {
  10609. return false;
  10610. }
  10611. if ($this->literal2 !== $rule->literal2) {
  10612. return false;
  10613. }
  10614. return true;
  10615. }
  10616. $literals = $rule->getLiterals();
  10617. if (2 != \count($literals)) {
  10618. return false;
  10619. }
  10620. if ($this->literal1 !== $literals[0]) {
  10621. return false;
  10622. }
  10623. if ($this->literal2 !== $literals[1]) {
  10624. return false;
  10625. }
  10626. return true;
  10627. }
  10628. public function isAssertion()
  10629. {
  10630. return false;
  10631. }
  10632. public function __toString()
  10633. {
  10634. $result = $this->isDisabled() ? 'disabled(' : '(';
  10635. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  10636. return $result;
  10637. }
  10638. }
  10639. <?php
  10640. namespace Composer\DependencyResolver;
  10641. use Composer\Repository\RepositorySet;
  10642. class RuleSet implements \IteratorAggregate, \Countable
  10643. {
  10644. const TYPE_PACKAGE = 0;
  10645. const TYPE_REQUEST = 1;
  10646. const TYPE_LEARNED = 4;
  10647. public $ruleById;
  10648. protected static $types = array(
  10649. 255 => 'UNKNOWN',
  10650. self::TYPE_PACKAGE => 'PACKAGE',
  10651. self::TYPE_REQUEST => 'REQUEST',
  10652. self::TYPE_LEARNED => 'LEARNED',
  10653. );
  10654. protected $rules;
  10655. protected $nextRuleId;
  10656. protected $rulesByHash;
  10657. public function __construct()
  10658. {
  10659. $this->nextRuleId = 0;
  10660. foreach ($this->getTypes() as $type) {
  10661. $this->rules[$type] = array();
  10662. }
  10663. $this->rulesByHash = array();
  10664. }
  10665. public function add(Rule $rule, $type)
  10666. {
  10667. if (!isset(self::$types[$type])) {
  10668. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  10669. }
  10670. $hash = $rule->getHash();
  10671. if (isset($this->rulesByHash[$hash])) {
  10672. $potentialDuplicates = $this->rulesByHash[$hash];
  10673. if (\is_array($potentialDuplicates)) {
  10674. foreach ($potentialDuplicates as $potentialDuplicate) {
  10675. if ($rule->equals($potentialDuplicate)) {
  10676. return;
  10677. }
  10678. }
  10679. } else {
  10680. if ($rule->equals($potentialDuplicates)) {
  10681. return;
  10682. }
  10683. }
  10684. }
  10685. if (!isset($this->rules[$type])) {
  10686. $this->rules[$type] = array();
  10687. }
  10688. $this->rules[$type][] = $rule;
  10689. $this->ruleById[$this->nextRuleId] = $rule;
  10690. $rule->setType($type);
  10691. $this->nextRuleId++;
  10692. if (!isset($this->rulesByHash[$hash])) {
  10693. $this->rulesByHash[$hash] = $rule;
  10694. } elseif (\is_array($this->rulesByHash[$hash])) {
  10695. $this->rulesByHash[$hash][] = $rule;
  10696. } else {
  10697. $originalRule = $this->rulesByHash[$hash];
  10698. $this->rulesByHash[$hash] = array($originalRule, $rule);
  10699. }
  10700. }
  10701. public function count()
  10702. {
  10703. return $this->nextRuleId;
  10704. }
  10705. public function ruleById($id)
  10706. {
  10707. return $this->ruleById[$id];
  10708. }
  10709. public function getRules()
  10710. {
  10711. return $this->rules;
  10712. }
  10713. public function getIterator()
  10714. {
  10715. return new RuleSetIterator($this->getRules());
  10716. }
  10717. public function getIteratorFor($types)
  10718. {
  10719. if (!\is_array($types)) {
  10720. $types = array($types);
  10721. }
  10722. $allRules = $this->getRules();
  10723. $rules = array();
  10724. foreach ($types as $type) {
  10725. $rules[$type] = $allRules[$type];
  10726. }
  10727. return new RuleSetIterator($rules);
  10728. }
  10729. public function getIteratorWithout($types)
  10730. {
  10731. if (!\is_array($types)) {
  10732. $types = array($types);
  10733. }
  10734. $rules = $this->getRules();
  10735. foreach ($types as $type) {
  10736. unset($rules[$type]);
  10737. }
  10738. return new RuleSetIterator($rules);
  10739. }
  10740. public function getTypes()
  10741. {
  10742. $types = self::$types;
  10743. unset($types[255]);
  10744. return array_keys($types);
  10745. }
  10746. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
  10747. {
  10748. $string = "\n";
  10749. foreach ($this->rules as $type => $rules) {
  10750. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  10751. foreach ($rules as $rule) {
  10752. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  10753. }
  10754. $string .= "\n\n";
  10755. }
  10756. return $string;
  10757. }
  10758. public function __toString()
  10759. {
  10760. return $this->getPrettyString();
  10761. }
  10762. }
  10763. <?php
  10764. namespace Composer\DependencyResolver;
  10765. use Composer\Package\LinkConstraint\VersionConstraint;
  10766. use Composer\Package\PackageInterface;
  10767. use Composer\Package\AliasPackage;
  10768. use Composer\Repository\PlatformRepository;
  10769. use Composer\Semver\Constraint\Constraint;
  10770. class RuleSetGenerator
  10771. {
  10772. protected $policy;
  10773. protected $pool;
  10774. protected $rules;
  10775. protected $addedMap;
  10776. protected $conflictAddedMap;
  10777. protected $addedPackagesByNames;
  10778. protected $conflictsForName;
  10779. public function __construct(PolicyInterface $policy, Pool $pool)
  10780. {
  10781. $this->policy = $policy;
  10782. $this->pool = $pool;
  10783. }
  10784. protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
  10785. {
  10786. $literals = array(-$package->id);
  10787. foreach ($providers as $provider) {
  10788. if ($provider === $package) {
  10789. return null;
  10790. }
  10791. $literals[] = $provider->id;
  10792. }
  10793. return new GenericRule($literals, $reason, $reasonData);
  10794. }
  10795. protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
  10796. {
  10797. $literals = array();
  10798. foreach ($packages as $package) {
  10799. $literals[] = $package->id;
  10800. }
  10801. return new GenericRule($literals, $reason, $reasonData);
  10802. }
  10803. protected function createRule2Literals(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
  10804. {
  10805. if ($issuer === $provider) {
  10806. return null;
  10807. }
  10808. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  10809. }
  10810. protected function createMultiConflictRule(array $packages, $reason, $reasonData = null)
  10811. {
  10812. $literals = array();
  10813. foreach ($packages as $package) {
  10814. $literals[] = -$package->id;
  10815. }
  10816. if (\count($literals) == 2) {
  10817. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  10818. }
  10819. return new MultiConflictRule($literals, $reason, $reasonData);
  10820. }
  10821. private function addRule($type, Rule $newRule = null)
  10822. {
  10823. if (!$newRule) {
  10824. return;
  10825. }
  10826. $this->rules->add($newRule, $type);
  10827. }
  10828. protected function addRulesForPackage(PackageInterface $package, $ignorePlatformReqs)
  10829. {
  10830. $workQueue = new \SplQueue;
  10831. $workQueue->enqueue($package);
  10832. while (!$workQueue->isEmpty()) {
  10833. $package = $workQueue->dequeue();
  10834. if (isset($this->addedMap[$package->id])) {
  10835. continue;
  10836. }
  10837. $this->addedMap[$package->id] = $package;
  10838. if (!$package instanceof AliasPackage) {
  10839. foreach ($package->getNames(false) as $name) {
  10840. $this->addedPackagesByNames[$name][] = $package;
  10841. }
  10842. } else {
  10843. $workQueue->enqueue($package->getAliasOf());
  10844. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  10845. if ($package->isRootPackageAlias()) {
  10846. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), array($package), Rule::RULE_PACKAGE_ROOT_ALIAS, $package->getAliasOf()));
  10847. }
  10848. if (!$package->hasSelfVersionRequires()) {
  10849. continue;
  10850. }
  10851. }
  10852. foreach ($package->getRequires() as $link) {
  10853. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10854. continue;
  10855. }
  10856. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10857. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  10858. foreach ($possibleRequires as $require) {
  10859. $workQueue->enqueue($require);
  10860. }
  10861. }
  10862. }
  10863. }
  10864. protected function addConflictRules($ignorePlatformReqs = false)
  10865. {
  10866. foreach ($this->addedMap as $package) {
  10867. foreach ($package->getConflicts() as $link) {
  10868. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  10869. continue;
  10870. }
  10871. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10872. continue;
  10873. }
  10874. foreach ($this->addedPackagesByNames[$link->getTarget()] as $possibleConflict) {
  10875. if ($this->pool->match($possibleConflict, $link->getTarget(), $link->getConstraint())) {
  10876. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $possibleConflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  10877. }
  10878. }
  10879. }
  10880. }
  10881. foreach ($this->addedPackagesByNames as $name => $packages) {
  10882. if (\count($packages) > 1) {
  10883. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  10884. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  10885. }
  10886. }
  10887. }
  10888. protected function addRulesForRequest(Request $request, $ignorePlatformReqs)
  10889. {
  10890. foreach ($request->getFixedPackages() as $package) {
  10891. if ($package->id == -1) {
  10892. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  10893. continue;
  10894. }
  10895. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  10896. }
  10897. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10898. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  10899. 'package' => $package,
  10900. ));
  10901. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10902. }
  10903. foreach ($request->getRequires() as $packageName => $constraint) {
  10904. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  10905. continue;
  10906. }
  10907. $packages = $this->pool->whatProvides($packageName, $constraint);
  10908. if ($packages) {
  10909. foreach ($packages as $package) {
  10910. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10911. }
  10912. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  10913. 'packageName' => $packageName,
  10914. 'constraint' => $constraint,
  10915. ));
  10916. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10917. }
  10918. }
  10919. }
  10920. protected function addRulesForRootAliases($ignorePlatformReqs)
  10921. {
  10922. foreach ($this->pool->getPackages() as $package) {
  10923. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  10924. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10925. }
  10926. }
  10927. }
  10928. public function getRulesFor(Request $request, $ignorePlatformReqs = false)
  10929. {
  10930. $this->rules = new RuleSet;
  10931. $this->addedMap = array();
  10932. $this->conflictAddedMap = array();
  10933. $this->addedPackagesByNames = array();
  10934. $this->conflictsForName = array();
  10935. $this->addRulesForRequest($request, $ignorePlatformReqs);
  10936. $this->addRulesForRootAliases($ignorePlatformReqs);
  10937. $this->addConflictRules($ignorePlatformReqs);
  10938. $this->addedMap = $this->addedPackagesByNames = null;
  10939. return $this->rules;
  10940. }
  10941. }
  10942. <?php
  10943. namespace Composer\DependencyResolver;
  10944. class RuleSetIterator implements \Iterator
  10945. {
  10946. protected $rules;
  10947. protected $types;
  10948. protected $currentOffset;
  10949. protected $currentType;
  10950. protected $currentTypeOffset;
  10951. public function __construct(array $rules)
  10952. {
  10953. $this->rules = $rules;
  10954. $this->types = array_keys($rules);
  10955. sort($this->types);
  10956. $this->rewind();
  10957. }
  10958. public function current()
  10959. {
  10960. return $this->rules[$this->currentType][$this->currentOffset];
  10961. }
  10962. public function key()
  10963. {
  10964. return $this->currentType;
  10965. }
  10966. public function next()
  10967. {
  10968. $this->currentOffset++;
  10969. if (!isset($this->rules[$this->currentType])) {
  10970. return;
  10971. }
  10972. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  10973. $this->currentOffset = 0;
  10974. do {
  10975. $this->currentTypeOffset++;
  10976. if (!isset($this->types[$this->currentTypeOffset])) {
  10977. $this->currentType = -1;
  10978. break;
  10979. }
  10980. $this->currentType = $this->types[$this->currentTypeOffset];
  10981. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  10982. }
  10983. }
  10984. public function rewind()
  10985. {
  10986. $this->currentOffset = 0;
  10987. $this->currentTypeOffset = -1;
  10988. $this->currentType = -1;
  10989. do {
  10990. $this->currentTypeOffset++;
  10991. if (!isset($this->types[$this->currentTypeOffset])) {
  10992. $this->currentType = -1;
  10993. break;
  10994. }
  10995. $this->currentType = $this->types[$this->currentTypeOffset];
  10996. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  10997. }
  10998. public function valid()
  10999. {
  11000. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  11001. }
  11002. }
  11003. <?php
  11004. namespace Composer\DependencyResolver;
  11005. class RuleWatchChain extends \SplDoublyLinkedList
  11006. {
  11007. protected $offset = 0;
  11008. public function seek($offset)
  11009. {
  11010. $this->rewind();
  11011. for ($i = 0; $i < $offset; $i++, $this->next());
  11012. }
  11013. public function remove()
  11014. {
  11015. $offset = $this->key();
  11016. $this->offsetUnset($offset);
  11017. $this->seek($offset);
  11018. }
  11019. }
  11020. <?php
  11021. namespace Composer\DependencyResolver;
  11022. class RuleWatchGraph
  11023. {
  11024. protected $watchChains = array();
  11025. public function insert(RuleWatchNode $node)
  11026. {
  11027. if ($node->getRule()->isAssertion()) {
  11028. return;
  11029. }
  11030. if (!$node->getRule() instanceof MultiConflictRule) {
  11031. foreach (array($node->watch1, $node->watch2) as $literal) {
  11032. if (!isset($this->watchChains[$literal])) {
  11033. $this->watchChains[$literal] = new RuleWatchChain;
  11034. }
  11035. $this->watchChains[$literal]->unshift($node);
  11036. }
  11037. } else {
  11038. foreach ($node->getRule()->getLiterals() as $literal) {
  11039. if (!isset($this->watchChains[$literal])) {
  11040. $this->watchChains[$literal] = new RuleWatchChain;
  11041. }
  11042. $this->watchChains[$literal]->unshift($node);
  11043. }
  11044. }
  11045. }
  11046. public function propagateLiteral($decidedLiteral, $level, $decisions)
  11047. {
  11048. $literal = -$decidedLiteral;
  11049. if (!isset($this->watchChains[$literal])) {
  11050. return null;
  11051. }
  11052. $chain = $this->watchChains[$literal];
  11053. $chain->rewind();
  11054. while ($chain->valid()) {
  11055. $node = $chain->current();
  11056. if (!$node->getRule() instanceof MultiConflictRule) {
  11057. $otherWatch = $node->getOtherWatch($literal);
  11058. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  11059. $ruleLiterals = $node->getRule()->getLiterals();
  11060. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  11061. return $literal !== $ruleLiteral &&
  11062. $otherWatch !== $ruleLiteral &&
  11063. !$decisions->conflict($ruleLiteral);
  11064. });
  11065. if ($alternativeLiterals) {
  11066. reset($alternativeLiterals);
  11067. $this->moveWatch($literal, current($alternativeLiterals), $node);
  11068. continue;
  11069. }
  11070. if ($decisions->conflict($otherWatch)) {
  11071. return $node->getRule();
  11072. }
  11073. $decisions->decide($otherWatch, $level, $node->getRule());
  11074. }
  11075. } else {
  11076. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  11077. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  11078. if ($decisions->conflict($otherLiteral)) {
  11079. return $node->getRule();
  11080. }
  11081. $decisions->decide($otherLiteral, $level, $node->getRule());
  11082. }
  11083. }
  11084. }
  11085. $chain->next();
  11086. }
  11087. return null;
  11088. }
  11089. protected function moveWatch($fromLiteral, $toLiteral, $node)
  11090. {
  11091. if (!isset($this->watchChains[$toLiteral])) {
  11092. $this->watchChains[$toLiteral] = new RuleWatchChain;
  11093. }
  11094. $node->moveWatch($fromLiteral, $toLiteral);
  11095. $this->watchChains[$fromLiteral]->remove();
  11096. $this->watchChains[$toLiteral]->unshift($node);
  11097. }
  11098. }
  11099. <?php
  11100. namespace Composer\DependencyResolver;
  11101. class RuleWatchNode
  11102. {
  11103. public $watch1;
  11104. public $watch2;
  11105. protected $rule;
  11106. public function __construct($rule)
  11107. {
  11108. $this->rule = $rule;
  11109. $literals = $rule->getLiterals();
  11110. $literalCount = \count($literals);
  11111. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  11112. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  11113. }
  11114. public function watch2OnHighest(Decisions $decisions)
  11115. {
  11116. $literals = $this->rule->getLiterals();
  11117. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  11118. return;
  11119. }
  11120. $watchLevel = 0;
  11121. foreach ($literals as $literal) {
  11122. $level = $decisions->decisionLevel($literal);
  11123. if ($level > $watchLevel) {
  11124. $this->watch2 = $literal;
  11125. $watchLevel = $level;
  11126. }
  11127. }
  11128. }
  11129. public function getRule()
  11130. {
  11131. return $this->rule;
  11132. }
  11133. public function getOtherWatch($literal)
  11134. {
  11135. if ($this->watch1 == $literal) {
  11136. return $this->watch2;
  11137. }
  11138. return $this->watch1;
  11139. }
  11140. public function moveWatch($from, $to)
  11141. {
  11142. if ($this->watch1 == $from) {
  11143. $this->watch1 = $to;
  11144. } else {
  11145. $this->watch2 = $to;
  11146. }
  11147. }
  11148. }
  11149. <?php
  11150. namespace Composer\DependencyResolver;
  11151. use Composer\IO\IOInterface;
  11152. use Composer\Package\PackageInterface;
  11153. use Composer\Repository\PlatformRepository;
  11154. use Composer\Semver\Constraint\MultiConstraint;
  11155. class Solver
  11156. {
  11157. const BRANCH_LITERALS = 0;
  11158. const BRANCH_LEVEL = 1;
  11159. protected $policy;
  11160. protected $pool;
  11161. protected $rules;
  11162. protected $watchGraph;
  11163. protected $decisions;
  11164. protected $fixedMap;
  11165. protected $propagateIndex;
  11166. protected $branches = array();
  11167. protected $problems = array();
  11168. protected $learnedPool = array();
  11169. protected $learnedWhy = array();
  11170. public $testFlagLearnedPositiveLiteral = false;
  11171. protected $io;
  11172. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  11173. {
  11174. $this->io = $io;
  11175. $this->policy = $policy;
  11176. $this->pool = $pool;
  11177. }
  11178. public function getRuleSetSize()
  11179. {
  11180. return \count($this->rules);
  11181. }
  11182. public function getPool()
  11183. {
  11184. return $this->pool;
  11185. }
  11186. private function makeAssertionRuleDecisions()
  11187. {
  11188. $decisionStart = \count($this->decisions) - 1;
  11189. $rulesCount = \count($this->rules);
  11190. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  11191. $rule = $this->rules->ruleById[$ruleIndex];
  11192. if (!$rule->isAssertion() || $rule->isDisabled()) {
  11193. continue;
  11194. }
  11195. $literals = $rule->getLiterals();
  11196. $literal = $literals[0];
  11197. if (!$this->decisions->decided($literal)) {
  11198. $this->decisions->decide($literal, 1, $rule);
  11199. continue;
  11200. }
  11201. if ($this->decisions->satisfy($literal)) {
  11202. continue;
  11203. }
  11204. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  11205. $rule->disable();
  11206. continue;
  11207. }
  11208. $conflict = $this->decisions->decisionRule($literal);
  11209. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  11210. $problem = new Problem();
  11211. $problem->addRule($rule);
  11212. $problem->addRule($conflict);
  11213. $rule->disable();
  11214. $this->problems[] = $problem;
  11215. continue;
  11216. }
  11217. $problem = new Problem();
  11218. $problem->addRule($rule);
  11219. $problem->addRule($conflict);
  11220. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  11221. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  11222. continue;
  11223. }
  11224. $assertRuleLiterals = $assertRule->getLiterals();
  11225. $assertRuleLiteral = $assertRuleLiterals[0];
  11226. if (abs($literal) !== abs($assertRuleLiteral)) {
  11227. continue;
  11228. }
  11229. $problem->addRule($assertRule);
  11230. $assertRule->disable();
  11231. }
  11232. $this->problems[] = $problem;
  11233. $this->decisions->resetToOffset($decisionStart);
  11234. $ruleIndex = -1;
  11235. }
  11236. }
  11237. protected function setupFixedMap(Request $request)
  11238. {
  11239. $this->fixedMap = array();
  11240. foreach ($request->getFixedPackages() as $package) {
  11241. $this->fixedMap[$package->id] = $package;
  11242. }
  11243. }
  11244. protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
  11245. {
  11246. foreach ($request->getRequires() as $packageName => $constraint) {
  11247. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  11248. continue;
  11249. }
  11250. if (!$this->pool->whatProvides($packageName, $constraint)) {
  11251. $problem = new Problem();
  11252. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  11253. $this->problems[] = $problem;
  11254. }
  11255. }
  11256. }
  11257. public function solve(Request $request, $ignorePlatformReqs = false)
  11258. {
  11259. $this->setupFixedMap($request);
  11260. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  11261. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  11262. $this->rules = $ruleSetGenerator->getRulesFor($request, $ignorePlatformReqs);
  11263. unset($ruleSetGenerator);
  11264. $this->checkForRootRequireProblems($request, $ignorePlatformReqs);
  11265. $this->decisions = new Decisions($this->pool);
  11266. $this->watchGraph = new RuleWatchGraph;
  11267. foreach ($this->rules as $rule) {
  11268. $this->watchGraph->insert(new RuleWatchNode($rule));
  11269. }
  11270. $this->makeAssertionRuleDecisions();
  11271. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  11272. $before = microtime(true);
  11273. $this->runSat();
  11274. $this->io->writeError('', true, IOInterface::DEBUG);
  11275. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  11276. if ($this->problems) {
  11277. throw new SolverProblemsException($this->problems, $this->learnedPool);
  11278. }
  11279. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  11280. }
  11281. protected function propagate($level)
  11282. {
  11283. while ($this->decisions->validOffset($this->propagateIndex)) {
  11284. $decision = $this->decisions->atOffset($this->propagateIndex);
  11285. $conflict = $this->watchGraph->propagateLiteral(
  11286. $decision[Decisions::DECISION_LITERAL],
  11287. $level,
  11288. $this->decisions
  11289. );
  11290. $this->propagateIndex++;
  11291. if ($conflict) {
  11292. return $conflict;
  11293. }
  11294. }
  11295. return null;
  11296. }
  11297. private function revert($level)
  11298. {
  11299. while (!$this->decisions->isEmpty()) {
  11300. $literal = $this->decisions->lastLiteral();
  11301. if ($this->decisions->undecided($literal)) {
  11302. break;
  11303. }
  11304. $decisionLevel = $this->decisions->decisionLevel($literal);
  11305. if ($decisionLevel <= $level) {
  11306. break;
  11307. }
  11308. $this->decisions->revertLast();
  11309. $this->propagateIndex = \count($this->decisions);
  11310. }
  11311. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  11312. array_pop($this->branches);
  11313. }
  11314. }
  11315. private function setPropagateLearn($level, $literal, Rule $rule)
  11316. {
  11317. $level++;
  11318. $this->decisions->decide($literal, $level, $rule);
  11319. while (true) {
  11320. $rule = $this->propagate($level);
  11321. if (!$rule) {
  11322. break;
  11323. }
  11324. if ($level == 1) {
  11325. return $this->analyzeUnsolvable($rule);
  11326. }
  11327. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  11328. if ($newLevel <= 0 || $newLevel >= $level) {
  11329. throw new SolverBugException(
  11330. "Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
  11331. );
  11332. }
  11333. if (!$newRule) {
  11334. throw new SolverBugException(
  11335. "No rule was learned from analyzing $rule at level $level."
  11336. );
  11337. }
  11338. $level = $newLevel;
  11339. $this->revert($level);
  11340. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  11341. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  11342. $ruleNode = new RuleWatchNode($newRule);
  11343. $ruleNode->watch2OnHighest($this->decisions);
  11344. $this->watchGraph->insert($ruleNode);
  11345. $this->decisions->decide($learnLiteral, $level, $newRule);
  11346. }
  11347. return $level;
  11348. }
  11349. private function selectAndInstall($level, array $decisionQueue, Rule $rule)
  11350. {
  11351. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  11352. $selectedLiteral = array_shift($literals);
  11353. if (\count($literals)) {
  11354. $this->branches[] = array($literals, $level);
  11355. }
  11356. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  11357. }
  11358. protected function analyze($level, Rule $rule)
  11359. {
  11360. $analyzedRule = $rule;
  11361. $ruleLevel = 1;
  11362. $num = 0;
  11363. $l1num = 0;
  11364. $seen = array();
  11365. $learnedLiterals = array(null);
  11366. $decisionId = \count($this->decisions);
  11367. $this->learnedPool[] = array();
  11368. while (true) {
  11369. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11370. foreach ($rule->getLiterals() as $literal) {
  11371. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  11372. continue;
  11373. }
  11374. if ($this->decisions->satisfy($literal)) {
  11375. continue;
  11376. }
  11377. if (isset($seen[abs($literal)])) {
  11378. continue;
  11379. }
  11380. $seen[abs($literal)] = true;
  11381. $l = $this->decisions->decisionLevel($literal);
  11382. if (1 === $l) {
  11383. $l1num++;
  11384. } elseif ($level === $l) {
  11385. $num++;
  11386. } else {
  11387. $learnedLiterals[] = $literal;
  11388. if ($l > $ruleLevel) {
  11389. $ruleLevel = $l;
  11390. }
  11391. }
  11392. }
  11393. unset($literal);
  11394. $l1retry = true;
  11395. while ($l1retry) {
  11396. $l1retry = false;
  11397. if (!$num && !--$l1num) {
  11398. break 2;
  11399. }
  11400. while (true) {
  11401. if ($decisionId <= 0) {
  11402. throw new SolverBugException(
  11403. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  11404. );
  11405. }
  11406. $decisionId--;
  11407. $decision = $this->decisions->atOffset($decisionId);
  11408. $literal = $decision[Decisions::DECISION_LITERAL];
  11409. if (isset($seen[abs($literal)])) {
  11410. break;
  11411. }
  11412. }
  11413. unset($seen[abs($literal)]);
  11414. if ($num && 0 === --$num) {
  11415. if ($literal < 0) {
  11416. $this->testFlagLearnedPositiveLiteral = true;
  11417. }
  11418. $learnedLiterals[0] = -$literal;
  11419. if (!$l1num) {
  11420. break 2;
  11421. }
  11422. foreach ($learnedLiterals as $i => $learnedLiteral) {
  11423. if ($i !== 0) {
  11424. unset($seen[abs($learnedLiteral)]);
  11425. }
  11426. }
  11427. $l1num++;
  11428. $l1retry = true;
  11429. } else {
  11430. $decision = $this->decisions->atOffset($decisionId);
  11431. $rule = $decision[Decisions::DECISION_REASON];
  11432. if ($rule instanceof MultiConflictRule) {
  11433. foreach ($rule->getLiterals() as $literal) {
  11434. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  11435. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11436. $l = $this->decisions->decisionLevel($literal);
  11437. if (1 === $l) {
  11438. $l1num++;
  11439. } elseif ($level === $l) {
  11440. $num++;
  11441. } else {
  11442. $learnedLiterals[] = $literal;
  11443. if ($l > $ruleLevel) {
  11444. $ruleLevel = $l;
  11445. }
  11446. }
  11447. $seen[abs($literal)] = true;
  11448. break;
  11449. }
  11450. }
  11451. $l1retry = true;
  11452. }
  11453. }
  11454. }
  11455. $decision = $this->decisions->atOffset($decisionId);
  11456. $rule = $decision[Decisions::DECISION_REASON];
  11457. }
  11458. $why = \count($this->learnedPool) - 1;
  11459. if (!$learnedLiterals[0]) {
  11460. throw new SolverBugException(
  11461. "Did not find a learnable literal in analyzed rule $analyzedRule."
  11462. );
  11463. }
  11464. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  11465. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  11466. }
  11467. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen)
  11468. {
  11469. $why = spl_object_hash($conflictRule);
  11470. $ruleSeen[$why] = true;
  11471. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  11472. $learnedWhy = $this->learnedWhy[$why];
  11473. $problemRules = $this->learnedPool[$learnedWhy];
  11474. foreach ($problemRules as $problemRule) {
  11475. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  11476. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  11477. }
  11478. }
  11479. return;
  11480. }
  11481. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  11482. return;
  11483. }
  11484. $problem->nextSection();
  11485. $problem->addRule($conflictRule);
  11486. }
  11487. private function analyzeUnsolvable(Rule $conflictRule)
  11488. {
  11489. $problem = new Problem();
  11490. $problem->addRule($conflictRule);
  11491. $ruleSeen = array();
  11492. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  11493. $this->problems[] = $problem;
  11494. $seen = array();
  11495. $literals = $conflictRule->getLiterals();
  11496. foreach ($literals as $literal) {
  11497. if ($this->decisions->satisfy($literal)) {
  11498. continue;
  11499. }
  11500. $seen[abs($literal)] = true;
  11501. }
  11502. foreach ($this->decisions as $decision) {
  11503. $literal = $decision[Decisions::DECISION_LITERAL];
  11504. if (!isset($seen[abs($literal)])) {
  11505. continue;
  11506. }
  11507. $why = $decision[Decisions::DECISION_REASON];
  11508. $problem->addRule($why);
  11509. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  11510. $literals = $why->getLiterals();
  11511. foreach ($literals as $literal) {
  11512. if ($this->decisions->satisfy($literal)) {
  11513. continue;
  11514. }
  11515. $seen[abs($literal)] = true;
  11516. }
  11517. }
  11518. return 0;
  11519. }
  11520. private function enableDisableLearnedRules()
  11521. {
  11522. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  11523. $why = $this->learnedWhy[spl_object_hash($rule)];
  11524. $problemRules = $this->learnedPool[$why];
  11525. $foundDisabled = false;
  11526. foreach ($problemRules as $problemRule) {
  11527. if ($problemRule->isDisabled()) {
  11528. $foundDisabled = true;
  11529. break;
  11530. }
  11531. }
  11532. if ($foundDisabled && $rule->isEnabled()) {
  11533. $rule->disable();
  11534. } elseif (!$foundDisabled && $rule->isDisabled()) {
  11535. $rule->enable();
  11536. }
  11537. }
  11538. }
  11539. private function runSat()
  11540. {
  11541. $this->propagateIndex = 0;
  11542. $level = 1;
  11543. $systemLevel = $level + 1;
  11544. while (true) {
  11545. if (1 === $level) {
  11546. $conflictRule = $this->propagate($level);
  11547. if (null !== $conflictRule) {
  11548. if ($this->analyzeUnsolvable($conflictRule)) {
  11549. continue;
  11550. }
  11551. return;
  11552. }
  11553. }
  11554. if ($level < $systemLevel) {
  11555. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  11556. foreach ($iterator as $rule) {
  11557. if ($rule->isEnabled()) {
  11558. $decisionQueue = array();
  11559. $noneSatisfied = true;
  11560. foreach ($rule->getLiterals() as $literal) {
  11561. if ($this->decisions->satisfy($literal)) {
  11562. $noneSatisfied = false;
  11563. break;
  11564. }
  11565. if ($literal > 0 && $this->decisions->undecided($literal)) {
  11566. $decisionQueue[] = $literal;
  11567. }
  11568. }
  11569. if ($noneSatisfied && \count($decisionQueue)) {
  11570. $prunedQueue = array();
  11571. foreach ($decisionQueue as $literal) {
  11572. if (isset($this->fixedMap[abs($literal)])) {
  11573. $prunedQueue[] = $literal;
  11574. }
  11575. }
  11576. if (!empty($prunedQueue)) {
  11577. $decisionQueue = $prunedQueue;
  11578. }
  11579. }
  11580. if ($noneSatisfied && \count($decisionQueue)) {
  11581. $oLevel = $level;
  11582. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11583. if (0 === $level) {
  11584. return;
  11585. }
  11586. if ($level <= $oLevel) {
  11587. break;
  11588. }
  11589. }
  11590. }
  11591. }
  11592. $systemLevel = $level + 1;
  11593. $iterator->next();
  11594. if ($iterator->valid()) {
  11595. continue;
  11596. }
  11597. }
  11598. if ($level < $systemLevel) {
  11599. $systemLevel = $level;
  11600. }
  11601. $rulesCount = \count($this->rules);
  11602. $pass = 1;
  11603. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  11604. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  11605. if ($i == $rulesCount) {
  11606. if (1 === $pass) {
  11607. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  11608. } else {
  11609. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  11610. }
  11611. $i = 0;
  11612. $pass++;
  11613. }
  11614. $rule = $this->rules->ruleById[$i];
  11615. $literals = $rule->getLiterals();
  11616. if ($rule->isDisabled()) {
  11617. continue;
  11618. }
  11619. $decisionQueue = array();
  11620. foreach ($literals as $literal) {
  11621. if ($literal <= 0) {
  11622. if (!$this->decisions->decidedInstall($literal)) {
  11623. continue 2;
  11624. }
  11625. } else {
  11626. if ($this->decisions->decidedInstall($literal)) {
  11627. continue 2;
  11628. }
  11629. if ($this->decisions->undecided($literal)) {
  11630. $decisionQueue[] = $literal;
  11631. }
  11632. }
  11633. }
  11634. if (\count($decisionQueue) < 2) {
  11635. continue;
  11636. }
  11637. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11638. if (0 === $level) {
  11639. return;
  11640. }
  11641. $rulesCount = \count($this->rules);
  11642. $n = -1;
  11643. }
  11644. if ($level < $systemLevel) {
  11645. continue;
  11646. }
  11647. if (\count($this->branches)) {
  11648. $lastLiteral = null;
  11649. $lastLevel = null;
  11650. $lastBranchIndex = 0;
  11651. $lastBranchOffset = 0;
  11652. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  11653. list($literals, $l) = $this->branches[$i];
  11654. foreach ($literals as $offset => $literal) {
  11655. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  11656. $lastLiteral = $literal;
  11657. $lastBranchIndex = $i;
  11658. $lastBranchOffset = $offset;
  11659. $lastLevel = $l;
  11660. }
  11661. }
  11662. }
  11663. if ($lastLiteral) {
  11664. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  11665. $level = $lastLevel;
  11666. $this->revert($level);
  11667. $why = $this->decisions->lastReason();
  11668. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  11669. if ($level == 0) {
  11670. return;
  11671. }
  11672. continue;
  11673. }
  11674. }
  11675. break;
  11676. }
  11677. }
  11678. }
  11679. <?php
  11680. namespace Composer\DependencyResolver;
  11681. class SolverBugException extends \RuntimeException
  11682. {
  11683. public function __construct($message)
  11684. {
  11685. parent::__construct(
  11686. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  11687. "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"
  11688. );
  11689. }
  11690. }
  11691. <?php
  11692. namespace Composer\DependencyResolver;
  11693. use Composer\Util\IniHelper;
  11694. use Composer\Repository\RepositorySet;
  11695. class SolverProblemsException extends \RuntimeException
  11696. {
  11697. protected $problems;
  11698. protected $learnedPool;
  11699. public function __construct(array $problems, array $learnedPool)
  11700. {
  11701. $this->problems = $problems;
  11702. $this->learnedPool = $learnedPool;
  11703. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', 2);
  11704. }
  11705. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
  11706. {
  11707. $installedMap = $request->getPresentMap(true);
  11708. $hasExtensionProblems = false;
  11709. $isCausedByLock = false;
  11710. $problems = array();
  11711. foreach ($this->problems as $problem) {
  11712. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  11713. if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
  11714. $hasExtensionProblems = true;
  11715. }
  11716. $isCausedByLock |= $problem->isCausedByLock($repositorySet, $request, $pool);
  11717. }
  11718. $i = 1;
  11719. $text = "\n";
  11720. foreach (array_unique($problems) as $problem) {
  11721. $text .= " Problem ".($i++).$problem;
  11722. }
  11723. $hints = array();
  11724. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  11725. $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.";
  11726. }
  11727. if ($hasExtensionProblems) {
  11728. $hints[] = $this->createExtensionHint();
  11729. }
  11730. if ($isCausedByLock && !$isDevExtraction) {
  11731. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  11732. }
  11733. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  11734. $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+.";
  11735. }
  11736. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  11737. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  11738. $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.";
  11739. }
  11740. }
  11741. if ($hints) {
  11742. $text .= "\n" . implode("\n\n", $hints);
  11743. }
  11744. return $text;
  11745. }
  11746. public function getProblems()
  11747. {
  11748. return $this->problems;
  11749. }
  11750. private function createExtensionHint()
  11751. {
  11752. $paths = IniHelper::getAll();
  11753. if (count($paths) === 1 && empty($paths[0])) {
  11754. return '';
  11755. }
  11756. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  11757. $text .= implode("\n - ", $paths);
  11758. $text .= "\nYou can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
  11759. return $text;
  11760. }
  11761. private function hasExtensionProblems(array $reasonSets)
  11762. {
  11763. foreach ($reasonSets as $reasonSet) {
  11764. foreach ($reasonSet as $rule) {
  11765. if (0 === strpos($rule->getRequiredPackage(), 'ext-')) {
  11766. return true;
  11767. }
  11768. }
  11769. }
  11770. return false;
  11771. }
  11772. }
  11773. <?php
  11774. namespace Composer\DependencyResolver;
  11775. use Composer\Package\AliasPackage;
  11776. use Composer\Package\Link;
  11777. use Composer\Package\PackageInterface;
  11778. use Composer\Repository\PlatformRepository;
  11779. class Transaction
  11780. {
  11781. protected $operations;
  11782. protected $presentPackages;
  11783. protected $resultPackageMap;
  11784. protected $resultPackagesByName = array();
  11785. public function __construct($presentPackages, $resultPackages)
  11786. {
  11787. $this->presentPackages = $presentPackages;
  11788. $this->setResultPackageMaps($resultPackages);
  11789. $this->operations = $this->calculateOperations();
  11790. }
  11791. public function getOperations()
  11792. {
  11793. return $this->operations;
  11794. }
  11795. private function setResultPackageMaps($resultPackages)
  11796. {
  11797. $packageSort = function (PackageInterface $a, PackageInterface $b) {
  11798. if ($a->getName() == $b->getName()) {
  11799. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  11800. return $a instanceof AliasPackage ? -1 : 1;
  11801. }
  11802. return strcmp($b->getVersion(), $a->getVersion());
  11803. }
  11804. return strcmp($b->getName(), $a->getName());
  11805. };
  11806. $this->resultPackageMap = array();
  11807. foreach ($resultPackages as $package) {
  11808. $this->resultPackageMap[spl_object_hash($package)] = $package;
  11809. foreach ($package->getNames() as $name) {
  11810. $this->resultPackagesByName[$name][] = $package;
  11811. }
  11812. }
  11813. uasort($this->resultPackageMap, $packageSort);
  11814. foreach ($this->resultPackagesByName as $name => $packages) {
  11815. uasort($this->resultPackagesByName[$name], $packageSort);
  11816. }
  11817. }
  11818. protected function calculateOperations()
  11819. {
  11820. $operations = array();
  11821. $presentPackageMap = array();
  11822. $removeMap = array();
  11823. $presentAliasMap = array();
  11824. $removeAliasMap = array();
  11825. foreach ($this->presentPackages as $package) {
  11826. if ($package instanceof AliasPackage) {
  11827. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11828. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11829. } else {
  11830. $presentPackageMap[$package->getName()] = $package;
  11831. $removeMap[$package->getName()] = $package;
  11832. }
  11833. }
  11834. $stack = $this->getRootPackages();
  11835. $visited = array();
  11836. $processed = array();
  11837. while (!empty($stack)) {
  11838. $package = array_pop($stack);
  11839. if (isset($processed[spl_object_hash($package)])) {
  11840. continue;
  11841. }
  11842. if (!isset($visited[spl_object_hash($package)])) {
  11843. $visited[spl_object_hash($package)] = true;
  11844. $stack[] = $package;
  11845. if ($package instanceof AliasPackage) {
  11846. $stack[] = $package->getAliasOf();
  11847. } else {
  11848. foreach ($package->getRequires() as $link) {
  11849. $possibleRequires = $this->getProvidersInResult($link);
  11850. foreach ($possibleRequires as $require) {
  11851. $stack[] = $require;
  11852. }
  11853. }
  11854. }
  11855. } elseif (!isset($processed[spl_object_hash($package)])) {
  11856. $processed[spl_object_hash($package)] = true;
  11857. if ($package instanceof AliasPackage) {
  11858. $aliasKey = $package->getName().'::'.$package->getVersion();
  11859. if (isset($presentAliasMap[$aliasKey])) {
  11860. unset($removeAliasMap[$aliasKey]);
  11861. } else {
  11862. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  11863. }
  11864. } else {
  11865. if (isset($presentPackageMap[$package->getName()])) {
  11866. $source = $presentPackageMap[$package->getName()];
  11867. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  11868. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  11869. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  11870. ) {
  11871. $operations[] = new Operation\UpdateOperation($source, $package);
  11872. }
  11873. unset($removeMap[$package->getName()]);
  11874. } else {
  11875. $operations[] = new Operation\InstallOperation($package);
  11876. unset($removeMap[$package->getName()]);
  11877. }
  11878. }
  11879. }
  11880. }
  11881. foreach ($removeMap as $name => $package) {
  11882. array_unshift($operations, new Operation\UninstallOperation($package));
  11883. }
  11884. foreach ($removeAliasMap as $nameVersion => $package) {
  11885. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  11886. }
  11887. $operations = $this->movePluginsToFront($operations);
  11888. $operations = $this->moveUninstallsToFront($operations);
  11889. return $this->operations = $operations;
  11890. }
  11891. protected function getRootPackages()
  11892. {
  11893. $roots = $this->resultPackageMap;
  11894. foreach ($this->resultPackageMap as $packageHash => $package) {
  11895. if (!isset($roots[$packageHash])) {
  11896. continue;
  11897. }
  11898. foreach ($package->getRequires() as $link) {
  11899. $possibleRequires = $this->getProvidersInResult($link);
  11900. foreach ($possibleRequires as $require) {
  11901. if ($require !== $package) {
  11902. unset($roots[spl_object_hash($require)]);
  11903. }
  11904. }
  11905. }
  11906. }
  11907. return $roots;
  11908. }
  11909. protected function getProvidersInResult(Link $link)
  11910. {
  11911. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  11912. return array();
  11913. }
  11914. return $this->resultPackagesByName[$link->getTarget()];
  11915. }
  11916. private function movePluginsToFront(array $operations)
  11917. {
  11918. $dlModifyingPluginsNoDeps = array();
  11919. $dlModifyingPluginsWithDeps = array();
  11920. $dlModifyingPluginRequires = array();
  11921. $pluginsNoDeps = array();
  11922. $pluginsWithDeps = array();
  11923. $pluginRequires = array();
  11924. foreach (array_reverse($operations, true) as $idx => $op) {
  11925. if ($op instanceof Operation\InstallOperation) {
  11926. $package = $op->getPackage();
  11927. } elseif ($op instanceof Operation\UpdateOperation) {
  11928. $package = $op->getTargetPackage();
  11929. } else {
  11930. continue;
  11931. }
  11932. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  11933. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  11934. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  11935. return !PlatformRepository::isPlatformPackage($req);
  11936. });
  11937. if ($isDownloadsModifyingPlugin && !count($requires)) {
  11938. array_unshift($dlModifyingPluginsNoDeps, $op);
  11939. } else {
  11940. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  11941. array_unshift($dlModifyingPluginsWithDeps, $op);
  11942. }
  11943. unset($operations[$idx]);
  11944. continue;
  11945. }
  11946. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  11947. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  11948. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  11949. return !PlatformRepository::isPlatformPackage($req);
  11950. });
  11951. if ($isPlugin && !count($requires)) {
  11952. array_unshift($pluginsNoDeps, $op);
  11953. } else {
  11954. $pluginRequires = array_merge($pluginRequires, $requires);
  11955. array_unshift($pluginsWithDeps, $op);
  11956. }
  11957. unset($operations[$idx]);
  11958. }
  11959. }
  11960. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  11961. }
  11962. private function moveUninstallsToFront(array $operations)
  11963. {
  11964. $uninstOps = array();
  11965. foreach ($operations as $idx => $op) {
  11966. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  11967. $uninstOps[] = $op;
  11968. unset($operations[$idx]);
  11969. }
  11970. }
  11971. return array_merge($uninstOps, $operations);
  11972. }
  11973. }
  11974. <?php
  11975. namespace Composer\Downloader;
  11976. use Composer\Package\PackageInterface;
  11977. use Symfony\Component\Finder\Finder;
  11978. use Composer\IO\IOInterface;
  11979. use Composer\Exception\IrrecoverableDownloadException;
  11980. use React\Promise\PromiseInterface;
  11981. use Composer\DependencyResolver\Operation\InstallOperation;
  11982. abstract class ArchiveDownloader extends FileDownloader
  11983. {
  11984. public function install(PackageInterface $package, $path, $output = true)
  11985. {
  11986. if ($output) {
  11987. $this->io->writeError(" - " . InstallOperation::format($package).": Extracting archive");
  11988. } else {
  11989. $this->io->writeError('Extracting archive', false);
  11990. }
  11991. $vendorDir = $this->config->get('vendor-dir');
  11992. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  11993. $this->filesystem->emptyDirectory($path);
  11994. }
  11995. do {
  11996. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  11997. } while (is_dir($temporaryDir));
  11998. $this->addCleanupPath($package, $temporaryDir);
  11999. if (!is_dir($path) || realpath($path) !== getcwd()) {
  12000. $this->addCleanupPath($package, $path);
  12001. }
  12002. $this->filesystem->ensureDirectoryExists($temporaryDir);
  12003. $fileName = $this->getFileName($package, $path);
  12004. $filesystem = $this->filesystem;
  12005. $self = $this;
  12006. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package, $self) {
  12007. $self->clearLastCacheWrite($package);
  12008. $filesystem->removeDirectory($temporaryDir);
  12009. if (is_dir($path) && realpath($path) !== getcwd()) {
  12010. $filesystem->removeDirectory($path);
  12011. }
  12012. $self->removeCleanupPath($package, $temporaryDir);
  12013. $self->removeCleanupPath($package, realpath($path));
  12014. };
  12015. $promise = null;
  12016. try {
  12017. $promise = $this->extract($package, $fileName, $temporaryDir);
  12018. } catch (\Exception $e) {
  12019. $cleanup();
  12020. throw $e;
  12021. }
  12022. if (!$promise instanceof PromiseInterface) {
  12023. $promise = \React\Promise\resolve();
  12024. }
  12025. return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) {
  12026. $filesystem->unlink($fileName);
  12027. $getFolderContent = function ($dir) {
  12028. $finder = Finder::create()
  12029. ->ignoreVCS(false)
  12030. ->ignoreDotFiles(false)
  12031. ->notName('.DS_Store')
  12032. ->depth(0)
  12033. ->in($dir);
  12034. return iterator_to_array($finder);
  12035. };
  12036. $renameAsOne = false;
  12037. if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectory($path))) {
  12038. $renameAsOne = true;
  12039. }
  12040. $contentDir = $getFolderContent($temporaryDir);
  12041. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));
  12042. if ($renameAsOne) {
  12043. if ($singleDirAtTopLevel) {
  12044. $extractedDir = (string) reset($contentDir);
  12045. } else {
  12046. $extractedDir = $temporaryDir;
  12047. }
  12048. $filesystem->rename($extractedDir, $path);
  12049. } else {
  12050. if ($singleDirAtTopLevel) {
  12051. $contentDir = $getFolderContent((string) reset($contentDir));
  12052. }
  12053. foreach ($contentDir as $file) {
  12054. $file = (string) $file;
  12055. $filesystem->rename($file, $path . '/' . basename($file));
  12056. }
  12057. }
  12058. $filesystem->removeDirectory($temporaryDir);
  12059. $self->removeCleanupPath($package, $temporaryDir);
  12060. $self->removeCleanupPath($package, $path);
  12061. }, function ($e) use ($cleanup) {
  12062. $cleanup();
  12063. throw $e;
  12064. });
  12065. }
  12066. abstract protected function extract(PackageInterface $package, $file, $path);
  12067. }
  12068. <?php
  12069. namespace Composer\Downloader;
  12070. use Composer\Package\PackageInterface;
  12071. interface ChangeReportInterface
  12072. {
  12073. public function getLocalChanges(PackageInterface $package, $path);
  12074. }
  12075. <?php
  12076. namespace Composer\Downloader;
  12077. use Composer\Package\PackageInterface;
  12078. use Composer\IO\IOInterface;
  12079. use Composer\Util\Filesystem;
  12080. use Composer\Exception\IrrecoverableDownloadException;
  12081. use React\Promise\PromiseInterface;
  12082. class DownloadManager
  12083. {
  12084. private $io;
  12085. private $preferDist = false;
  12086. private $preferSource;
  12087. private $packagePreferences = array();
  12088. private $filesystem;
  12089. private $downloaders = array();
  12090. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  12091. {
  12092. $this->io = $io;
  12093. $this->preferSource = $preferSource;
  12094. $this->filesystem = $filesystem ?: new Filesystem();
  12095. }
  12096. public function setPreferSource($preferSource)
  12097. {
  12098. $this->preferSource = $preferSource;
  12099. return $this;
  12100. }
  12101. public function setPreferDist($preferDist)
  12102. {
  12103. $this->preferDist = $preferDist;
  12104. return $this;
  12105. }
  12106. public function setPreferences(array $preferences)
  12107. {
  12108. $this->packagePreferences = $preferences;
  12109. return $this;
  12110. }
  12111. public function setDownloader($type, DownloaderInterface $downloader)
  12112. {
  12113. $type = strtolower($type);
  12114. $this->downloaders[$type] = $downloader;
  12115. return $this;
  12116. }
  12117. public function getDownloader($type)
  12118. {
  12119. $type = strtolower($type);
  12120. if (!isset($this->downloaders[$type])) {
  12121. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  12122. }
  12123. return $this->downloaders[$type];
  12124. }
  12125. public function getDownloaderForPackage(PackageInterface $package)
  12126. {
  12127. $installationSource = $package->getInstallationSource();
  12128. if ('metapackage' === $package->getType()) {
  12129. return;
  12130. }
  12131. if ('dist' === $installationSource) {
  12132. $downloader = $this->getDownloader($package->getDistType());
  12133. } elseif ('source' === $installationSource) {
  12134. $downloader = $this->getDownloader($package->getSourceType());
  12135. } else {
  12136. throw new \InvalidArgumentException(
  12137. 'Package '.$package.' does not have an installation source set'
  12138. );
  12139. }
  12140. if ($installationSource !== $downloader->getInstallationSource()) {
  12141. throw new \LogicException(sprintf(
  12142. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  12143. get_class($downloader),
  12144. $downloader->getInstallationSource(),
  12145. $installationSource,
  12146. $package
  12147. ));
  12148. }
  12149. return $downloader;
  12150. }
  12151. public function getDownloaderType(DownloaderInterface $downloader)
  12152. {
  12153. return array_search($downloader, $this->downloaders);
  12154. }
  12155. public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12156. {
  12157. $targetDir = $this->normalizeTargetDir($targetDir);
  12158. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  12159. $sources = $this->getAvailableSources($package, $prevPackage);
  12160. $io = $this->io;
  12161. $self = $this;
  12162. $download = function ($retry = false) use (&$sources, $io, $package, $self, $targetDir, &$download, $prevPackage) {
  12163. $source = array_shift($sources);
  12164. if ($retry) {
  12165. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  12166. }
  12167. $package->setInstallationSource($source);
  12168. $downloader = $self->getDownloaderForPackage($package);
  12169. if (!$downloader) {
  12170. return \React\Promise\resolve();
  12171. }
  12172. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  12173. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  12174. if (!$sources) {
  12175. throw $e;
  12176. }
  12177. $io->writeError(
  12178. ' <warning>Failed to download '.
  12179. $package->getPrettyName().
  12180. ' from ' . $source . ': '.
  12181. $e->getMessage().'</warning>'
  12182. );
  12183. return $download(true);
  12184. }
  12185. throw $e;
  12186. };
  12187. try {
  12188. $result = $downloader->download($package, $targetDir, $prevPackage);
  12189. } catch (\Exception $e) {
  12190. return $handleError($e);
  12191. }
  12192. if (!$result instanceof PromiseInterface) {
  12193. return \React\Promise\resolve($result);
  12194. }
  12195. $res = $result->then(function ($res) {
  12196. return $res;
  12197. }, $handleError);
  12198. return $res;
  12199. };
  12200. return $download();
  12201. }
  12202. public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12203. {
  12204. $targetDir = $this->normalizeTargetDir($targetDir);
  12205. $downloader = $this->getDownloaderForPackage($package);
  12206. if ($downloader) {
  12207. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  12208. }
  12209. }
  12210. public function install(PackageInterface $package, $targetDir)
  12211. {
  12212. $targetDir = $this->normalizeTargetDir($targetDir);
  12213. $downloader = $this->getDownloaderForPackage($package);
  12214. if ($downloader) {
  12215. return $downloader->install($package, $targetDir);
  12216. }
  12217. }
  12218. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  12219. {
  12220. $targetDir = $this->normalizeTargetDir($targetDir);
  12221. $downloader = $this->getDownloaderForPackage($target);
  12222. $initialDownloader = $this->getDownloaderForPackage($initial);
  12223. if (!$initialDownloader && !$downloader) {
  12224. return;
  12225. }
  12226. if (!$downloader) {
  12227. return $initialDownloader->remove($initial, $targetDir);
  12228. }
  12229. $initialType = $this->getDownloaderType($initialDownloader);
  12230. $targetType = $this->getDownloaderType($downloader);
  12231. if ($initialType === $targetType) {
  12232. try {
  12233. return $downloader->update($initial, $target, $targetDir);
  12234. } catch (\RuntimeException $e) {
  12235. if (!$this->io->isInteractive()) {
  12236. throw $e;
  12237. }
  12238. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  12239. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  12240. throw $e;
  12241. }
  12242. }
  12243. }
  12244. $promise = $initialDownloader->remove($initial, $targetDir);
  12245. if ($promise) {
  12246. $self = $this;
  12247. return $promise->then(function ($res) use ($self, $target, $targetDir) {
  12248. return $self->install($target, $targetDir);
  12249. });
  12250. }
  12251. return $this->install($target, $targetDir);
  12252. }
  12253. public function remove(PackageInterface $package, $targetDir)
  12254. {
  12255. $targetDir = $this->normalizeTargetDir($targetDir);
  12256. $downloader = $this->getDownloaderForPackage($package);
  12257. if ($downloader) {
  12258. return $downloader->remove($package, $targetDir);
  12259. }
  12260. }
  12261. public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12262. {
  12263. $targetDir = $this->normalizeTargetDir($targetDir);
  12264. $downloader = $this->getDownloaderForPackage($package);
  12265. if ($downloader) {
  12266. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  12267. }
  12268. }
  12269. protected function resolvePackageInstallPreference(PackageInterface $package)
  12270. {
  12271. foreach ($this->packagePreferences as $pattern => $preference) {
  12272. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  12273. if (preg_match($pattern, $package->getName())) {
  12274. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  12275. return 'dist';
  12276. }
  12277. return 'source';
  12278. }
  12279. }
  12280. return $package->isDev() ? 'source' : 'dist';
  12281. }
  12282. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
  12283. {
  12284. $sourceType = $package->getSourceType();
  12285. $distType = $package->getDistType();
  12286. $sources = array();
  12287. if ($sourceType) {
  12288. $sources[] = 'source';
  12289. }
  12290. if ($distType) {
  12291. $sources[] = 'dist';
  12292. }
  12293. if (empty($sources)) {
  12294. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  12295. }
  12296. if (
  12297. $prevPackage
  12298. && in_array($prevPackage->getInstallationSource(), $sources, true)
  12299. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  12300. ) {
  12301. $prevSource = $prevPackage->getInstallationSource();
  12302. usort($sources, function ($a, $b) use ($prevSource) {
  12303. return $a === $prevSource ? -1 : 1;
  12304. });
  12305. return $sources;
  12306. }
  12307. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  12308. $sources = array_reverse($sources);
  12309. }
  12310. return $sources;
  12311. }
  12312. private function normalizeTargetDir($dir)
  12313. {
  12314. if ($dir === '\\' || $dir === '/') {
  12315. return $dir;
  12316. }
  12317. return rtrim($dir, '\\/');
  12318. }
  12319. }
  12320. <?php
  12321. namespace Composer\Downloader;
  12322. use Composer\Package\PackageInterface;
  12323. use React\Promise\PromiseInterface;
  12324. interface DownloaderInterface
  12325. {
  12326. public function getInstallationSource();
  12327. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12328. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12329. public function install(PackageInterface $package, $path);
  12330. public function update(PackageInterface $initial, PackageInterface $target, $path);
  12331. public function remove(PackageInterface $package, $path);
  12332. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12333. }
  12334. <?php
  12335. namespace Composer\Downloader;
  12336. use Composer\Package\PackageInterface;
  12337. interface DvcsDownloaderInterface
  12338. {
  12339. public function getUnpushedChanges(PackageInterface $package, $path);
  12340. }
  12341. <?php
  12342. namespace Composer\Downloader;
  12343. use Composer\Config;
  12344. use Composer\Cache;
  12345. use Composer\IO\IOInterface;
  12346. use Composer\IO\NullIO;
  12347. use Composer\Package\Comparer\Comparer;
  12348. use Composer\DependencyResolver\Operation\UpdateOperation;
  12349. use Composer\DependencyResolver\Operation\InstallOperation;
  12350. use Composer\DependencyResolver\Operation\UninstallOperation;
  12351. use Composer\Package\PackageInterface;
  12352. use Composer\Plugin\PluginEvents;
  12353. use Composer\Plugin\PostFileDownloadEvent;
  12354. use Composer\Plugin\PreFileDownloadEvent;
  12355. use Composer\EventDispatcher\EventDispatcher;
  12356. use Composer\Util\Filesystem;
  12357. use Composer\Util\HttpDownloader;
  12358. use Composer\Util\Url as UrlUtil;
  12359. use Composer\Util\ProcessExecutor;
  12360. use Composer\Downloader\TransportException;
  12361. use React\Promise\PromiseInterface;
  12362. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  12363. {
  12364. protected $io;
  12365. protected $config;
  12366. protected $httpDownloader;
  12367. protected $filesystem;
  12368. protected $cache;
  12369. protected $eventDispatcher;
  12370. protected $process;
  12371. public $lastCacheWrites = array();
  12372. private $additionalCleanupPaths = array();
  12373. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  12374. {
  12375. $this->io = $io;
  12376. $this->config = $config;
  12377. $this->eventDispatcher = $eventDispatcher;
  12378. $this->httpDownloader = $httpDownloader;
  12379. $this->cache = $cache;
  12380. $this->process = $process ?: new ProcessExecutor($io);
  12381. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  12382. if ($this->cache && $this->cache->gcIsNecessary()) {
  12383. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  12384. }
  12385. }
  12386. public function getInstallationSource()
  12387. {
  12388. return 'dist';
  12389. }
  12390. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  12391. {
  12392. if (!$package->getDistUrl()) {
  12393. throw new \InvalidArgumentException('The given package is missing url information');
  12394. }
  12395. $cacheKeyGenerator = function (PackageInterface $package, $key) {
  12396. $cacheKey = sha1($key);
  12397. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  12398. };
  12399. $retries = 3;
  12400. $urls = $package->getDistUrls();
  12401. foreach ($urls as $index => $url) {
  12402. $processedUrl = $this->processUrl($package, $url);
  12403. $urls[$index] = array(
  12404. 'base' => $url,
  12405. 'processed' => $processedUrl,
  12406. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl)
  12407. );
  12408. }
  12409. $fileName = $this->getFileName($package, $path);
  12410. $this->filesystem->ensureDirectoryExists($path);
  12411. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  12412. $io = $this->io;
  12413. $cache = $this->cache;
  12414. $httpDownloader = $this->httpDownloader;
  12415. $eventDispatcher = $this->eventDispatcher;
  12416. $filesystem = $this->filesystem;
  12417. $self = $this;
  12418. $accept = null;
  12419. $reject = null;
  12420. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject) {
  12421. $url = reset($urls);
  12422. $index = key($urls);
  12423. if ($eventDispatcher) {
  12424. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  12425. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  12426. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  12427. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  12428. } else if ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  12429. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  12430. }
  12431. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  12432. }
  12433. $urls[$index] = $url;
  12434. $checksum = $package->getDistSha1Checksum();
  12435. $cacheKey = $url['cacheKey'];
  12436. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  12437. if ($output) {
  12438. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  12439. }
  12440. $result = \React\Promise\resolve($fileName);
  12441. } else {
  12442. if ($output) {
  12443. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  12444. }
  12445. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  12446. ->then($accept, $reject);
  12447. }
  12448. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher) {
  12449. if (null === $result) {
  12450. return $fileName;
  12451. }
  12452. if (!file_exists($fileName)) {
  12453. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  12454. .' directory is writable and you have internet connectivity');
  12455. }
  12456. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  12457. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  12458. }
  12459. if ($eventDispatcher) {
  12460. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], $package);
  12461. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  12462. }
  12463. return $fileName;
  12464. });
  12465. };
  12466. $accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
  12467. $url = reset($urls);
  12468. $cacheKey = $url['cacheKey'];
  12469. if ($cache && !$cache->isReadOnly()) {
  12470. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  12471. $cache->copyFrom($cacheKey, $fileName);
  12472. }
  12473. $response->collect();
  12474. return $fileName;
  12475. };
  12476. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem, $self) {
  12477. if (file_exists($fileName)) {
  12478. $filesystem->unlink($fileName);
  12479. }
  12480. $self->clearLastCacheWrite($package);
  12481. if ($e instanceof TransportException) {
  12482. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  12483. $retries = 0;
  12484. }
  12485. }
  12486. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  12487. $retries = 0;
  12488. $urls = array();
  12489. }
  12490. if ($retries) {
  12491. usleep(500000);
  12492. $retries--;
  12493. return $download();
  12494. }
  12495. array_shift($urls);
  12496. if ($urls) {
  12497. if ($io->isDebug()) {
  12498. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  12499. $io->writeError(' Trying the next URL for '.$package->getName());
  12500. } else {
  12501. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  12502. }
  12503. $retries = 3;
  12504. usleep(100000);
  12505. return $download();
  12506. }
  12507. throw $e;
  12508. };
  12509. return $download();
  12510. }
  12511. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12512. {
  12513. }
  12514. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12515. {
  12516. $fileName = $this->getFileName($package, $path);
  12517. if (file_exists($fileName)) {
  12518. $this->filesystem->unlink($fileName);
  12519. }
  12520. $dirsToCleanUp = array(
  12521. $this->config->get('vendor-dir').'/composer/',
  12522. $this->config->get('vendor-dir'),
  12523. $path,
  12524. );
  12525. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12526. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  12527. $this->filesystem->remove($path);
  12528. }
  12529. }
  12530. foreach ($dirsToCleanUp as $dir) {
  12531. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
  12532. $this->filesystem->removeDirectory($dir);
  12533. }
  12534. }
  12535. }
  12536. public function install(PackageInterface $package, $path, $output = true)
  12537. {
  12538. if ($output) {
  12539. $this->io->writeError(" - " . InstallOperation::format($package));
  12540. }
  12541. $this->filesystem->emptyDirectory($path);
  12542. $this->filesystem->ensureDirectoryExists($path);
  12543. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
  12544. }
  12545. public function clearLastCacheWrite(PackageInterface $package)
  12546. {
  12547. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  12548. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  12549. unset($this->lastCacheWrites[$package->getName()]);
  12550. }
  12551. }
  12552. public function addCleanupPath(PackageInterface $package, $path)
  12553. {
  12554. $this->additionalCleanupPaths[$package->getName()][] = $path;
  12555. }
  12556. public function removeCleanupPath(PackageInterface $package, $path)
  12557. {
  12558. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12559. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  12560. if (false !== $idx) {
  12561. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  12562. }
  12563. }
  12564. }
  12565. public function update(PackageInterface $initial, PackageInterface $target, $path)
  12566. {
  12567. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . ": ", false);
  12568. $promise = $this->remove($initial, $path, false);
  12569. if ($promise === null || !$promise instanceof PromiseInterface) {
  12570. $promise = \React\Promise\resolve();
  12571. }
  12572. $self = $this;
  12573. $io = $this->io;
  12574. return $promise->then(function () use ($self, $target, $path, $io) {
  12575. $promise = $self->install($target, $path, false);
  12576. $io->writeError('');
  12577. return $promise;
  12578. });
  12579. }
  12580. public function remove(PackageInterface $package, $path, $output = true)
  12581. {
  12582. if ($output) {
  12583. $this->io->writeError(" - " . UninstallOperation::format($package));
  12584. }
  12585. if (!$this->filesystem->removeDirectory($path)) {
  12586. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  12587. }
  12588. }
  12589. protected function getFileName(PackageInterface $package, $path)
  12590. {
  12591. 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), '.');
  12592. }
  12593. protected function processUrl(PackageInterface $package, $url)
  12594. {
  12595. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  12596. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  12597. }
  12598. if ($package->getDistReference()) {
  12599. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  12600. }
  12601. return $url;
  12602. }
  12603. public function getLocalChanges(PackageInterface $package, $targetDir)
  12604. {
  12605. $prevIO = $this->io;
  12606. $this->io = new NullIO;
  12607. $this->io->loadConfiguration($this->config);
  12608. $e = null;
  12609. $output = '';
  12610. $targetDir = Filesystem::trimTrailingSlash($targetDir);
  12611. try {
  12612. if (is_dir($targetDir.'_compare')) {
  12613. $this->filesystem->removeDirectory($targetDir.'_compare');
  12614. }
  12615. $this->download($package, $targetDir.'_compare', null, false);
  12616. $this->httpDownloader->wait();
  12617. $this->install($package, $targetDir.'_compare', false);
  12618. $this->process->wait();
  12619. $comparer = new Comparer();
  12620. $comparer->setSource($targetDir.'_compare');
  12621. $comparer->setUpdate($targetDir);
  12622. $comparer->doCompare();
  12623. $output = $comparer->getChanged(true, true);
  12624. $this->filesystem->removeDirectory($targetDir.'_compare');
  12625. } catch (\Exception $e) {
  12626. }
  12627. $this->io = $prevIO;
  12628. if ($e) {
  12629. throw $e;
  12630. }
  12631. return trim($output);
  12632. }
  12633. }
  12634. <?php
  12635. namespace Composer\Downloader;
  12636. class FilesystemException extends \Exception
  12637. {
  12638. public function __construct($message = '', $code = 0, \Exception $previous = null)
  12639. {
  12640. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  12641. }
  12642. }
  12643. <?php
  12644. namespace Composer\Downloader;
  12645. use Composer\Package\PackageInterface;
  12646. use Composer\Util\ProcessExecutor;
  12647. class FossilDownloader extends VcsDownloader
  12648. {
  12649. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12650. {
  12651. }
  12652. protected function doInstall(PackageInterface $package, $path, $url)
  12653. {
  12654. $this->config->prohibitUrlByConfig($url, $this->io);
  12655. $url = ProcessExecutor::escape($url);
  12656. $ref = ProcessExecutor::escape($package->getSourceReference());
  12657. $repoFile = $path . '.fossil';
  12658. $this->io->writeError("Cloning ".$package->getSourceReference());
  12659. $command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape($repoFile));
  12660. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  12661. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12662. }
  12663. $command = sprintf('fossil open %s --nested', ProcessExecutor::escape($repoFile));
  12664. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12665. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12666. }
  12667. $command = sprintf('fossil update %s', $ref);
  12668. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12669. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12670. }
  12671. }
  12672. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12673. {
  12674. $this->config->prohibitUrlByConfig($url, $this->io);
  12675. $ref = ProcessExecutor::escape($target->getSourceReference());
  12676. $this->io->writeError(" Updating to ".$target->getSourceReference());
  12677. if (!$this->hasMetadataRepository($path)) {
  12678. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12679. }
  12680. $command = sprintf('fossil pull && fossil up %s', $ref);
  12681. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12682. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12683. }
  12684. }
  12685. public function getLocalChanges(PackageInterface $package, $path)
  12686. {
  12687. if (!$this->hasMetadataRepository($path)) {
  12688. return null;
  12689. }
  12690. $this->process->execute('fossil changes', $output, realpath($path));
  12691. return trim($output) ?: null;
  12692. }
  12693. protected function getCommitLogs($fromReference, $toReference, $path)
  12694. {
  12695. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  12696. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  12697. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12698. }
  12699. $log = '';
  12700. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  12701. foreach ($this->process->splitLines($output) as $line) {
  12702. if (preg_match($match, $line)) {
  12703. break;
  12704. }
  12705. $log .= $line;
  12706. }
  12707. return $log;
  12708. }
  12709. protected function hasMetadataRepository($path)
  12710. {
  12711. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  12712. }
  12713. }
  12714. <?php
  12715. namespace Composer\Downloader;
  12716. use Composer\Config;
  12717. use Composer\IO\IOInterface;
  12718. use Composer\Package\PackageInterface;
  12719. use Composer\Util\Filesystem;
  12720. use Composer\Util\Git as GitUtil;
  12721. use Composer\Util\Url;
  12722. use Composer\Util\Platform;
  12723. use Composer\Util\ProcessExecutor;
  12724. use Composer\Cache;
  12725. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  12726. {
  12727. private $hasStashedChanges = array();
  12728. private $hasDiscardedChanges = array();
  12729. private $gitUtil;
  12730. private $cachedPackages = array();
  12731. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  12732. {
  12733. parent::__construct($io, $config, $process, $fs);
  12734. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  12735. }
  12736. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12737. {
  12738. GitUtil::cleanEnv();
  12739. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12740. $gitVersion = GitUtil::getVersion($this->process);
  12741. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  12742. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  12743. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  12744. $ref = $package->getSourceReference();
  12745. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  12746. $this->cachedPackages[$package->getId()][$ref] = true;
  12747. }
  12748. }
  12749. }
  12750. protected function doInstall(PackageInterface $package, $path, $url)
  12751. {
  12752. GitUtil::cleanEnv();
  12753. $path = $this->normalizePath($path);
  12754. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12755. $ref = $package->getSourceReference();
  12756. $flag = Platform::isWindows() ? '/D ' : '';
  12757. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  12758. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  12759. $command =
  12760. 'git clone --no-checkout %cachePath% %path% --dissociate --reference %cachePath% '
  12761. . '&& cd '.$flag.'%path% '
  12762. . '&& git remote set-url origin %sanitizedUrl% && git remote add composer %sanitizedUrl%';
  12763. } else {
  12764. $msg = "Cloning ".$this->getShortHash($ref);
  12765. $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%';
  12766. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12767. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  12768. }
  12769. }
  12770. $this->io->writeError($msg);
  12771. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  12772. return str_replace(
  12773. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  12774. array(
  12775. ProcessExecutor::escape($url),
  12776. ProcessExecutor::escape($path),
  12777. ProcessExecutor::escape($cachePath),
  12778. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12779. ),
  12780. $command
  12781. );
  12782. };
  12783. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  12784. if ($url !== $package->getSourceUrl()) {
  12785. $this->updateOriginUrl($path, $package->getSourceUrl());
  12786. } else {
  12787. $this->setPushUrl($path, $url);
  12788. }
  12789. if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
  12790. if ($package->getDistReference() === $package->getSourceReference()) {
  12791. $package->setDistReference($newRef);
  12792. }
  12793. $package->setSourceReference($newRef);
  12794. }
  12795. }
  12796. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12797. {
  12798. GitUtil::cleanEnv();
  12799. $path = $this->normalizePath($path);
  12800. if (!$this->hasMetadataRepository($path)) {
  12801. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12802. }
  12803. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12804. $ref = $target->getSourceReference();
  12805. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  12806. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  12807. $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%';
  12808. } else {
  12809. $msg = "Checking out ".$this->getShortHash($ref);
  12810. $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%';
  12811. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12812. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  12813. }
  12814. }
  12815. $this->io->writeError($msg);
  12816. $commandCallable = function ($url) use ($ref, $command, $cachePath) {
  12817. return str_replace(
  12818. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  12819. array(
  12820. ProcessExecutor::escape($url),
  12821. ProcessExecutor::escape($ref.'^{commit}'),
  12822. ProcessExecutor::escape($cachePath),
  12823. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12824. ),
  12825. $command
  12826. );
  12827. };
  12828. $this->gitUtil->runCommand($commandCallable, $url, $path);
  12829. if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
  12830. if ($target->getDistReference() === $target->getSourceReference()) {
  12831. $target->setDistReference($newRef);
  12832. }
  12833. $target->setSourceReference($newRef);
  12834. }
  12835. $updateOriginUrl = false;
  12836. if (
  12837. 0 === $this->process->execute('git remote -v', $output, $path)
  12838. && preg_match('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  12839. && preg_match('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  12840. ) {
  12841. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  12842. $updateOriginUrl = true;
  12843. }
  12844. }
  12845. if ($updateOriginUrl) {
  12846. $this->updateOriginUrl($path, $target->getSourceUrl());
  12847. }
  12848. }
  12849. public function getLocalChanges(PackageInterface $package, $path)
  12850. {
  12851. GitUtil::cleanEnv();
  12852. if (!$this->hasMetadataRepository($path)) {
  12853. return;
  12854. }
  12855. $command = 'git status --porcelain --untracked-files=no';
  12856. if (0 !== $this->process->execute($command, $output, $path)) {
  12857. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12858. }
  12859. return trim($output) ?: null;
  12860. }
  12861. public function getUnpushedChanges(PackageInterface $package, $path)
  12862. {
  12863. GitUtil::cleanEnv();
  12864. $path = $this->normalizePath($path);
  12865. if (!$this->hasMetadataRepository($path)) {
  12866. return;
  12867. }
  12868. $command = 'git show-ref --head -d';
  12869. if (0 !== $this->process->execute($command, $output, $path)) {
  12870. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12871. }
  12872. $refs = trim($output);
  12873. if (!preg_match('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  12874. return;
  12875. }
  12876. $headRef = $match[1];
  12877. if (!preg_match_all('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  12878. return;
  12879. }
  12880. $branch = $matches[1][0];
  12881. $unpushedChanges = null;
  12882. for ($i = 0; $i <= 1; $i++) {
  12883. foreach ($matches[1] as $candidate) {
  12884. if (preg_match('{^[a-f0-9]+ refs/remotes/((?:composer|origin)/'.preg_quote($candidate).')$}mi', $refs, $match)) {
  12885. $branch = $candidate;
  12886. $remoteBranch = $match[1];
  12887. break;
  12888. }
  12889. }
  12890. if (!isset($remoteBranch)) {
  12891. $unpushedChanges = 'Branch ' . $branch . ' could not be found on the origin remote and appears to be unpushed';
  12892. } else {
  12893. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  12894. if (0 !== $this->process->execute($command, $output, $path)) {
  12895. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12896. }
  12897. $unpushedChanges = trim($output) ?: null;
  12898. }
  12899. if ($unpushedChanges && $i === 0) {
  12900. $this->process->execute('git fetch composer && git fetch origin', $output, $path);
  12901. }
  12902. if (!$unpushedChanges) {
  12903. break;
  12904. }
  12905. }
  12906. return $unpushedChanges;
  12907. }
  12908. protected function cleanChanges(PackageInterface $package, $path, $update)
  12909. {
  12910. GitUtil::cleanEnv();
  12911. $path = $this->normalizePath($path);
  12912. $unpushed = $this->getUnpushedChanges($package, $path);
  12913. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  12914. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  12915. }
  12916. if (!$changes = $this->getLocalChanges($package, $path)) {
  12917. return;
  12918. }
  12919. if (!$this->io->isInteractive()) {
  12920. $discardChanges = $this->config->get('discard-changes');
  12921. if (true === $discardChanges) {
  12922. return $this->discardChanges($path);
  12923. }
  12924. if ('stash' === $discardChanges) {
  12925. if (!$update) {
  12926. return parent::cleanChanges($package, $path, $update);
  12927. }
  12928. return $this->stashChanges($path);
  12929. }
  12930. return parent::cleanChanges($package, $path, $update);
  12931. }
  12932. $changes = array_map(function ($elem) {
  12933. return ' '.$elem;
  12934. }, preg_split('{\s*\r?\n\s*}', $changes));
  12935. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  12936. $this->io->writeError(array_slice($changes, 0, 10));
  12937. if (count($changes) > 10) {
  12938. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  12939. }
  12940. while (true) {
  12941. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  12942. case 'y':
  12943. $this->discardChanges($path);
  12944. break 2;
  12945. case 's':
  12946. if (!$update) {
  12947. goto help;
  12948. }
  12949. $this->stashChanges($path);
  12950. break 2;
  12951. case 'n':
  12952. throw new \RuntimeException('Update aborted');
  12953. case 'v':
  12954. $this->io->writeError($changes);
  12955. break;
  12956. case 'd':
  12957. $this->viewDiff($path);
  12958. break;
  12959. case '?':
  12960. default:
  12961. help:
  12962. $this->io->writeError(array(
  12963. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  12964. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  12965. ' v - view modified files',
  12966. ' d - view local modifications (diff)',
  12967. ));
  12968. if ($update) {
  12969. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  12970. }
  12971. $this->io->writeError(' ? - print help');
  12972. break;
  12973. }
  12974. }
  12975. }
  12976. protected function reapplyChanges($path)
  12977. {
  12978. $path = $this->normalizePath($path);
  12979. if (!empty($this->hasStashedChanges[$path])) {
  12980. unset($this->hasStashedChanges[$path]);
  12981. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  12982. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  12983. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  12984. }
  12985. }
  12986. unset($this->hasDiscardedChanges[$path]);
  12987. }
  12988. protected function updateToCommit($path, $reference, $branch, $date)
  12989. {
  12990. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  12991. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  12992. $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
  12993. $branches = null;
  12994. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  12995. $branches = $output;
  12996. }
  12997. $gitRef = $reference;
  12998. if (!preg_match('{^[a-f0-9]{40}$}', $reference)
  12999. && $branches
  13000. && preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  13001. ) {
  13002. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  13003. if (0 === $this->process->execute($command, $output, $path)) {
  13004. return null;
  13005. }
  13006. }
  13007. if (preg_match('{^[a-f0-9]{40}$}', $reference)) {
  13008. if (!preg_match('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && preg_match('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  13009. $branch = 'v' . $branch;
  13010. }
  13011. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  13012. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  13013. if (0 === $this->process->execute($command, $output, $path)
  13014. || 0 === $this->process->execute($fallbackCommand, $output, $path)
  13015. ) {
  13016. $command = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  13017. if (0 === $this->process->execute($command, $output, $path)) {
  13018. return null;
  13019. }
  13020. }
  13021. }
  13022. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  13023. if (0 === $this->process->execute($command, $output, $path)) {
  13024. return null;
  13025. }
  13026. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  13027. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  13028. }
  13029. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
  13030. }
  13031. protected function updateOriginUrl($path, $url)
  13032. {
  13033. $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
  13034. $this->setPushUrl($path, $url);
  13035. }
  13036. protected function setPushUrl($path, $url)
  13037. {
  13038. if (preg_match('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  13039. $protocols = $this->config->get('github-protocols');
  13040. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  13041. if (!in_array('ssh', $protocols, true)) {
  13042. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  13043. }
  13044. $cmd = sprintf('git remote set-url --push origin %s', ProcessExecutor::escape($pushUrl));
  13045. $this->process->execute($cmd, $ignoredOutput, $path);
  13046. }
  13047. }
  13048. protected function getCommitLogs($fromReference, $toReference, $path)
  13049. {
  13050. $path = $this->normalizePath($path);
  13051. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13052. if (0 !== $this->process->execute($command, $output, $path)) {
  13053. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13054. }
  13055. return $output;
  13056. }
  13057. protected function discardChanges($path)
  13058. {
  13059. $path = $this->normalizePath($path);
  13060. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  13061. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  13062. }
  13063. $this->hasDiscardedChanges[$path] = true;
  13064. }
  13065. protected function stashChanges($path)
  13066. {
  13067. $path = $this->normalizePath($path);
  13068. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  13069. throw new \RuntimeException("Could not stash changes\n\n:".$this->process->getErrorOutput());
  13070. }
  13071. $this->hasStashedChanges[$path] = true;
  13072. }
  13073. protected function viewDiff($path)
  13074. {
  13075. $path = $this->normalizePath($path);
  13076. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  13077. throw new \RuntimeException("Could not view diff\n\n:".$this->process->getErrorOutput());
  13078. }
  13079. $this->io->writeError($output);
  13080. }
  13081. protected function normalizePath($path)
  13082. {
  13083. if (Platform::isWindows() && strlen($path) > 0) {
  13084. $basePath = $path;
  13085. $removed = array();
  13086. while (!is_dir($basePath) && $basePath !== '\\') {
  13087. array_unshift($removed, basename($basePath));
  13088. $basePath = dirname($basePath);
  13089. }
  13090. if ($basePath === '\\') {
  13091. return $path;
  13092. }
  13093. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  13094. }
  13095. return $path;
  13096. }
  13097. protected function hasMetadataRepository($path)
  13098. {
  13099. $path = $this->normalizePath($path);
  13100. return is_dir($path.'/.git');
  13101. }
  13102. protected function getShortHash($reference)
  13103. {
  13104. if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {
  13105. return substr($reference, 0, 10);
  13106. }
  13107. return $reference;
  13108. }
  13109. }
  13110. <?php
  13111. namespace Composer\Downloader;
  13112. use Composer\Config;
  13113. use Composer\Cache;
  13114. use Composer\EventDispatcher\EventDispatcher;
  13115. use Composer\Package\PackageInterface;
  13116. use Composer\Util\Platform;
  13117. use Composer\Util\ProcessExecutor;
  13118. use Composer\Util\HttpDownloader;
  13119. use Composer\IO\IOInterface;
  13120. use Composer\Util\Filesystem;
  13121. class GzipDownloader extends ArchiveDownloader
  13122. {
  13123. protected function extract(PackageInterface $package, $file, $path)
  13124. {
  13125. $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
  13126. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  13127. if (!Platform::isWindows()) {
  13128. $command = 'gzip -cd ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  13129. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13130. return;
  13131. }
  13132. if (extension_loaded('zlib')) {
  13133. $this->extractUsingExt($file, $targetFilepath);
  13134. return;
  13135. }
  13136. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13137. throw new \RuntimeException($processError);
  13138. }
  13139. $this->extractUsingExt($file, $targetFilepath);
  13140. }
  13141. private function extractUsingExt($file, $targetFilepath)
  13142. {
  13143. $archiveFile = gzopen($file, 'rb');
  13144. $targetFile = fopen($targetFilepath, 'wb');
  13145. while ($string = gzread($archiveFile, 4096)) {
  13146. fwrite($targetFile, $string, Platform::strlen($string));
  13147. }
  13148. gzclose($archiveFile);
  13149. fclose($targetFile);
  13150. }
  13151. }
  13152. <?php
  13153. namespace Composer\Downloader;
  13154. use Composer\Package\PackageInterface;
  13155. use Composer\Util\ProcessExecutor;
  13156. use Composer\Util\Hg as HgUtils;
  13157. class HgDownloader extends VcsDownloader
  13158. {
  13159. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13160. {
  13161. }
  13162. protected function doInstall(PackageInterface $package, $path, $url)
  13163. {
  13164. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13165. $cloneCommand = function ($url) use ($path) {
  13166. return sprintf('hg clone %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  13167. };
  13168. $hgUtils->runCommand($cloneCommand, $url, $path);
  13169. $ref = ProcessExecutor::escape($package->getSourceReference());
  13170. $command = sprintf('hg up %s', $ref);
  13171. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13172. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13173. }
  13174. }
  13175. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13176. {
  13177. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13178. $ref = $target->getSourceReference();
  13179. $this->io->writeError(" Updating to ".$target->getSourceReference());
  13180. if (!$this->hasMetadataRepository($path)) {
  13181. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13182. }
  13183. $command = function ($url) use ($ref) {
  13184. return sprintf('hg pull %s && hg up %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  13185. };
  13186. $hgUtils->runCommand($command, $url, $path);
  13187. }
  13188. public function getLocalChanges(PackageInterface $package, $path)
  13189. {
  13190. if (!is_dir($path.'/.hg')) {
  13191. return null;
  13192. }
  13193. $this->process->execute('hg st', $output, realpath($path));
  13194. return trim($output) ?: null;
  13195. }
  13196. protected function getCommitLogs($fromReference, $toReference, $path)
  13197. {
  13198. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13199. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  13200. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13201. }
  13202. return $output;
  13203. }
  13204. protected function hasMetadataRepository($path)
  13205. {
  13206. return is_dir($path . '/.hg');
  13207. }
  13208. }
  13209. <?php
  13210. namespace Composer\Downloader;
  13211. class MaxFileSizeExceededException extends TransportException
  13212. {
  13213. }
  13214. <?php
  13215. namespace Composer\Downloader;
  13216. use Composer\Package\Archiver\ArchivableFilesFinder;
  13217. use Composer\Package\Dumper\ArrayDumper;
  13218. use Composer\Package\PackageInterface;
  13219. use Composer\Package\Version\VersionGuesser;
  13220. use Composer\Package\Version\VersionParser;
  13221. use Composer\Util\Platform;
  13222. use Composer\IO\IOInterface;
  13223. use Composer\Config;
  13224. use Composer\Cache;
  13225. use Composer\Util\HttpDownloader;
  13226. use Composer\Util\ProcessExecutor;
  13227. use Composer\Util\Filesystem;
  13228. use Composer\EventDispatcher\EventDispatcher;
  13229. use Symfony\Component\Filesystem\Exception\IOException;
  13230. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  13231. use Composer\DependencyResolver\Operation\UpdateOperation;
  13232. use Composer\DependencyResolver\Operation\InstallOperation;
  13233. use Composer\DependencyResolver\Operation\UninstallOperation;
  13234. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  13235. {
  13236. const STRATEGY_SYMLINK = 10;
  13237. const STRATEGY_MIRROR = 20;
  13238. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13239. {
  13240. $path = Filesystem::trimTrailingSlash($path);
  13241. $url = $package->getDistUrl();
  13242. $realUrl = realpath($url);
  13243. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  13244. throw new \RuntimeException(sprintf(
  13245. 'Source path "%s" is not found for package %s',
  13246. $url,
  13247. $package->getName()
  13248. ));
  13249. }
  13250. if (realpath($path) === $realUrl) {
  13251. return;
  13252. }
  13253. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  13254. throw new \RuntimeException(sprintf(
  13255. 'Package %s cannot install to "%s" inside its source at "%s"',
  13256. $package->getName(),
  13257. realpath($path),
  13258. $realUrl
  13259. ));
  13260. }
  13261. }
  13262. public function install(PackageInterface $package, $path, $output = true)
  13263. {
  13264. $path = Filesystem::trimTrailingSlash($path);
  13265. $url = $package->getDistUrl();
  13266. $realUrl = realpath($url);
  13267. if (realpath($path) === $realUrl) {
  13268. if ($output) {
  13269. $this->io->writeError(" - " . InstallOperation::format($package).': Source already present');
  13270. } else {
  13271. $this->io->writeError('Source already present', false);
  13272. }
  13273. return;
  13274. }
  13275. $transportOptions = $package->getTransportOptions() + array('symlink' => null, 'relative' => true);
  13276. $currentStrategy = self::STRATEGY_SYMLINK;
  13277. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  13278. $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS');
  13279. if ($mirrorPathRepos) {
  13280. $currentStrategy = self::STRATEGY_MIRROR;
  13281. }
  13282. if (true === $transportOptions['symlink']) {
  13283. $currentStrategy = self::STRATEGY_SYMLINK;
  13284. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  13285. } elseif (false === $transportOptions['symlink']) {
  13286. $currentStrategy = self::STRATEGY_MIRROR;
  13287. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13288. }
  13289. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  13290. $currentStrategy = self::STRATEGY_MIRROR;
  13291. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13292. }
  13293. $symfonyFilesystem = new SymfonyFilesystem();
  13294. $this->filesystem->removeDirectory($path);
  13295. if ($output) {
  13296. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13297. }
  13298. $isFallback = false;
  13299. if (self::STRATEGY_SYMLINK == $currentStrategy) {
  13300. try {
  13301. if (Platform::isWindows()) {
  13302. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  13303. $this->filesystem->junction($realUrl, $path);
  13304. } else {
  13305. $absolutePath = $path;
  13306. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  13307. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  13308. }
  13309. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  13310. $path = rtrim($path, "/");
  13311. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  13312. if ($transportOptions['relative']) {
  13313. $symfonyFilesystem->symlink($shortestPath, $path);
  13314. } else {
  13315. $symfonyFilesystem->symlink($realUrl, $path);
  13316. }
  13317. }
  13318. } catch (IOException $e) {
  13319. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
  13320. $this->io->writeError('');
  13321. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  13322. $currentStrategy = self::STRATEGY_MIRROR;
  13323. $isFallback = true;
  13324. } else {
  13325. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  13326. }
  13327. }
  13328. }
  13329. if (self::STRATEGY_MIRROR == $currentStrategy) {
  13330. $realUrl = $this->filesystem->normalizePath($realUrl);
  13331. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  13332. $iterator = new ArchivableFilesFinder($realUrl, array());
  13333. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  13334. }
  13335. if ($output) {
  13336. $this->io->writeError('');
  13337. }
  13338. }
  13339. public function remove(PackageInterface $package, $path, $output = true)
  13340. {
  13341. $path = Filesystem::trimTrailingSlash($path);
  13342. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  13343. if ($output) {
  13344. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13345. }
  13346. if (!$this->filesystem->removeJunction($path)) {
  13347. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  13348. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  13349. }
  13350. } elseif (realpath($path) === realpath($package->getDistUrl())) {
  13351. if ($output) {
  13352. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13353. }
  13354. } else {
  13355. parent::remove($package, $path, $output);
  13356. }
  13357. }
  13358. public function getVcsReference(PackageInterface $package, $path)
  13359. {
  13360. $path = Filesystem::trimTrailingSlash($path);
  13361. $parser = new VersionParser;
  13362. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13363. $dumper = new ArrayDumper;
  13364. $packageConfig = $dumper->dump($package);
  13365. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13366. return $packageVersion['commit'];
  13367. }
  13368. }
  13369. private function safeJunctions()
  13370. {
  13371. return function_exists('proc_open') &&
  13372. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  13373. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  13374. }
  13375. }
  13376. <?php
  13377. namespace Composer\Downloader;
  13378. use Composer\Package\PackageInterface;
  13379. use Composer\Repository\VcsRepository;
  13380. use Composer\Util\Perforce;
  13381. class PerforceDownloader extends VcsDownloader
  13382. {
  13383. protected $perforce;
  13384. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13385. {
  13386. }
  13387. public function doInstall(PackageInterface $package, $path, $url)
  13388. {
  13389. $ref = $package->getSourceReference();
  13390. $label = $this->getLabelFromSourceReference($ref);
  13391. $this->io->writeError('Cloning ' . $ref);
  13392. $this->initPerforce($package, $path, $url);
  13393. $this->perforce->setStream($ref);
  13394. $this->perforce->p4Login();
  13395. $this->perforce->writeP4ClientSpec();
  13396. $this->perforce->connectClient();
  13397. $this->perforce->syncCodeBase($label);
  13398. $this->perforce->cleanupClientSpec();
  13399. }
  13400. private function getLabelFromSourceReference($ref)
  13401. {
  13402. $pos = strpos($ref, '@');
  13403. if (false !== $pos) {
  13404. return substr($ref, $pos + 1);
  13405. }
  13406. return null;
  13407. }
  13408. public function initPerforce(PackageInterface $package, $path, $url)
  13409. {
  13410. if (!empty($this->perforce)) {
  13411. $this->perforce->initializePath($path);
  13412. return;
  13413. }
  13414. $repository = $package->getRepository();
  13415. $repoConfig = null;
  13416. if ($repository instanceof VcsRepository) {
  13417. $repoConfig = $this->getRepoConfig($repository);
  13418. }
  13419. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  13420. }
  13421. private function getRepoConfig(VcsRepository $repository)
  13422. {
  13423. return $repository->getRepoConfig();
  13424. }
  13425. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13426. {
  13427. $this->doInstall($target, $path, $url);
  13428. }
  13429. public function getLocalChanges(PackageInterface $package, $path)
  13430. {
  13431. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  13432. }
  13433. protected function getCommitLogs($fromReference, $toReference, $path)
  13434. {
  13435. return $this->perforce->getCommitLogs($fromReference, $toReference);
  13436. }
  13437. public function setPerforce($perforce)
  13438. {
  13439. $this->perforce = $perforce;
  13440. }
  13441. protected function hasMetadataRepository($path)
  13442. {
  13443. return true;
  13444. }
  13445. }
  13446. <?php
  13447. namespace Composer\Downloader;
  13448. use Composer\Package\PackageInterface;
  13449. class PharDownloader extends ArchiveDownloader
  13450. {
  13451. protected function extract(PackageInterface $package, $file, $path)
  13452. {
  13453. $archive = new \Phar($file);
  13454. $archive->extractTo($path, null, true);
  13455. }
  13456. }
  13457. <?php
  13458. namespace Composer\Downloader;
  13459. use Composer\Config;
  13460. use Composer\Cache;
  13461. use Composer\EventDispatcher\EventDispatcher;
  13462. use Composer\Util\IniHelper;
  13463. use Composer\Util\Platform;
  13464. use Composer\Util\ProcessExecutor;
  13465. use Composer\Util\HttpDownloader;
  13466. use Composer\Util\Filesystem;
  13467. use Composer\IO\IOInterface;
  13468. use Composer\Package\PackageInterface;
  13469. use RarArchive;
  13470. class RarDownloader extends ArchiveDownloader
  13471. {
  13472. protected function extract(PackageInterface $package, $file, $path)
  13473. {
  13474. $processError = null;
  13475. if (!Platform::isWindows()) {
  13476. $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  13477. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13478. return;
  13479. }
  13480. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13481. }
  13482. if (!class_exists('RarArchive')) {
  13483. $iniMessage = IniHelper::getMessage();
  13484. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  13485. . $iniMessage . "\n" . $processError;
  13486. if (!Platform::isWindows()) {
  13487. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  13488. }
  13489. throw new \RuntimeException($error);
  13490. }
  13491. $rarArchive = RarArchive::open($file);
  13492. if (false === $rarArchive) {
  13493. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  13494. }
  13495. $entries = $rarArchive->getEntries();
  13496. if (false === $entries) {
  13497. throw new \RuntimeException('Could not retrieve RAR archive entries');
  13498. }
  13499. foreach ($entries as $entry) {
  13500. if (false === $entry->extract($path)) {
  13501. throw new \RuntimeException('Could not extract entry');
  13502. }
  13503. }
  13504. $rarArchive->close();
  13505. }
  13506. }
  13507. <?php
  13508. namespace Composer\Downloader;
  13509. use Composer\Package\PackageInterface;
  13510. use Composer\Util\Svn as SvnUtil;
  13511. use Composer\Repository\VcsRepository;
  13512. use Composer\Util\ProcessExecutor;
  13513. class SvnDownloader extends VcsDownloader
  13514. {
  13515. protected $cacheCredentials = true;
  13516. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13517. {
  13518. }
  13519. protected function doInstall(PackageInterface $package, $path, $url)
  13520. {
  13521. SvnUtil::cleanEnv();
  13522. $ref = $package->getSourceReference();
  13523. $repo = $package->getRepository();
  13524. if ($repo instanceof VcsRepository) {
  13525. $repoConfig = $repo->getRepoConfig();
  13526. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  13527. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  13528. }
  13529. }
  13530. $this->io->writeError(" Checking out ".$package->getSourceReference());
  13531. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  13532. }
  13533. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13534. {
  13535. SvnUtil::cleanEnv();
  13536. $ref = $target->getSourceReference();
  13537. if (!$this->hasMetadataRepository($path)) {
  13538. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13539. }
  13540. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  13541. $flags = "";
  13542. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  13543. $flags .= ' --ignore-ancestry';
  13544. }
  13545. $this->io->writeError(" Checking out " . $ref);
  13546. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  13547. }
  13548. public function getLocalChanges(PackageInterface $package, $path)
  13549. {
  13550. if (!$this->hasMetadataRepository($path)) {
  13551. return null;
  13552. }
  13553. $this->process->execute('svn status --ignore-externals', $output, $path);
  13554. return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
  13555. }
  13556. protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
  13557. {
  13558. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13559. $util->setCacheCredentials($this->cacheCredentials);
  13560. try {
  13561. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  13562. } catch (\RuntimeException $e) {
  13563. throw new \RuntimeException(
  13564. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  13565. );
  13566. }
  13567. }
  13568. protected function cleanChanges(PackageInterface $package, $path, $update)
  13569. {
  13570. if (!$changes = $this->getLocalChanges($package, $path)) {
  13571. return;
  13572. }
  13573. if (!$this->io->isInteractive()) {
  13574. if (true === $this->config->get('discard-changes')) {
  13575. return $this->discardChanges($path);
  13576. }
  13577. return parent::cleanChanges($package, $path, $update);
  13578. }
  13579. $changes = array_map(function ($elem) {
  13580. return ' '.$elem;
  13581. }, preg_split('{\s*\r?\n\s*}', $changes));
  13582. $countChanges = count($changes);
  13583. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  13584. $this->io->writeError(array_slice($changes, 0, 10));
  13585. if ($countChanges > 10) {
  13586. $remainingChanges = $countChanges - 10;
  13587. $this->io->writeError(
  13588. sprintf(
  13589. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  13590. $remainingChanges === 1 ? '' : 's'
  13591. )
  13592. );
  13593. }
  13594. while (true) {
  13595. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  13596. case 'y':
  13597. $this->discardChanges($path);
  13598. break 2;
  13599. case 'n':
  13600. throw new \RuntimeException('Update aborted');
  13601. case 'v':
  13602. $this->io->writeError($changes);
  13603. break;
  13604. case '?':
  13605. default:
  13606. $this->io->writeError(array(
  13607. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13608. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13609. ' v - view modified files',
  13610. ' ? - print help',
  13611. ));
  13612. break;
  13613. }
  13614. }
  13615. }
  13616. protected function getCommitLogs($fromReference, $toReference, $path)
  13617. {
  13618. if (preg_match('{@(\d+)$}', $fromReference) && preg_match('{@(\d+)$}', $toReference)) {
  13619. $command = sprintf('svn info --non-interactive --xml %s', ProcessExecutor::escape($path));
  13620. if (0 !== $this->process->execute($command, $output, $path)) {
  13621. throw new \RuntimeException(
  13622. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  13623. );
  13624. }
  13625. $urlPattern = '#<url>(.*)</url>#';
  13626. if (preg_match($urlPattern, $output, $matches)) {
  13627. $baseUrl = $matches[1];
  13628. } else {
  13629. throw new \RuntimeException(
  13630. 'Unable to determine svn url for path '. $path
  13631. );
  13632. }
  13633. $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
  13634. $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
  13635. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  13636. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13637. $util->setCacheCredentials($this->cacheCredentials);
  13638. try {
  13639. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  13640. } catch (\RuntimeException $e) {
  13641. throw new \RuntimeException(
  13642. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  13643. );
  13644. }
  13645. }
  13646. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  13647. }
  13648. protected function discardChanges($path)
  13649. {
  13650. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  13651. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  13652. }
  13653. }
  13654. protected function hasMetadataRepository($path)
  13655. {
  13656. return is_dir($path.'/.svn');
  13657. }
  13658. }
  13659. <?php
  13660. namespace Composer\Downloader;
  13661. use Composer\Package\PackageInterface;
  13662. class TarDownloader extends ArchiveDownloader
  13663. {
  13664. protected function extract(PackageInterface $package, $file, $path)
  13665. {
  13666. $archive = new \PharData($file);
  13667. $archive->extractTo($path, null, true);
  13668. }
  13669. }
  13670. <?php
  13671. namespace Composer\Downloader;
  13672. class TransportException extends \RuntimeException
  13673. {
  13674. protected $headers;
  13675. protected $response;
  13676. protected $statusCode;
  13677. public function setHeaders($headers)
  13678. {
  13679. $this->headers = $headers;
  13680. }
  13681. public function getHeaders()
  13682. {
  13683. return $this->headers;
  13684. }
  13685. public function setResponse($response)
  13686. {
  13687. $this->response = $response;
  13688. }
  13689. public function getResponse()
  13690. {
  13691. return $this->response;
  13692. }
  13693. public function setStatusCode($statusCode)
  13694. {
  13695. $this->statusCode = $statusCode;
  13696. }
  13697. public function getStatusCode()
  13698. {
  13699. return $this->statusCode;
  13700. }
  13701. }
  13702. <?php
  13703. namespace Composer\Downloader;
  13704. use Composer\Package\PackageInterface;
  13705. interface VcsCapableDownloaderInterface
  13706. {
  13707. public function getVcsReference(PackageInterface $package, $path);
  13708. }
  13709. <?php
  13710. namespace Composer\Downloader;
  13711. use Composer\Config;
  13712. use Composer\Package\Dumper\ArrayDumper;
  13713. use Composer\Package\PackageInterface;
  13714. use Composer\Package\Version\VersionGuesser;
  13715. use Composer\Package\Version\VersionParser;
  13716. use Composer\Util\ProcessExecutor;
  13717. use Composer\IO\IOInterface;
  13718. use Composer\Util\Filesystem;
  13719. use React\Promise\PromiseInterface;
  13720. use Composer\DependencyResolver\Operation\UpdateOperation;
  13721. use Composer\DependencyResolver\Operation\InstallOperation;
  13722. use Composer\DependencyResolver\Operation\UninstallOperation;
  13723. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  13724. {
  13725. protected $io;
  13726. protected $config;
  13727. protected $process;
  13728. protected $filesystem;
  13729. protected $hasCleanedChanges = array();
  13730. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  13731. {
  13732. $this->io = $io;
  13733. $this->config = $config;
  13734. $this->process = $process ?: new ProcessExecutor($io);
  13735. $this->filesystem = $fs ?: new Filesystem($this->process);
  13736. }
  13737. public function getInstallationSource()
  13738. {
  13739. return 'source';
  13740. }
  13741. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13742. {
  13743. if (!$package->getSourceReference()) {
  13744. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13745. }
  13746. $urls = $this->prepareUrls($package->getSourceUrls());
  13747. while ($url = array_shift($urls)) {
  13748. try {
  13749. return $this->doDownload($package, $path, $url, $prevPackage);
  13750. } catch (\Exception $e) {
  13751. if ($e instanceof \PHPUnit\Framework\Exception) {
  13752. throw $e;
  13753. }
  13754. if ($this->io->isDebug()) {
  13755. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13756. } elseif (count($urls)) {
  13757. $this->io->writeError(' Failed, trying the next URL');
  13758. }
  13759. if (!count($urls)) {
  13760. throw $e;
  13761. }
  13762. }
  13763. }
  13764. }
  13765. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13766. {
  13767. if ($type === 'update') {
  13768. $this->cleanChanges($prevPackage, $path, true);
  13769. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  13770. } elseif ($type === 'install') {
  13771. $this->filesystem->emptyDirectory($path);
  13772. } elseif ($type === 'uninstall') {
  13773. $this->cleanChanges($package, $path, false);
  13774. }
  13775. }
  13776. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13777. {
  13778. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  13779. $this->reapplyChanges($path);
  13780. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  13781. }
  13782. }
  13783. public function install(PackageInterface $package, $path)
  13784. {
  13785. if (!$package->getSourceReference()) {
  13786. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13787. }
  13788. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13789. $urls = $this->prepareUrls($package->getSourceUrls());
  13790. while ($url = array_shift($urls)) {
  13791. try {
  13792. $this->doInstall($package, $path, $url);
  13793. break;
  13794. } catch (\Exception $e) {
  13795. if ($e instanceof \PHPUnit\Framework\Exception) {
  13796. throw $e;
  13797. }
  13798. if ($this->io->isDebug()) {
  13799. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13800. } elseif (count($urls)) {
  13801. $this->io->writeError(' Failed, trying the next URL');
  13802. }
  13803. if (!count($urls)) {
  13804. throw $e;
  13805. }
  13806. }
  13807. }
  13808. }
  13809. public function update(PackageInterface $initial, PackageInterface $target, $path)
  13810. {
  13811. if (!$target->getSourceReference()) {
  13812. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  13813. }
  13814. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  13815. $urls = $this->prepareUrls($target->getSourceUrls());
  13816. $exception = null;
  13817. while ($url = array_shift($urls)) {
  13818. try {
  13819. $this->doUpdate($initial, $target, $path, $url);
  13820. $exception = null;
  13821. break;
  13822. } catch (\Exception $exception) {
  13823. if ($exception instanceof \PHPUnit\Framework\Exception) {
  13824. throw $exception;
  13825. }
  13826. if ($this->io->isDebug()) {
  13827. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  13828. } elseif (count($urls)) {
  13829. $this->io->writeError(' Failed, trying the next URL');
  13830. }
  13831. }
  13832. }
  13833. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  13834. $message = 'Pulling in changes:';
  13835. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  13836. if (!trim($logs)) {
  13837. $message = 'Rolling back changes:';
  13838. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  13839. }
  13840. if (trim($logs)) {
  13841. $logs = implode("\n", array_map(function ($line) {
  13842. return ' ' . $line;
  13843. }, explode("\n", $logs)));
  13844. $logs = str_replace('<', '\<', $logs);
  13845. $this->io->writeError(' '.$message);
  13846. $this->io->writeError($logs);
  13847. }
  13848. }
  13849. if (!$urls && $exception) {
  13850. throw $exception;
  13851. }
  13852. }
  13853. public function remove(PackageInterface $package, $path)
  13854. {
  13855. $this->io->writeError(" - " . UninstallOperation::format($package));
  13856. if (!$this->filesystem->removeDirectory($path)) {
  13857. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  13858. }
  13859. }
  13860. public function getVcsReference(PackageInterface $package, $path)
  13861. {
  13862. $parser = new VersionParser;
  13863. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13864. $dumper = new ArrayDumper;
  13865. $packageConfig = $dumper->dump($package);
  13866. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13867. return $packageVersion['commit'];
  13868. }
  13869. }
  13870. protected function cleanChanges(PackageInterface $package, $path, $update)
  13871. {
  13872. if (null !== $this->getLocalChanges($package, $path)) {
  13873. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  13874. }
  13875. }
  13876. protected function reapplyChanges($path)
  13877. {
  13878. }
  13879. abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
  13880. abstract protected function doInstall(PackageInterface $package, $path, $url);
  13881. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  13882. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  13883. abstract protected function hasMetadataRepository($path);
  13884. private function prepareUrls(array $urls)
  13885. {
  13886. foreach ($urls as $index => $url) {
  13887. if (Filesystem::isLocalPath($url)) {
  13888. $fileProtocol = 'file://';
  13889. $isFileProtocol = false;
  13890. if (0 === strpos($url, $fileProtocol)) {
  13891. $url = substr($url, strlen($fileProtocol));
  13892. $isFileProtocol = true;
  13893. }
  13894. if (false !== strpos($url, '%')) {
  13895. $url = rawurldecode($url);
  13896. }
  13897. $urls[$index] = realpath($url);
  13898. if ($isFileProtocol) {
  13899. $urls[$index] = $fileProtocol . $urls[$index];
  13900. }
  13901. }
  13902. }
  13903. return $urls;
  13904. }
  13905. }
  13906. <?php
  13907. namespace Composer\Downloader;
  13908. use Composer\Config;
  13909. use Composer\Cache;
  13910. use Composer\EventDispatcher\EventDispatcher;
  13911. use Composer\Package\PackageInterface;
  13912. use Composer\Util\ProcessExecutor;
  13913. use Composer\Util\HttpDownloader;
  13914. use Composer\IO\IOInterface;
  13915. use Composer\Util\Filesystem;
  13916. class XzDownloader extends ArchiveDownloader
  13917. {
  13918. protected function extract(PackageInterface $package, $file, $path)
  13919. {
  13920. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  13921. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13922. return;
  13923. }
  13924. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13925. throw new \RuntimeException($processError);
  13926. }
  13927. }
  13928. <?php
  13929. namespace Composer\Downloader;
  13930. use Composer\Config;
  13931. use Composer\Cache;
  13932. use Composer\EventDispatcher\EventDispatcher;
  13933. use Composer\Package\PackageInterface;
  13934. use Composer\Util\IniHelper;
  13935. use Composer\Util\Platform;
  13936. use Composer\Util\ProcessExecutor;
  13937. use Composer\Util\Filesystem;
  13938. use Composer\Util\HttpDownloader;
  13939. use Composer\IO\IOInterface;
  13940. use Symfony\Component\Process\ExecutableFinder;
  13941. use ZipArchive;
  13942. class ZipDownloader extends ArchiveDownloader
  13943. {
  13944. protected static $hasSystemUnzip;
  13945. private static $hasZipArchive;
  13946. private static $isWindows;
  13947. private $zipArchiveObject;
  13948. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13949. {
  13950. if (null === self::$hasSystemUnzip) {
  13951. $finder = new ExecutableFinder;
  13952. self::$hasSystemUnzip = (bool) $finder->find('unzip');
  13953. }
  13954. if (null === self::$hasZipArchive) {
  13955. self::$hasZipArchive = class_exists('ZipArchive');
  13956. }
  13957. if (!self::$hasZipArchive && !self::$hasSystemUnzip) {
  13958. $iniMessage = IniHelper::getMessage();
  13959. $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
  13960. throw new \RuntimeException($error);
  13961. }
  13962. if (null === self::$isWindows) {
  13963. self::$isWindows = Platform::isWindows();
  13964. if (!self::$isWindows && !self::$hasSystemUnzip) {
  13965. $this->io->writeError("<warning>As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  13966. $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>");
  13967. $this->io->writeError("<warning>Installing 'unzip' may remediate them.</warning>");
  13968. }
  13969. }
  13970. return parent::download($package, $path, $prevPackage, $output);
  13971. }
  13972. private function extractWithSystemUnzip(PackageInterface $package, $file, $path, $isLastChance, $async = false)
  13973. {
  13974. if (!self::$hasZipArchive) {
  13975. $isLastChance = true;
  13976. }
  13977. if (!self::$hasSystemUnzip && !$isLastChance) {
  13978. return $this->extractWithZipArchive($package, $file, $path, true);
  13979. }
  13980. $overwrite = $isLastChance ? '-o' : '';
  13981. $command = 'unzip -qq '.$overwrite.' '.ProcessExecutor::escape($file).' -d '.ProcessExecutor::escape($path);
  13982. if ($async) {
  13983. $self = $this;
  13984. $io = $this->io;
  13985. $tryFallback = function ($processError) use ($isLastChance, $io, $self, $file, $path, $package) {
  13986. if ($isLastChance) {
  13987. throw $processError;
  13988. }
  13989. if (!is_file($file)) {
  13990. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  13991. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  13992. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  13993. } else {
  13994. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  13995. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  13996. $io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  13997. }
  13998. return $self->extractWithZipArchive($package, $file, $path, true);
  13999. };
  14000. try {
  14001. $promise = $this->process->executeAsync($command);
  14002. return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) {
  14003. if (!$process->isSuccessful()) {
  14004. $output = $process->getErrorOutput();
  14005. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  14006. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  14007. }
  14008. });
  14009. } catch (\Exception $e) {
  14010. return $tryFallback($e);
  14011. } catch (\Throwable $e) {
  14012. return $tryFallback($e);
  14013. }
  14014. }
  14015. $processError = null;
  14016. try {
  14017. if (0 === $exitCode = $this->process->execute($command, $ignoredOutput)) {
  14018. return \React\Promise\resolve();
  14019. }
  14020. $processError = new \RuntimeException('Failed to execute ('.$exitCode.') '.$command."\n\n".$this->process->getErrorOutput());
  14021. } catch (\Exception $e) {
  14022. $processError = $e;
  14023. }
  14024. if ($isLastChance) {
  14025. throw $processError;
  14026. }
  14027. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14028. $this->io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  14029. $this->io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  14030. return $this->extractWithZipArchive($package, $file, $path, true);
  14031. }
  14032. public function extractWithZipArchive(PackageInterface $package, $file, $path, $isLastChance)
  14033. {
  14034. if (!self::$hasSystemUnzip) {
  14035. $isLastChance = true;
  14036. }
  14037. if (!self::$hasZipArchive && !$isLastChance) {
  14038. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14039. }
  14040. $processError = null;
  14041. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  14042. try {
  14043. if (true === ($retval = $zipArchive->open($file))) {
  14044. $extractResult = $zipArchive->extractTo($path);
  14045. if (true === $extractResult) {
  14046. $zipArchive->close();
  14047. return \React\Promise\resolve();
  14048. }
  14049. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  14050. } else {
  14051. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  14052. }
  14053. } catch (\ErrorException $e) {
  14054. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  14055. } catch (\Exception $e) {
  14056. $processError = $e;
  14057. } catch (\Throwable $e) {
  14058. $processError = $e;
  14059. }
  14060. if ($isLastChance) {
  14061. throw $processError;
  14062. }
  14063. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14064. $this->io->writeError(' Unzip with ZipArchive class failed, falling back to unzip command');
  14065. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14066. }
  14067. public function extract(PackageInterface $package, $file, $path)
  14068. {
  14069. if (self::$isWindows) {
  14070. return $this->extractWithZipArchive($package, $file, $path, false);
  14071. }
  14072. return $this->extractWithSystemUnzip($package, $file, $path, false, true);
  14073. }
  14074. protected function getErrorMessage($retval, $file)
  14075. {
  14076. switch ($retval) {
  14077. case ZipArchive::ER_EXISTS:
  14078. return sprintf("File '%s' already exists.", $file);
  14079. case ZipArchive::ER_INCONS:
  14080. return sprintf("Zip archive '%s' is inconsistent.", $file);
  14081. case ZipArchive::ER_INVAL:
  14082. return sprintf("Invalid argument (%s)", $file);
  14083. case ZipArchive::ER_MEMORY:
  14084. return sprintf("Malloc failure (%s)", $file);
  14085. case ZipArchive::ER_NOENT:
  14086. return sprintf("No such zip file: '%s'", $file);
  14087. case ZipArchive::ER_NOZIP:
  14088. return sprintf("'%s' is not a zip archive.", $file);
  14089. case ZipArchive::ER_OPEN:
  14090. return sprintf("Can't open zip file: %s", $file);
  14091. case ZipArchive::ER_READ:
  14092. return sprintf("Zip read error (%s)", $file);
  14093. case ZipArchive::ER_SEEK:
  14094. return sprintf("Zip seek error (%s)", $file);
  14095. default:
  14096. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  14097. }
  14098. }
  14099. }
  14100. <?php
  14101. namespace Composer\EventDispatcher;
  14102. class Event
  14103. {
  14104. protected $name;
  14105. protected $args;
  14106. protected $flags;
  14107. private $propagationStopped = false;
  14108. public function __construct($name, array $args = array(), array $flags = array())
  14109. {
  14110. $this->name = $name;
  14111. $this->args = $args;
  14112. $this->flags = $flags;
  14113. }
  14114. public function getName()
  14115. {
  14116. return $this->name;
  14117. }
  14118. public function getArguments()
  14119. {
  14120. return $this->args;
  14121. }
  14122. public function getFlags()
  14123. {
  14124. return $this->flags;
  14125. }
  14126. public function isPropagationStopped()
  14127. {
  14128. return $this->propagationStopped;
  14129. }
  14130. public function stopPropagation()
  14131. {
  14132. $this->propagationStopped = true;
  14133. }
  14134. }
  14135. <?php
  14136. namespace Composer\EventDispatcher;
  14137. use Composer\DependencyResolver\Transaction;
  14138. use Composer\Installer\InstallerEvent;
  14139. use Composer\IO\IOInterface;
  14140. use Composer\Composer;
  14141. use Composer\DependencyResolver\Operation\OperationInterface;
  14142. use Composer\Repository\RepositoryInterface;
  14143. use Composer\Script;
  14144. use Composer\Installer\PackageEvent;
  14145. use Composer\Installer\BinaryInstaller;
  14146. use Composer\Util\ProcessExecutor;
  14147. use Composer\Script\Event as ScriptEvent;
  14148. use Composer\ClassLoader;
  14149. use Symfony\Component\Process\PhpExecutableFinder;
  14150. class EventDispatcher
  14151. {
  14152. protected $composer;
  14153. protected $io;
  14154. protected $loader;
  14155. protected $process;
  14156. protected $listeners = array();
  14157. private $eventStack;
  14158. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14159. {
  14160. $this->composer = $composer;
  14161. $this->io = $io;
  14162. $this->process = $process ?: new ProcessExecutor($io);
  14163. $this->eventStack = array();
  14164. }
  14165. public function dispatch($eventName, Event $event = null)
  14166. {
  14167. if (null === $event) {
  14168. $event = new Event($eventName);
  14169. }
  14170. return $this->doDispatch($event);
  14171. }
  14172. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  14173. {
  14174. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  14175. }
  14176. public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  14177. {
  14178. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  14179. }
  14180. public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
  14181. {
  14182. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  14183. }
  14184. protected function doDispatch(Event $event)
  14185. {
  14186. if (getenv('COMPOSER_DEBUG_EVENTS')) {
  14187. $details = null;
  14188. if ($event instanceof PackageEvent) {
  14189. $details = (string) $event->getOperation();
  14190. }
  14191. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  14192. }
  14193. $listeners = $this->getListeners($event);
  14194. $this->pushEvent($event);
  14195. $return = 0;
  14196. foreach ($listeners as $callable) {
  14197. $this->ensureBinDirIsInPath();
  14198. if (!is_string($callable)) {
  14199. if (!is_callable($callable)) {
  14200. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  14201. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  14202. }
  14203. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  14204. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1] ), true, IOInterface::VERBOSE);
  14205. }
  14206. $return = false === call_user_func($callable, $event) ? 1 : 0;
  14207. } elseif ($this->isComposerScript($callable)) {
  14208. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  14209. $script = explode(' ', substr($callable, 1));
  14210. $scriptName = $script[0];
  14211. unset($script[0]);
  14212. $args = array_merge($script, $event->getArguments());
  14213. $flags = $event->getFlags();
  14214. if (strpos($callable, '@composer ') === 0) {
  14215. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  14216. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14217. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14218. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14219. }
  14220. } else {
  14221. if (!$this->getListeners(new Event($scriptName))) {
  14222. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  14223. }
  14224. try {
  14225. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  14226. $scriptEvent->setOriginatingEvent($event);
  14227. $return = $this->dispatch($scriptName, $scriptEvent);
  14228. } catch (ScriptExecutionException $e) {
  14229. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14230. throw $e;
  14231. }
  14232. }
  14233. } elseif ($this->isPhpScript($callable)) {
  14234. $className = substr($callable, 0, strpos($callable, '::'));
  14235. $methodName = substr($callable, strpos($callable, '::') + 2);
  14236. if (!class_exists($className)) {
  14237. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14238. continue;
  14239. }
  14240. if (!is_callable($callable)) {
  14241. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14242. continue;
  14243. }
  14244. try {
  14245. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  14246. } catch (\Exception $e) {
  14247. $message = "Script %s handling the %s event terminated with an exception";
  14248. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  14249. throw $e;
  14250. }
  14251. } else {
  14252. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  14253. $exec = $callable . ($args === '' ? '' : ' '.$args);
  14254. if ($this->io->isVerbose()) {
  14255. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  14256. } else {
  14257. $this->io->writeError(sprintf('> %s', $exec));
  14258. }
  14259. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  14260. if ($possibleLocalBinaries) {
  14261. foreach ($possibleLocalBinaries as $localExec) {
  14262. if (preg_match('{\b'.preg_quote($callable).'$}', $localExec)) {
  14263. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  14264. $exec = preg_replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  14265. break;
  14266. }
  14267. }
  14268. }
  14269. if (strpos($exec, '@putenv ') === 0) {
  14270. putenv(substr($exec, 8));
  14271. continue;
  14272. }
  14273. if (strpos($exec, '@php ') === 0) {
  14274. $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5);
  14275. } else {
  14276. $finder = new PhpExecutableFinder();
  14277. $phpPath = $finder->find(false);
  14278. if ($phpPath) {
  14279. $_SERVER['PHP_BINARY'] = $phpPath;
  14280. putenv('PHP_BINARY=' . $_SERVER['PHP_BINARY']);
  14281. }
  14282. }
  14283. if (strpos($exec, 'composer ') === 0) {
  14284. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8);
  14285. }
  14286. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14287. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14288. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14289. }
  14290. }
  14291. if ($event->isPropagationStopped()) {
  14292. break;
  14293. }
  14294. }
  14295. $this->popEvent();
  14296. return $return;
  14297. }
  14298. protected function executeTty($exec)
  14299. {
  14300. if ($this->io->isInteractive()) {
  14301. return $this->process->executeTty($exec);
  14302. }
  14303. return $this->process->execute($exec);
  14304. }
  14305. protected function getPhpExecCommand()
  14306. {
  14307. $finder = new PhpExecutableFinder();
  14308. $phpPath = $finder->find(false);
  14309. if (!$phpPath) {
  14310. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  14311. }
  14312. $phpArgs = $finder->findArguments();
  14313. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  14314. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  14315. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  14316. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  14317. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  14318. }
  14319. protected function executeEventPhpScript($className, $methodName, Event $event)
  14320. {
  14321. if ($this->io->isVerbose()) {
  14322. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  14323. } else {
  14324. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  14325. }
  14326. return $className::$methodName($event);
  14327. }
  14328. public function addListener($eventName, $listener, $priority = 0)
  14329. {
  14330. $this->listeners[$eventName][$priority][] = $listener;
  14331. }
  14332. public function removeListener($listener)
  14333. {
  14334. foreach ($this->listeners as $eventName => $priorities) {
  14335. foreach ($priorities as $priority => $listeners) {
  14336. foreach ($listeners as $index => $candidate) {
  14337. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  14338. unset($this->listeners[$eventName][$priority][$index]);
  14339. }
  14340. }
  14341. }
  14342. }
  14343. }
  14344. public function addSubscriber(EventSubscriberInterface $subscriber)
  14345. {
  14346. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  14347. if (is_string($params)) {
  14348. $this->addListener($eventName, array($subscriber, $params));
  14349. } elseif (is_string($params[0])) {
  14350. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  14351. } else {
  14352. foreach ($params as $listener) {
  14353. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  14354. }
  14355. }
  14356. }
  14357. }
  14358. protected function getListeners(Event $event)
  14359. {
  14360. $scriptListeners = $this->getScriptListeners($event);
  14361. if (!isset($this->listeners[$event->getName()][0])) {
  14362. $this->listeners[$event->getName()][0] = array();
  14363. }
  14364. krsort($this->listeners[$event->getName()]);
  14365. $listeners = $this->listeners;
  14366. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  14367. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  14368. }
  14369. public function hasEventListeners(Event $event)
  14370. {
  14371. $listeners = $this->getListeners($event);
  14372. return count($listeners) > 0;
  14373. }
  14374. protected function getScriptListeners(Event $event)
  14375. {
  14376. $package = $this->composer->getPackage();
  14377. $scripts = $package->getScripts();
  14378. if (empty($scripts[$event->getName()])) {
  14379. return array();
  14380. }
  14381. if ($this->loader) {
  14382. $this->loader->unregister();
  14383. }
  14384. $generator = $this->composer->getAutoloadGenerator();
  14385. if ($event instanceof ScriptEvent) {
  14386. $generator->setDevMode($event->isDevMode());
  14387. }
  14388. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  14389. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  14390. $map = $generator->parseAutoloads($packageMap, $package);
  14391. $this->loader = $generator->createLoader($map);
  14392. $this->loader->register();
  14393. return $scripts[$event->getName()];
  14394. }
  14395. protected function isPhpScript($callable)
  14396. {
  14397. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  14398. }
  14399. protected function isComposerScript($callable)
  14400. {
  14401. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  14402. }
  14403. protected function pushEvent(Event $event)
  14404. {
  14405. $eventName = $event->getName();
  14406. if (in_array($eventName, $this->eventStack)) {
  14407. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  14408. }
  14409. return array_push($this->eventStack, $eventName);
  14410. }
  14411. protected function popEvent()
  14412. {
  14413. return array_pop($this->eventStack);
  14414. }
  14415. private function ensureBinDirIsInPath()
  14416. {
  14417. $pathStr = 'PATH';
  14418. if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
  14419. $pathStr = 'Path';
  14420. }
  14421. $binDir = $this->composer->getConfig()->get('bin-dir');
  14422. if (is_dir($binDir)) {
  14423. $binDir = realpath($binDir);
  14424. if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) {
  14425. $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
  14426. putenv($pathStr.'='.$_SERVER[$pathStr]);
  14427. }
  14428. }
  14429. }
  14430. }
  14431. <?php
  14432. namespace Composer\EventDispatcher;
  14433. interface EventSubscriberInterface
  14434. {
  14435. public static function getSubscribedEvents();
  14436. }
  14437. <?php
  14438. namespace Composer\EventDispatcher;
  14439. class ScriptExecutionException extends \RuntimeException
  14440. {
  14441. }
  14442. <?php
  14443. namespace Composer\Exception;
  14444. class IrrecoverableDownloadException extends \RuntimeException
  14445. {
  14446. }
  14447. <?php
  14448. namespace Composer\Exception;
  14449. class NoSslException extends \RuntimeException
  14450. {
  14451. }
  14452. <?php
  14453. namespace Composer;
  14454. use Composer\Config\JsonConfigSource;
  14455. use Composer\Json\JsonFile;
  14456. use Composer\IO\IOInterface;
  14457. use Composer\Package\Archiver;
  14458. use Composer\Package\Version\VersionGuesser;
  14459. use Composer\Package\RootPackageInterface;
  14460. use Composer\Repository\RepositoryManager;
  14461. use Composer\Repository\RepositoryFactory;
  14462. use Composer\Repository\WritableRepositoryInterface;
  14463. use Composer\Util\Filesystem;
  14464. use Composer\Util\Platform;
  14465. use Composer\Util\ProcessExecutor;
  14466. use Composer\Util\HttpDownloader;
  14467. use Composer\Util\Loop;
  14468. use Composer\Util\Silencer;
  14469. use Composer\Plugin\PluginEvents;
  14470. use Composer\EventDispatcher\Event;
  14471. use Seld\JsonLint\DuplicateKeyException;
  14472. use Symfony\Component\Console\Formatter\OutputFormatter;
  14473. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  14474. use Symfony\Component\Console\Output\ConsoleOutput;
  14475. use Composer\EventDispatcher\EventDispatcher;
  14476. use Composer\Autoload\AutoloadGenerator;
  14477. use Composer\Package\Version\VersionParser;
  14478. use Composer\Downloader\TransportException;
  14479. use Seld\JsonLint\JsonParser;
  14480. class Factory
  14481. {
  14482. protected static function getHomeDir()
  14483. {
  14484. $home = getenv('COMPOSER_HOME');
  14485. if ($home) {
  14486. return $home;
  14487. }
  14488. if (Platform::isWindows()) {
  14489. if (!getenv('APPDATA')) {
  14490. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14491. }
  14492. return rtrim(strtr(getenv('APPDATA'), '\\', '/'), '/') . '/Composer';
  14493. }
  14494. $userDir = self::getUserDir();
  14495. $dirs = array();
  14496. if (self::useXdg()) {
  14497. $xdgConfig = getenv('XDG_CONFIG_HOME');
  14498. if (!$xdgConfig) {
  14499. $xdgConfig = $userDir . '/.config';
  14500. }
  14501. $dirs[] = $xdgConfig . '/composer';
  14502. }
  14503. $dirs[] = $userDir . '/.composer';
  14504. foreach ($dirs as $dir) {
  14505. if (is_dir($dir)) {
  14506. return $dir;
  14507. }
  14508. }
  14509. return $dirs[0];
  14510. }
  14511. protected static function getCacheDir($home)
  14512. {
  14513. $cacheDir = getenv('COMPOSER_CACHE_DIR');
  14514. if ($cacheDir) {
  14515. return $cacheDir;
  14516. }
  14517. $homeEnv = getenv('COMPOSER_HOME');
  14518. if ($homeEnv) {
  14519. return $homeEnv . '/cache';
  14520. }
  14521. if (Platform::isWindows()) {
  14522. if ($cacheDir = getenv('LOCALAPPDATA')) {
  14523. $cacheDir .= '/Composer';
  14524. } else {
  14525. $cacheDir = $home . '/cache';
  14526. }
  14527. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  14528. }
  14529. $userDir = self::getUserDir();
  14530. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  14531. return $home . '/cache';
  14532. }
  14533. if (self::useXdg()) {
  14534. $xdgCache = getenv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  14535. return $xdgCache . '/composer';
  14536. }
  14537. return $home . '/cache';
  14538. }
  14539. protected static function getDataDir($home)
  14540. {
  14541. $homeEnv = getenv('COMPOSER_HOME');
  14542. if ($homeEnv) {
  14543. return $homeEnv;
  14544. }
  14545. if (Platform::isWindows()) {
  14546. return strtr($home, '\\', '/');
  14547. }
  14548. $userDir = self::getUserDir();
  14549. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  14550. $xdgData = getenv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  14551. return $xdgData . '/composer';
  14552. }
  14553. return $home;
  14554. }
  14555. public static function createConfig(IOInterface $io = null, $cwd = null)
  14556. {
  14557. $cwd = $cwd ?: getcwd();
  14558. $config = new Config(true, $cwd);
  14559. $home = self::getHomeDir();
  14560. $config->merge(array('config' => array(
  14561. 'home' => $home,
  14562. 'cache-dir' => self::getCacheDir($home),
  14563. 'data-dir' => self::getDataDir($home),
  14564. )));
  14565. $file = new JsonFile($config->get('home').'/config.json');
  14566. if ($file->exists()) {
  14567. if ($io && $io->isDebug()) {
  14568. $io->writeError('Loading config file ' . $file->getPath());
  14569. }
  14570. $config->merge($file->read());
  14571. }
  14572. $config->setConfigSource(new JsonConfigSource($file));
  14573. $htaccessProtect = (bool) $config->get('htaccess-protect');
  14574. if ($htaccessProtect) {
  14575. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  14576. foreach ($dirs as $dir) {
  14577. if (!file_exists($dir . '/.htaccess')) {
  14578. if (!is_dir($dir)) {
  14579. Silencer::call('mkdir', $dir, 0777, true);
  14580. }
  14581. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  14582. }
  14583. }
  14584. }
  14585. $file = new JsonFile($config->get('home').'/auth.json');
  14586. if ($file->exists()) {
  14587. if ($io && $io->isDebug()) {
  14588. $io->writeError('Loading config file ' . $file->getPath());
  14589. }
  14590. $config->merge(array('config' => $file->read()));
  14591. }
  14592. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  14593. if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
  14594. $authData = json_decode($composerAuthEnv, true);
  14595. if (null === $authData) {
  14596. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  14597. }
  14598. if ($io && $io->isDebug()) {
  14599. $io->writeError('Loading auth config from COMPOSER_AUTH');
  14600. }
  14601. $config->merge(array('config' => $authData));
  14602. }
  14603. return $config;
  14604. }
  14605. public static function getComposerFile()
  14606. {
  14607. return trim(getenv('COMPOSER')) ?: './composer.json';
  14608. }
  14609. public static function getLockFile($composerFile)
  14610. {
  14611. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  14612. ? substr($composerFile, 0, -4).'lock'
  14613. : $composerFile . '.lock';
  14614. }
  14615. public static function createAdditionalStyles()
  14616. {
  14617. return array(
  14618. 'highlight' => new OutputFormatterStyle('red'),
  14619. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  14620. );
  14621. }
  14622. public static function createOutput()
  14623. {
  14624. $styles = self::createAdditionalStyles();
  14625. $formatter = new OutputFormatter(false, $styles);
  14626. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  14627. }
  14628. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
  14629. {
  14630. $cwd = $cwd ?: getcwd();
  14631. if (null === $localConfig) {
  14632. $localConfig = static::getComposerFile();
  14633. }
  14634. if (is_string($localConfig)) {
  14635. $composerFile = $localConfig;
  14636. $file = new JsonFile($localConfig, null, $io);
  14637. if (!$file->exists()) {
  14638. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  14639. $message = 'Composer could not find a composer.json file in '.$cwd;
  14640. } else {
  14641. $message = 'Composer could not find the config file: '.$localConfig;
  14642. }
  14643. $instructions = 'To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section';
  14644. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  14645. }
  14646. $file->validateSchema(JsonFile::LAX_SCHEMA);
  14647. $jsonParser = new JsonParser;
  14648. try {
  14649. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  14650. } catch (DuplicateKeyException $e) {
  14651. $details = $e->getDetails();
  14652. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  14653. }
  14654. $localConfig = $file->read();
  14655. }
  14656. $config = static::createConfig($io, $cwd);
  14657. $config->merge($localConfig);
  14658. if (isset($composerFile)) {
  14659. $io->writeError('Loading config file ' . $composerFile, true, IOInterface::DEBUG);
  14660. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  14661. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  14662. if ($localAuthFile->exists()) {
  14663. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  14664. $config->merge(array('config' => $localAuthFile->read()));
  14665. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  14666. }
  14667. }
  14668. $vendorDir = $config->get('vendor-dir');
  14669. $composer = new Composer();
  14670. $composer->setConfig($config);
  14671. if ($fullLoad) {
  14672. $io->loadConfiguration($config);
  14673. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  14674. include $installedVersionsPath;
  14675. }
  14676. }
  14677. $httpDownloader = self::createHttpDownloader($io, $config);
  14678. $process = new ProcessExecutor($io);
  14679. $loop = new Loop($httpDownloader, $process);
  14680. $composer->setLoop($loop);
  14681. $dispatcher = new EventDispatcher($composer, $io, $process);
  14682. $composer->setEventDispatcher($dispatcher);
  14683. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  14684. $composer->setRepositoryManager($rm);
  14685. if (!$fullLoad && !isset($localConfig['version'])) {
  14686. $localConfig['version'] = '1.0.0';
  14687. }
  14688. $parser = new VersionParser;
  14689. $guesser = new VersionGuesser($config, $process, $parser);
  14690. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  14691. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  14692. $composer->setPackage($package);
  14693. $this->addLocalRepository($io, $rm, $vendorDir, $package);
  14694. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  14695. $composer->setInstallationManager($im);
  14696. if ($fullLoad) {
  14697. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  14698. $composer->setDownloadManager($dm);
  14699. $generator = new AutoloadGenerator($dispatcher, $io);
  14700. $composer->setAutoloadGenerator($generator);
  14701. $am = $this->createArchiveManager($config, $dm, $loop);
  14702. $composer->setArchiveManager($am);
  14703. }
  14704. $this->createDefaultInstallers($im, $composer, $io, $process);
  14705. if ($fullLoad) {
  14706. $globalComposer = null;
  14707. if (realpath($config->get('home')) !== $cwd) {
  14708. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
  14709. }
  14710. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  14711. $composer->setPluginManager($pm);
  14712. $pm->loadInstalledPlugins();
  14713. }
  14714. if ($fullLoad && isset($composerFile)) {
  14715. $lockFile = self::getLockFile($composerFile);
  14716. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
  14717. $composer->setLocker($locker);
  14718. }
  14719. if ($fullLoad) {
  14720. $initEvent = new Event(PluginEvents::INIT);
  14721. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  14722. if ($rm->getLocalRepository()) {
  14723. $this->purgePackages($rm->getLocalRepository(), $im);
  14724. }
  14725. }
  14726. return $composer;
  14727. }
  14728. public static function createGlobal(IOInterface $io, $disablePlugins = false)
  14729. {
  14730. $factory = new static();
  14731. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, true);
  14732. }
  14733. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage)
  14734. {
  14735. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage));
  14736. }
  14737. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
  14738. {
  14739. $composer = null;
  14740. try {
  14741. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad);
  14742. } catch (\Exception $e) {
  14743. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  14744. }
  14745. return $composer;
  14746. }
  14747. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null)
  14748. {
  14749. $cache = null;
  14750. if ($config->get('cache-files-ttl') > 0) {
  14751. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  14752. $cache->setReadOnly($config->get('cache-read-only'));
  14753. }
  14754. $fs = new Filesystem($process);
  14755. $dm = new Downloader\DownloadManager($io, false, $fs);
  14756. switch ($preferred = $config->get('preferred-install')) {
  14757. case 'dist':
  14758. $dm->setPreferDist(true);
  14759. break;
  14760. case 'source':
  14761. $dm->setPreferSource(true);
  14762. break;
  14763. case 'auto':
  14764. default:
  14765. break;
  14766. }
  14767. if (is_array($preferred)) {
  14768. $dm->setPreferences($preferred);
  14769. }
  14770. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  14771. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  14772. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  14773. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  14774. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  14775. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14776. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14777. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14778. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14779. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14780. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14781. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14782. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14783. return $dm;
  14784. }
  14785. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  14786. {
  14787. $am = new Archiver\ArchiveManager($dm, $loop);
  14788. $am->addArchiver(new Archiver\ZipArchiver);
  14789. $am->addArchiver(new Archiver\PharArchiver);
  14790. return $am;
  14791. }
  14792. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  14793. {
  14794. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  14795. }
  14796. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  14797. {
  14798. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  14799. }
  14800. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14801. {
  14802. $fs = new Filesystem($process);
  14803. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs);
  14804. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  14805. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  14806. $im->addInstaller(new Installer\MetapackageInstaller($io));
  14807. }
  14808. protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
  14809. {
  14810. foreach ($repo->getPackages() as $package) {
  14811. if (!$im->isPackageInstalled($repo, $package)) {
  14812. $repo->removePackage($package);
  14813. }
  14814. }
  14815. }
  14816. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
  14817. {
  14818. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  14819. }
  14820. public static function create(IOInterface $io, $config = null, $disablePlugins = false)
  14821. {
  14822. $factory = new static();
  14823. return $factory->createComposer($io, $config, $disablePlugins);
  14824. }
  14825. public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())
  14826. {
  14827. static $warned = false;
  14828. $disableTls = false;
  14829. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  14830. $warned = true;
  14831. $disableTls = !extension_loaded('openssl');
  14832. } elseif ($config && $config->get('disable-tls') === true) {
  14833. if (!$warned) {
  14834. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  14835. }
  14836. $warned = true;
  14837. $disableTls = true;
  14838. } elseif (!extension_loaded('openssl')) {
  14839. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  14840. . '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.');
  14841. }
  14842. $httpDownloaderOptions = array();
  14843. if ($disableTls === false) {
  14844. if ($config && $config->get('cafile')) {
  14845. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  14846. }
  14847. if ($config && $config->get('capath')) {
  14848. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  14849. }
  14850. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  14851. }
  14852. try {
  14853. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  14854. } catch (TransportException $e) {
  14855. if (false !== strpos($e->getMessage(), 'cafile')) {
  14856. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  14857. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  14858. if (PHP_VERSION_ID < 50600) {
  14859. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  14860. }
  14861. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  14862. }
  14863. throw $e;
  14864. }
  14865. return $httpDownloader;
  14866. }
  14867. private static function useXdg()
  14868. {
  14869. foreach (array_keys($_SERVER) as $key) {
  14870. if (strpos($key, 'XDG_') === 0) {
  14871. return true;
  14872. }
  14873. }
  14874. if (is_dir('/etc/xdg')) {
  14875. return true;
  14876. }
  14877. return false;
  14878. }
  14879. private static function getUserDir()
  14880. {
  14881. $home = getenv('HOME');
  14882. if (!$home) {
  14883. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14884. }
  14885. return rtrim(strtr($home, '\\', '/'), '/');
  14886. }
  14887. }
  14888. <?php
  14889. namespace Composer\IO;
  14890. use Composer\Config;
  14891. use Composer\Util\ProcessExecutor;
  14892. use Psr\Log\LogLevel;
  14893. abstract class BaseIO implements IOInterface
  14894. {
  14895. protected $authentications = array();
  14896. public function getAuthentications()
  14897. {
  14898. return $this->authentications;
  14899. }
  14900. public function resetAuthentications()
  14901. {
  14902. $this->authentications = array();
  14903. }
  14904. public function hasAuthentication($repositoryName)
  14905. {
  14906. return isset($this->authentications[$repositoryName]);
  14907. }
  14908. public function getAuthentication($repositoryName)
  14909. {
  14910. if (isset($this->authentications[$repositoryName])) {
  14911. return $this->authentications[$repositoryName];
  14912. }
  14913. return array('username' => null, 'password' => null);
  14914. }
  14915. public function setAuthentication($repositoryName, $username, $password = null)
  14916. {
  14917. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  14918. }
  14919. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  14920. {
  14921. $this->write($messages, $newline, $verbosity);
  14922. }
  14923. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  14924. {
  14925. $this->writeError($messages, $newline, $verbosity);
  14926. }
  14927. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  14928. {
  14929. if ($this->hasAuthentication($repositoryName)) {
  14930. $auth = $this->getAuthentication($repositoryName);
  14931. if ($auth['username'] === $username && $auth['password'] === $password) {
  14932. return;
  14933. }
  14934. $this->writeError(
  14935. sprintf(
  14936. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  14937. $repositoryName
  14938. )
  14939. );
  14940. }
  14941. $this->setAuthentication($repositoryName, $username, $password);
  14942. }
  14943. public function loadConfiguration(Config $config)
  14944. {
  14945. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  14946. $githubOauth = $config->get('github-oauth') ?: array();
  14947. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  14948. $gitlabToken = $config->get('gitlab-token') ?: array();
  14949. $httpBasic = $config->get('http-basic') ?: array();
  14950. $bearerToken = $config->get('bearer') ?: array();
  14951. foreach ($bitbucketOauth as $domain => $cred) {
  14952. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  14953. }
  14954. foreach ($githubOauth as $domain => $token) {
  14955. if (!preg_match('{^[.a-z0-9]+$}', $token)) {
  14956. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  14957. }
  14958. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  14959. }
  14960. foreach ($gitlabOauth as $domain => $token) {
  14961. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  14962. }
  14963. foreach ($gitlabToken as $domain => $token) {
  14964. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  14965. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  14966. $this->checkAndSetAuthentication($domain, $username, $password);
  14967. }
  14968. foreach ($httpBasic as $domain => $cred) {
  14969. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  14970. }
  14971. foreach ($bearerToken as $domain => $token) {
  14972. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  14973. }
  14974. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  14975. }
  14976. public function emergency($message, array $context = array())
  14977. {
  14978. return $this->log(LogLevel::EMERGENCY, $message, $context);
  14979. }
  14980. public function alert($message, array $context = array())
  14981. {
  14982. return $this->log(LogLevel::ALERT, $message, $context);
  14983. }
  14984. public function critical($message, array $context = array())
  14985. {
  14986. return $this->log(LogLevel::CRITICAL, $message, $context);
  14987. }
  14988. public function error($message, array $context = array())
  14989. {
  14990. return $this->log(LogLevel::ERROR, $message, $context);
  14991. }
  14992. public function warning($message, array $context = array())
  14993. {
  14994. return $this->log(LogLevel::WARNING, $message, $context);
  14995. }
  14996. public function notice($message, array $context = array())
  14997. {
  14998. return $this->log(LogLevel::NOTICE, $message, $context);
  14999. }
  15000. public function info($message, array $context = array())
  15001. {
  15002. return $this->log(LogLevel::INFO, $message, $context);
  15003. }
  15004. public function debug($message, array $context = array())
  15005. {
  15006. return $this->log(LogLevel::DEBUG, $message, $context);
  15007. }
  15008. public function log($level, $message, array $context = array())
  15009. {
  15010. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  15011. $this->writeError('<error>'.$message.'</error>');
  15012. } elseif ($level === LogLevel::WARNING) {
  15013. $this->writeError('<warning>'.$message.'</warning>');
  15014. } elseif ($level === LogLevel::NOTICE) {
  15015. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  15016. } elseif ($level === LogLevel::INFO) {
  15017. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  15018. } else {
  15019. $this->writeError($message, true, self::DEBUG);
  15020. }
  15021. }
  15022. }
  15023. <?php
  15024. namespace Composer\IO;
  15025. use Symfony\Component\Console\Helper\QuestionHelper;
  15026. use Symfony\Component\Console\Output\StreamOutput;
  15027. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  15028. use Symfony\Component\Console\Input\StreamableInputInterface;
  15029. use Symfony\Component\Console\Input\StringInput;
  15030. use Symfony\Component\Console\Helper\HelperSet;
  15031. class BufferIO extends ConsoleIO
  15032. {
  15033. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  15034. {
  15035. $input = new StringInput($input);
  15036. $input->setInteractive(false);
  15037. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  15038. parent::__construct($input, $output, new HelperSet(array(
  15039. new QuestionHelper(),
  15040. )));
  15041. }
  15042. public function getOutput()
  15043. {
  15044. fseek($this->output->getStream(), 0);
  15045. $output = stream_get_contents($this->output->getStream());
  15046. $output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  15047. $pre = strip_tags($matches[1]);
  15048. if (strlen($pre) === strlen($matches[2])) {
  15049. return '';
  15050. }
  15051. return rtrim($matches[1])."\n";
  15052. }, $output);
  15053. return $output;
  15054. }
  15055. public function setUserInputs(array $inputs)
  15056. {
  15057. if (!$this->input instanceof StreamableInputInterface) {
  15058. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  15059. }
  15060. $this->input->setStream($this->createStream($inputs));
  15061. $this->input->setInteractive(true);
  15062. }
  15063. private function createStream(array $inputs)
  15064. {
  15065. $stream = fopen('php://memory', 'r+');
  15066. foreach ($inputs as $input) {
  15067. fwrite($stream, $input.PHP_EOL);
  15068. }
  15069. rewind($stream);
  15070. return $stream;
  15071. }
  15072. }
  15073. <?php
  15074. namespace Composer\IO;
  15075. use Composer\Question\StrictConfirmationQuestion;
  15076. use Symfony\Component\Console\Helper\HelperSet;
  15077. use Symfony\Component\Console\Helper\ProgressBar;
  15078. use Symfony\Component\Console\Input\InputInterface;
  15079. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  15080. use Symfony\Component\Console\Output\OutputInterface;
  15081. use Symfony\Component\Console\Question\ChoiceQuestion;
  15082. use Symfony\Component\Console\Question\Question;
  15083. class ConsoleIO extends BaseIO
  15084. {
  15085. protected $input;
  15086. protected $output;
  15087. protected $helperSet;
  15088. protected $lastMessage;
  15089. protected $lastMessageErr;
  15090. private $startTime;
  15091. private $verbosityMap;
  15092. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  15093. {
  15094. $this->input = $input;
  15095. $this->output = $output;
  15096. $this->helperSet = $helperSet;
  15097. $this->verbosityMap = array(
  15098. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  15099. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  15100. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  15101. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  15102. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  15103. );
  15104. }
  15105. public function enableDebugging($startTime)
  15106. {
  15107. $this->startTime = $startTime;
  15108. }
  15109. public function isInteractive()
  15110. {
  15111. return $this->input->isInteractive();
  15112. }
  15113. public function isDecorated()
  15114. {
  15115. return $this->output->isDecorated();
  15116. }
  15117. public function isVerbose()
  15118. {
  15119. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  15120. }
  15121. public function isVeryVerbose()
  15122. {
  15123. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  15124. }
  15125. public function isDebug()
  15126. {
  15127. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  15128. }
  15129. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15130. {
  15131. $this->doWrite($messages, $newline, false, $verbosity);
  15132. }
  15133. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15134. {
  15135. $this->doWrite($messages, $newline, true, $verbosity);
  15136. }
  15137. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15138. {
  15139. $this->doWrite($messages, $newline, false, $verbosity, true);
  15140. }
  15141. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15142. {
  15143. $this->doWrite($messages, $newline, true, $verbosity, true);
  15144. }
  15145. private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
  15146. {
  15147. $sfVerbosity = $this->verbosityMap[$verbosity];
  15148. if ($sfVerbosity > $this->output->getVerbosity()) {
  15149. return;
  15150. }
  15151. if (OutputInterface::VERBOSITY_QUIET === 0) {
  15152. $sfVerbosity = OutputInterface::OUTPUT_NORMAL;
  15153. }
  15154. if ($raw) {
  15155. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  15156. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  15157. } else {
  15158. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  15159. }
  15160. }
  15161. if (null !== $this->startTime) {
  15162. $memoryUsage = memory_get_usage() / 1024 / 1024;
  15163. $timeSpent = microtime(true) - $this->startTime;
  15164. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  15165. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  15166. }, (array) $messages);
  15167. }
  15168. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  15169. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  15170. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  15171. return;
  15172. }
  15173. $this->output->write($messages, $newline, $sfVerbosity);
  15174. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  15175. }
  15176. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15177. {
  15178. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  15179. }
  15180. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15181. {
  15182. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  15183. }
  15184. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  15185. {
  15186. $messages = implode($newline ? "\n" : '', (array) $messages);
  15187. if (!isset($size)) {
  15188. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  15189. }
  15190. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  15191. $this->doWrite($messages, false, $stderr, $verbosity);
  15192. $fill = $size - strlen(strip_tags($messages));
  15193. if ($fill > 0) {
  15194. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  15195. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  15196. }
  15197. if ($newline) {
  15198. $this->doWrite('', true, $stderr, $verbosity);
  15199. }
  15200. if ($stderr) {
  15201. $this->lastMessageErr = $messages;
  15202. } else {
  15203. $this->lastMessage = $messages;
  15204. }
  15205. }
  15206. public function getProgressBar($max = 0)
  15207. {
  15208. return new ProgressBar($this->getErrorOutput(), $max);
  15209. }
  15210. public function ask($question, $default = null)
  15211. {
  15212. $helper = $this->helperSet->get('question');
  15213. $question = new Question($question, $default);
  15214. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15215. }
  15216. public function askConfirmation($question, $default = true)
  15217. {
  15218. $helper = $this->helperSet->get('question');
  15219. $question = new StrictConfirmationQuestion($question, $default);
  15220. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15221. }
  15222. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  15223. {
  15224. $helper = $this->helperSet->get('question');
  15225. $question = new Question($question, $default);
  15226. $question->setValidator($validator);
  15227. $question->setMaxAttempts($attempts);
  15228. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15229. }
  15230. public function askAndHideAnswer($question)
  15231. {
  15232. $helper = $this->helperSet->get('question');
  15233. $question = new Question($question);
  15234. $question->setHidden(true);
  15235. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15236. }
  15237. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15238. {
  15239. $helper = $this->helperSet->get('question');
  15240. $question = new ChoiceQuestion($question, $choices, $default);
  15241. $question->setMaxAttempts($attempts ?: null);
  15242. $question->setErrorMessage($errorMessage);
  15243. $question->setMultiselect($multiselect);
  15244. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  15245. if (!is_array($result)) {
  15246. return (string) array_search($result, $choices, true);
  15247. }
  15248. $results = array();
  15249. foreach ($choices as $index => $choice) {
  15250. if (in_array($choice, $result, true)) {
  15251. $results[] = (string) $index;
  15252. }
  15253. }
  15254. return $results;
  15255. }
  15256. private function getErrorOutput()
  15257. {
  15258. if ($this->output instanceof ConsoleOutputInterface) {
  15259. return $this->output->getErrorOutput();
  15260. }
  15261. return $this->output;
  15262. }
  15263. }
  15264. <?php
  15265. namespace Composer\IO;
  15266. use Composer\Config;
  15267. use Psr\Log\LoggerInterface;
  15268. interface IOInterface extends LoggerInterface
  15269. {
  15270. const QUIET = 1;
  15271. const NORMAL = 2;
  15272. const VERBOSE = 4;
  15273. const VERY_VERBOSE = 8;
  15274. const DEBUG = 16;
  15275. public function isInteractive();
  15276. public function isVerbose();
  15277. public function isVeryVerbose();
  15278. public function isDebug();
  15279. public function isDecorated();
  15280. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  15281. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  15282. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15283. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15284. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15285. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15286. public function ask($question, $default = null);
  15287. public function askConfirmation($question, $default = true);
  15288. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  15289. public function askAndHideAnswer($question);
  15290. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  15291. public function getAuthentications();
  15292. public function hasAuthentication($repositoryName);
  15293. public function getAuthentication($repositoryName);
  15294. public function setAuthentication($repositoryName, $username, $password = null);
  15295. public function loadConfiguration(Config $config);
  15296. }
  15297. <?php
  15298. namespace Composer\IO;
  15299. class NullIO extends BaseIO
  15300. {
  15301. public function isInteractive()
  15302. {
  15303. return false;
  15304. }
  15305. public function isVerbose()
  15306. {
  15307. return false;
  15308. }
  15309. public function isVeryVerbose()
  15310. {
  15311. return false;
  15312. }
  15313. public function isDebug()
  15314. {
  15315. return false;
  15316. }
  15317. public function isDecorated()
  15318. {
  15319. return false;
  15320. }
  15321. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15322. {
  15323. }
  15324. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15325. {
  15326. }
  15327. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15328. {
  15329. }
  15330. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15331. {
  15332. }
  15333. public function ask($question, $default = null)
  15334. {
  15335. return $default;
  15336. }
  15337. public function askConfirmation($question, $default = true)
  15338. {
  15339. return $default;
  15340. }
  15341. public function askAndValidate($question, $validator, $attempts = false, $default = null)
  15342. {
  15343. return $default;
  15344. }
  15345. public function askAndHideAnswer($question)
  15346. {
  15347. return null;
  15348. }
  15349. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15350. {
  15351. return $default;
  15352. }
  15353. }
  15354. <?php
  15355. namespace Composer;
  15356. use Composer\Semver\VersionParser;
  15357. class InstalledVersions
  15358. {
  15359. private static $installed;
  15360. public static function getInstalledPackages()
  15361. {
  15362. return array_keys(self::$installed['versions']);
  15363. }
  15364. public static function isInstalled($packageName)
  15365. {
  15366. return isset(self::$installed['versions'][$packageName]);
  15367. }
  15368. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  15369. {
  15370. $constraint = $parser->parseConstraints($constraint);
  15371. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  15372. return $provided->matches($constraint);
  15373. }
  15374. public static function getVersionRanges($packageName)
  15375. {
  15376. if (!isset(self::$installed['versions'][$packageName])) {
  15377. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15378. }
  15379. $ranges = array();
  15380. if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  15381. $ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
  15382. }
  15383. if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
  15384. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
  15385. }
  15386. if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
  15387. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
  15388. }
  15389. if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
  15390. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
  15391. }
  15392. return implode(' || ', $ranges);
  15393. }
  15394. public static function getVersion($packageName)
  15395. {
  15396. if (!isset(self::$installed['versions'][$packageName])) {
  15397. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15398. }
  15399. if (!isset(self::$installed['versions'][$packageName]['version'])) {
  15400. return null;
  15401. }
  15402. return self::$installed['versions'][$packageName]['version'];
  15403. }
  15404. public static function getPrettyVersion($packageName)
  15405. {
  15406. if (!isset(self::$installed['versions'][$packageName])) {
  15407. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15408. }
  15409. if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  15410. return null;
  15411. }
  15412. return self::$installed['versions'][$packageName]['pretty_version'];
  15413. }
  15414. public static function getReference($packageName)
  15415. {
  15416. if (!isset(self::$installed['versions'][$packageName])) {
  15417. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15418. }
  15419. if (!isset(self::$installed['versions'][$packageName]['reference'])) {
  15420. return null;
  15421. }
  15422. return self::$installed['versions'][$packageName]['reference'];
  15423. }
  15424. public static function getRootPackage()
  15425. {
  15426. return self::$installed['root'];
  15427. }
  15428. public static function getRawData()
  15429. {
  15430. return self::$installed;
  15431. }
  15432. public static function reload($data)
  15433. {
  15434. self::$installed = $data;
  15435. }
  15436. }
  15437. <?php
  15438. namespace Composer;
  15439. use Composer\Autoload\AutoloadGenerator;
  15440. use Composer\Console\GithubActionError;
  15441. use Composer\DependencyResolver\DefaultPolicy;
  15442. use Composer\DependencyResolver\LocalRepoTransaction;
  15443. use Composer\DependencyResolver\LockTransaction;
  15444. use Composer\DependencyResolver\Operation\UpdateOperation;
  15445. use Composer\DependencyResolver\Operation\InstallOperation;
  15446. use Composer\DependencyResolver\Operation\UninstallOperation;
  15447. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  15448. use Composer\DependencyResolver\Operation\OperationInterface;
  15449. use Composer\DependencyResolver\PolicyInterface;
  15450. use Composer\DependencyResolver\Pool;
  15451. use Composer\DependencyResolver\Request;
  15452. use Composer\DependencyResolver\Rule;
  15453. use Composer\DependencyResolver\Solver;
  15454. use Composer\DependencyResolver\SolverProblemsException;
  15455. use Composer\Downloader\DownloadManager;
  15456. use Composer\EventDispatcher\EventDispatcher;
  15457. use Composer\Installer\InstallationManager;
  15458. use Composer\Installer\InstallerEvents;
  15459. use Composer\Installer\NoopInstaller;
  15460. use Composer\Installer\SuggestedPackagesReporter;
  15461. use Composer\IO\IOInterface;
  15462. use Composer\Package\AliasPackage;
  15463. use Composer\Package\RootAliasPackage;
  15464. use Composer\Package\BasePackage;
  15465. use Composer\Package\CompletePackage;
  15466. use Composer\Package\CompletePackageInterface;
  15467. use Composer\Package\Link;
  15468. use Composer\Package\LinkConstraint\VersionConstraint;
  15469. use Composer\Package\Loader\ArrayLoader;
  15470. use Composer\Package\Dumper\ArrayDumper;
  15471. use Composer\Package\Version\VersionParser;
  15472. use Composer\Package\Package;
  15473. use Composer\Repository\ArrayRepository;
  15474. use Composer\Repository\RepositorySet;
  15475. use Composer\Semver\Constraint\Constraint;
  15476. use Composer\Package\Locker;
  15477. use Composer\Package\PackageInterface;
  15478. use Composer\Package\RootPackageInterface;
  15479. use Composer\Repository\CompositeRepository;
  15480. use Composer\Repository\InstalledArrayRepository;
  15481. use Composer\Repository\InstalledRepositoryInterface;
  15482. use Composer\Repository\InstalledRepository;
  15483. use Composer\Repository\RootPackageRepository;
  15484. use Composer\Repository\PlatformRepository;
  15485. use Composer\Repository\RepositoryInterface;
  15486. use Composer\Repository\RepositoryManager;
  15487. use Composer\Script\ScriptEvents;
  15488. class Installer
  15489. {
  15490. protected $io;
  15491. protected $config;
  15492. protected $package;
  15493. protected $fixedRootPackage;
  15494. protected $downloadManager;
  15495. protected $repositoryManager;
  15496. protected $locker;
  15497. protected $installationManager;
  15498. protected $eventDispatcher;
  15499. protected $autoloadGenerator;
  15500. protected $preferSource = false;
  15501. protected $preferDist = false;
  15502. protected $optimizeAutoloader = false;
  15503. protected $classMapAuthoritative = false;
  15504. protected $apcuAutoloader = false;
  15505. protected $apcuAutoloaderPrefix;
  15506. protected $devMode = false;
  15507. protected $dryRun = false;
  15508. protected $verbose = false;
  15509. protected $update = false;
  15510. protected $install = true;
  15511. protected $dumpAutoloader = true;
  15512. protected $runScripts = true;
  15513. protected $ignorePlatformReqs = false;
  15514. protected $preferStable = false;
  15515. protected $preferLowest = false;
  15516. protected $writeLock;
  15517. protected $executeOperations = true;
  15518. protected $updateMirrors = false;
  15519. protected $updateAllowList;
  15520. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  15521. protected $suggestedPackagesReporter;
  15522. protected $additionalFixedRepository;
  15523. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  15524. {
  15525. $this->io = $io;
  15526. $this->config = $config;
  15527. $this->package = $package;
  15528. $this->downloadManager = $downloadManager;
  15529. $this->repositoryManager = $repositoryManager;
  15530. $this->locker = $locker;
  15531. $this->installationManager = $installationManager;
  15532. $this->eventDispatcher = $eventDispatcher;
  15533. $this->autoloadGenerator = $autoloadGenerator;
  15534. $this->writeLock = $config->get('lock');
  15535. }
  15536. public function run()
  15537. {
  15538. gc_collect_cycles();
  15539. gc_disable();
  15540. if ($this->updateAllowList && $this->updateMirrors) {
  15541. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  15542. }
  15543. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  15544. if (!$this->update && !$this->locker->isLocked()) {
  15545. $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>');
  15546. $this->update = true;
  15547. }
  15548. if ($this->dryRun) {
  15549. $this->verbose = true;
  15550. $this->runScripts = false;
  15551. $this->executeOperations = false;
  15552. $this->writeLock = false;
  15553. $this->dumpAutoloader = false;
  15554. $this->mockLocalRepositories($this->repositoryManager);
  15555. }
  15556. if ($this->update && !$this->install) {
  15557. $this->dumpAutoloader = false;
  15558. }
  15559. if ($this->runScripts) {
  15560. $_SERVER['COMPOSER_DEV_MODE'] = $this->devMode ? '1' : '0';
  15561. putenv('COMPOSER_DEV_MODE='.$_SERVER['COMPOSER_DEV_MODE']);
  15562. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  15563. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15564. }
  15565. $this->downloadManager->setPreferSource($this->preferSource);
  15566. $this->downloadManager->setPreferDist($this->preferDist);
  15567. $localRepo = $this->repositoryManager->getLocalRepository();
  15568. if (!$this->suggestedPackagesReporter) {
  15569. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  15570. }
  15571. try {
  15572. if ($this->update) {
  15573. $res = $this->doUpdate($localRepo, $this->install);
  15574. } else {
  15575. $res = $this->doInstall($localRepo);
  15576. }
  15577. if ($res !== 0) {
  15578. return $res;
  15579. }
  15580. } catch (\Exception $e) {
  15581. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15582. $this->installationManager->notifyInstalls($this->io);
  15583. }
  15584. throw $e;
  15585. }
  15586. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15587. $this->installationManager->notifyInstalls($this->io);
  15588. }
  15589. if ($this->update) {
  15590. $installedRepo = new InstalledRepository(array(
  15591. $this->locker->getLockedRepository($this->devMode),
  15592. $this->createPlatformRepo(false),
  15593. new RootPackageRepository(clone $this->package),
  15594. ));
  15595. if ($isFreshInstall) {
  15596. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  15597. }
  15598. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  15599. }
  15600. $lockedRepository = $this->locker->getLockedRepository(true);
  15601. foreach ($lockedRepository->getPackages() as $package) {
  15602. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  15603. continue;
  15604. }
  15605. $replacement = is_string($package->getReplacementPackage())
  15606. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  15607. : 'No replacement was suggested';
  15608. $this->io->writeError(
  15609. sprintf(
  15610. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  15611. $package->getPrettyName(),
  15612. $replacement
  15613. )
  15614. );
  15615. }
  15616. if ($this->dumpAutoloader) {
  15617. if ($this->optimizeAutoloader) {
  15618. $this->io->writeError('<info>Generating optimized autoload files</info>');
  15619. } else {
  15620. $this->io->writeError('<info>Generating autoload files</info>');
  15621. }
  15622. $this->autoloadGenerator->setDevMode($this->devMode);
  15623. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  15624. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  15625. $this->autoloadGenerator->setRunScripts($this->runScripts);
  15626. $this->autoloadGenerator->setIgnorePlatformRequirements($this->ignorePlatformReqs);
  15627. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  15628. }
  15629. if ($this->install && $this->executeOperations) {
  15630. foreach ($localRepo->getPackages() as $package) {
  15631. $this->installationManager->ensureBinariesPresence($package);
  15632. }
  15633. }
  15634. $fundingCount = 0;
  15635. foreach ($localRepo->getPackages() as $package) {
  15636. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  15637. $fundingCount++;
  15638. }
  15639. }
  15640. if ($fundingCount) {
  15641. $this->io->writeError(array(
  15642. sprintf(
  15643. "<info>%d package%s you are using %s looking for funding.</info>",
  15644. $fundingCount,
  15645. 1 === $fundingCount ? '' : 's',
  15646. 1 === $fundingCount ? 'is' : 'are'
  15647. ),
  15648. '<info>Use the `composer fund` command to find out more!</info>',
  15649. ));
  15650. }
  15651. if ($this->runScripts) {
  15652. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  15653. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15654. }
  15655. if (!defined('HHVM_VERSION')) {
  15656. gc_enable();
  15657. }
  15658. return 0;
  15659. }
  15660. protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
  15661. {
  15662. $platformRepo = $this->createPlatformRepo(true);
  15663. $aliases = $this->getRootAliases(true);
  15664. $lockedRepository = null;
  15665. try {
  15666. if ($this->locker->isLocked()) {
  15667. $lockedRepository = $this->locker->getLockedRepository(true);
  15668. }
  15669. } catch (\Seld\JsonLint\ParsingException $e) {
  15670. if ($this->updateAllowList || $this->updateMirrors) {
  15671. throw $e;
  15672. }
  15673. }
  15674. if ($this->updateAllowList) {
  15675. if (!$lockedRepository) {
  15676. $this->io->writeError('<error>Cannot update only a partial set of packages without a lock file present.</error>', true, IOInterface::QUIET);
  15677. return 1;
  15678. }
  15679. }
  15680. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  15681. $policy = $this->createPolicy(true);
  15682. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15683. $repositories = $this->repositoryManager->getRepositories();
  15684. foreach ($repositories as $repository) {
  15685. $repositorySet->addRepository($repository);
  15686. }
  15687. if ($lockedRepository) {
  15688. $repositorySet->addRepository($lockedRepository);
  15689. }
  15690. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15691. if ($this->updateMirrors && $lockedRepository) {
  15692. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  15693. if (!$lockedPackage instanceof AliasPackage) {
  15694. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  15695. }
  15696. }
  15697. } else {
  15698. $links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  15699. foreach ($links as $link) {
  15700. $request->requireName($link->getTarget(), $link->getConstraint());
  15701. }
  15702. }
  15703. if ($this->updateAllowList) {
  15704. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  15705. }
  15706. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15707. $this->io->writeError('<info>Updating dependencies</info>');
  15708. $solver = new Solver($policy, $pool, $this->io);
  15709. try {
  15710. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15711. $ruleSetSize = $solver->getRuleSetSize();
  15712. $solver = null;
  15713. } catch (SolverProblemsException $e) {
  15714. $err = 'Your requirements could not be resolved to an installable set of packages.';
  15715. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15716. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15717. $this->io->writeError($prettyProblem);
  15718. if (!$this->devMode) {
  15719. $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);
  15720. }
  15721. $ghe = new GithubActionError($this->io);
  15722. $ghe->emit($err."\n".$prettyProblem);
  15723. return max(1, $e->getCode());
  15724. }
  15725. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  15726. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  15727. if (!$lockTransaction->getOperations()) {
  15728. $this->io->writeError('Nothing to modify in lock file');
  15729. }
  15730. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy);
  15731. if ($exitCode !== 0) {
  15732. return $exitCode;
  15733. }
  15734. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  15735. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  15736. $installsUpdates = $uninstalls = array();
  15737. if ($lockTransaction->getOperations()) {
  15738. $installNames = $updateNames = $uninstallNames = array();
  15739. foreach ($lockTransaction->getOperations() as $operation) {
  15740. if ($operation instanceof InstallOperation) {
  15741. $installsUpdates[] = $operation;
  15742. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15743. } elseif ($operation instanceof UpdateOperation) {
  15744. $installsUpdates[] = $operation;
  15745. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15746. } elseif ($operation instanceof UninstallOperation) {
  15747. $uninstalls[] = $operation;
  15748. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  15749. }
  15750. }
  15751. $this->io->writeError(sprintf(
  15752. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  15753. count($installNames),
  15754. 1 === count($installNames) ? '' : 's',
  15755. count($updateNames),
  15756. 1 === count($updateNames) ? '' : 's',
  15757. count($uninstalls),
  15758. 1 === count($uninstalls) ? '' : 's'
  15759. ));
  15760. if ($installNames) {
  15761. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  15762. }
  15763. if ($updateNames) {
  15764. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  15765. }
  15766. if ($uninstalls) {
  15767. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  15768. }
  15769. }
  15770. $sortByName = function ($a, $b) {
  15771. if ($a instanceof UpdateOperation) {
  15772. $a = $a->getTargetPackage()->getName();
  15773. } else {
  15774. $a = $a->getPackage()->getName();
  15775. }
  15776. if ($b instanceof UpdateOperation) {
  15777. $b = $b->getTargetPackage()->getName();
  15778. } else {
  15779. $b = $b->getPackage()->getName();
  15780. }
  15781. return strcmp($a, $b);
  15782. };
  15783. usort($uninstalls, $sortByName);
  15784. usort($installsUpdates, $sortByName);
  15785. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  15786. if ($operation instanceof InstallOperation) {
  15787. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  15788. }
  15789. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  15790. $this->io->writeError(' - ' . $operation->show(true));
  15791. }
  15792. }
  15793. $updatedLock = $this->locker->setLockData(
  15794. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  15795. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  15796. $platformReqs,
  15797. $platformDevReqs,
  15798. $lockTransaction->getAliases($aliases),
  15799. $this->package->getMinimumStability(),
  15800. $this->package->getStabilityFlags(),
  15801. $this->preferStable || $this->package->getPreferStable(),
  15802. $this->preferLowest,
  15803. $this->config->get('platform') ?: array(),
  15804. $this->writeLock && $this->executeOperations
  15805. );
  15806. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  15807. $this->io->writeError('<info>Writing lock file</info>');
  15808. }
  15809. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  15810. $vendorDir = $this->config->get('vendor-dir');
  15811. if (is_dir($vendorDir)) {
  15812. @touch($vendorDir);
  15813. }
  15814. }
  15815. if ($doInstall) {
  15816. return $this->doInstall($localRepo, true);
  15817. }
  15818. return 0;
  15819. }
  15820. protected function extractDevPackages(LockTransaction $lockTransaction, $platformRepo, $aliases, $policy)
  15821. {
  15822. if (!$this->package->getDevRequires()) {
  15823. return 0;
  15824. }
  15825. $resultRepo = new ArrayRepository(array());
  15826. $loader = new ArrayLoader(null, true);
  15827. $dumper = new ArrayDumper();
  15828. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  15829. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  15830. }
  15831. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15832. $repositorySet->addRepository($resultRepo);
  15833. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  15834. $links = $this->package->getRequires();
  15835. foreach ($links as $link) {
  15836. $request->requireName($link->getTarget(), $link->getConstraint());
  15837. }
  15838. $pool = $repositorySet->createPoolWithAllPackages();
  15839. $solver = new Solver($policy, $pool, $this->io);
  15840. try {
  15841. $nonDevLockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15842. $solver = null;
  15843. } catch (SolverProblemsException $e) {
  15844. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  15845. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  15846. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15847. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  15848. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  15849. $this->io->writeError($prettyProblem);
  15850. $ghe = new GithubActionError($this->io);
  15851. $ghe->emit($err."\n".$prettyProblem);
  15852. return max(1, $e->getCode());
  15853. }
  15854. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  15855. return 0;
  15856. }
  15857. protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false)
  15858. {
  15859. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  15860. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  15861. if (!$alreadySolved) {
  15862. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  15863. $platformRepo = $this->createPlatformRepo(false);
  15864. $policy = $this->createPolicy(false);
  15865. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  15866. $repositorySet->addRepository($lockedRepository);
  15867. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15868. if (!$this->locker->isFresh()) {
  15869. $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);
  15870. }
  15871. foreach ($lockedRepository->getPackages() as $package) {
  15872. $request->fixLockedPackage($package);
  15873. }
  15874. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  15875. $request->requireName($link->getTarget(), $link->getConstraint());
  15876. }
  15877. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15878. $solver = new Solver($policy, $pool, $this->io);
  15879. try {
  15880. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15881. $solver = null;
  15882. if (0 !== count($lockTransaction->getOperations())) {
  15883. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  15884. return 1;
  15885. }
  15886. } catch (SolverProblemsException $e) {
  15887. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  15888. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15889. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15890. $this->io->writeError($prettyProblem);
  15891. $ghe = new GithubActionError($this->io);
  15892. $ghe->emit($err."\n".$prettyProblem);
  15893. return max(1, $e->getCode());
  15894. }
  15895. }
  15896. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  15897. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  15898. if (!$localRepoTransaction->getOperations()) {
  15899. $this->io->writeError('Nothing to install, update or remove');
  15900. }
  15901. if ($localRepoTransaction->getOperations()) {
  15902. $installs = $updates = $uninstalls = array();
  15903. foreach ($localRepoTransaction->getOperations() as $operation) {
  15904. if ($operation instanceof InstallOperation) {
  15905. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15906. } elseif ($operation instanceof UpdateOperation) {
  15907. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15908. } elseif ($operation instanceof UninstallOperation) {
  15909. $uninstalls[] = $operation->getPackage()->getPrettyName();
  15910. }
  15911. }
  15912. $this->io->writeError(sprintf(
  15913. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  15914. count($installs),
  15915. 1 === count($installs) ? '' : 's',
  15916. count($updates),
  15917. 1 === count($updates) ? '' : 's',
  15918. count($uninstalls),
  15919. 1 === count($uninstalls) ? '' : 's'
  15920. ));
  15921. if ($installs) {
  15922. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  15923. }
  15924. if ($updates) {
  15925. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  15926. }
  15927. if ($uninstalls) {
  15928. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  15929. }
  15930. }
  15931. if ($this->executeOperations) {
  15932. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  15933. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  15934. } else {
  15935. foreach ($localRepoTransaction->getOperations() as $operation) {
  15936. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  15937. $this->io->writeError(' - ' . $operation->show(false));
  15938. }
  15939. }
  15940. }
  15941. return 0;
  15942. }
  15943. private function createPlatformRepo($forUpdate)
  15944. {
  15945. if ($forUpdate) {
  15946. $platformOverrides = $this->config->get('platform') ?: array();
  15947. } else {
  15948. $platformOverrides = $this->locker->getPlatformOverrides();
  15949. }
  15950. return new PlatformRepository(array(), $platformOverrides);
  15951. }
  15952. private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
  15953. {
  15954. if ($forUpdate) {
  15955. $minimumStability = $this->package->getMinimumStability();
  15956. $stabilityFlags = $this->package->getStabilityFlags();
  15957. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  15958. } else {
  15959. $minimumStability = $this->locker->getMinimumStability();
  15960. $stabilityFlags = $this->locker->getStabilityFlags();
  15961. $requires = array();
  15962. foreach ($lockedRepository->getPackages() as $package) {
  15963. $constraint = new Constraint('=', $package->getVersion());
  15964. $constraint->setPrettyString($package->getPrettyVersion());
  15965. $requires[$package->getName()] = $constraint;
  15966. }
  15967. }
  15968. $rootRequires = array();
  15969. foreach ($requires as $req => $constraint) {
  15970. if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($req)) {
  15971. continue;
  15972. }
  15973. if ($constraint instanceof Link) {
  15974. $rootRequires[$req] = $constraint->getConstraint();
  15975. } else {
  15976. $rootRequires[$req] = $constraint;
  15977. }
  15978. }
  15979. $this->fixedRootPackage = clone $this->package;
  15980. $this->fixedRootPackage->setRequires(array());
  15981. $this->fixedRootPackage->setDevRequires(array());
  15982. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  15983. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  15984. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  15985. $repositorySet->addRepository($platformRepo);
  15986. if ($this->additionalFixedRepository) {
  15987. $repositorySet->addRepository($this->additionalFixedRepository);
  15988. }
  15989. return $repositorySet;
  15990. }
  15991. private function createPolicy($forUpdate)
  15992. {
  15993. $preferStable = null;
  15994. $preferLowest = null;
  15995. if (!$forUpdate) {
  15996. $preferStable = $this->locker->getPreferStable();
  15997. $preferLowest = $this->locker->getPreferLowest();
  15998. }
  15999. if (null === $preferStable) {
  16000. $preferStable = $this->preferStable || $this->package->getPreferStable();
  16001. }
  16002. if (null === $preferLowest) {
  16003. $preferLowest = $this->preferLowest;
  16004. }
  16005. return new DefaultPolicy($preferStable, $preferLowest);
  16006. }
  16007. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, $lockedRepository = null)
  16008. {
  16009. $request = new Request($lockedRepository);
  16010. $request->fixPackage($rootPackage);
  16011. if ($rootPackage instanceof RootAliasPackage) {
  16012. $request->fixPackage($rootPackage->getAliasOf());
  16013. }
  16014. $fixedPackages = $platformRepo->getPackages();
  16015. if ($this->additionalFixedRepository) {
  16016. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  16017. }
  16018. $provided = $rootPackage->getProvides();
  16019. foreach ($fixedPackages as $package) {
  16020. if ($package->getRepository() !== $platformRepo
  16021. || !isset($provided[$package->getName()])
  16022. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  16023. ) {
  16024. $request->fixPackage($package);
  16025. }
  16026. }
  16027. return $request;
  16028. }
  16029. private function getRootAliases($forUpdate)
  16030. {
  16031. if ($forUpdate) {
  16032. $aliases = $this->package->getAliases();
  16033. } else {
  16034. $aliases = $this->locker->getAliases();
  16035. }
  16036. return $aliases;
  16037. }
  16038. private function extractPlatformRequirements($links)
  16039. {
  16040. $platformReqs = array();
  16041. foreach ($links as $link) {
  16042. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  16043. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  16044. }
  16045. }
  16046. return $platformReqs;
  16047. }
  16048. private function mockLocalRepositories(RepositoryManager $rm)
  16049. {
  16050. $packages = array();
  16051. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  16052. $packages[(string) $package] = clone $package;
  16053. }
  16054. foreach ($packages as $key => $package) {
  16055. if ($package instanceof AliasPackage) {
  16056. $alias = (string) $package->getAliasOf();
  16057. $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  16058. }
  16059. }
  16060. $rm->setLocalRepository(
  16061. new InstalledArrayRepository($packages)
  16062. );
  16063. }
  16064. public static function create(IOInterface $io, Composer $composer)
  16065. {
  16066. return new static(
  16067. $io,
  16068. $composer->getConfig(),
  16069. $composer->getPackage(),
  16070. $composer->getDownloadManager(),
  16071. $composer->getRepositoryManager(),
  16072. $composer->getLocker(),
  16073. $composer->getInstallationManager(),
  16074. $composer->getEventDispatcher(),
  16075. $composer->getAutoloadGenerator()
  16076. );
  16077. }
  16078. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository)
  16079. {
  16080. $this->additionalFixedRepository = $additionalFixedRepository;
  16081. return $this;
  16082. }
  16083. public function setDryRun($dryRun = true)
  16084. {
  16085. $this->dryRun = (bool) $dryRun;
  16086. return $this;
  16087. }
  16088. public function isDryRun()
  16089. {
  16090. return $this->dryRun;
  16091. }
  16092. public function setPreferSource($preferSource = true)
  16093. {
  16094. $this->preferSource = (bool) $preferSource;
  16095. return $this;
  16096. }
  16097. public function setPreferDist($preferDist = true)
  16098. {
  16099. $this->preferDist = (bool) $preferDist;
  16100. return $this;
  16101. }
  16102. public function setOptimizeAutoloader($optimizeAutoloader)
  16103. {
  16104. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  16105. if (!$this->optimizeAutoloader) {
  16106. $this->setClassMapAuthoritative(false);
  16107. }
  16108. return $this;
  16109. }
  16110. public function setClassMapAuthoritative($classMapAuthoritative)
  16111. {
  16112. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  16113. if ($this->classMapAuthoritative) {
  16114. $this->setOptimizeAutoloader(true);
  16115. }
  16116. return $this;
  16117. }
  16118. public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
  16119. {
  16120. $this->apcuAutoloader = $apcuAutoloader;
  16121. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  16122. return $this;
  16123. }
  16124. public function setUpdate($update)
  16125. {
  16126. $this->update = (bool) $update;
  16127. return $this;
  16128. }
  16129. public function setInstall($install)
  16130. {
  16131. $this->install = (bool) $install;
  16132. return $this;
  16133. }
  16134. public function setDevMode($devMode = true)
  16135. {
  16136. $this->devMode = (bool) $devMode;
  16137. return $this;
  16138. }
  16139. public function setDumpAutoloader($dumpAutoloader = true)
  16140. {
  16141. $this->dumpAutoloader = (bool) $dumpAutoloader;
  16142. return $this;
  16143. }
  16144. public function setRunScripts($runScripts = true)
  16145. {
  16146. $this->runScripts = (bool) $runScripts;
  16147. return $this;
  16148. }
  16149. public function setConfig(Config $config)
  16150. {
  16151. $this->config = $config;
  16152. return $this;
  16153. }
  16154. public function setVerbose($verbose = true)
  16155. {
  16156. $this->verbose = (bool) $verbose;
  16157. return $this;
  16158. }
  16159. public function isVerbose()
  16160. {
  16161. return $this->verbose;
  16162. }
  16163. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  16164. {
  16165. if (is_array($ignorePlatformReqs)) {
  16166. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  16167. return PlatformRepository::isPlatformPackage($req);
  16168. });
  16169. } else {
  16170. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  16171. }
  16172. return $this;
  16173. }
  16174. public function setUpdateMirrors($updateMirrors)
  16175. {
  16176. $this->updateMirrors = $updateMirrors;
  16177. return $this;
  16178. }
  16179. public function setUpdateAllowList(array $packages)
  16180. {
  16181. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  16182. return $this;
  16183. }
  16184. public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  16185. {
  16186. 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)) {
  16187. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  16188. }
  16189. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  16190. return $this;
  16191. }
  16192. public function setPreferStable($preferStable = true)
  16193. {
  16194. $this->preferStable = (bool) $preferStable;
  16195. return $this;
  16196. }
  16197. public function setPreferLowest($preferLowest = true)
  16198. {
  16199. $this->preferLowest = (bool) $preferLowest;
  16200. return $this;
  16201. }
  16202. public function setWriteLock($writeLock = true)
  16203. {
  16204. $this->writeLock = (bool) $writeLock;
  16205. return $this;
  16206. }
  16207. public function setExecuteOperations($executeOperations = true)
  16208. {
  16209. $this->executeOperations = (bool) $executeOperations;
  16210. return $this;
  16211. }
  16212. public function disablePlugins()
  16213. {
  16214. $this->installationManager->disablePlugins();
  16215. return $this;
  16216. }
  16217. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  16218. {
  16219. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  16220. return $this;
  16221. }
  16222. }
  16223. <?php
  16224. namespace Composer\Installer;
  16225. use Composer\IO\IOInterface;
  16226. use Composer\Package\PackageInterface;
  16227. use Composer\Util\Filesystem;
  16228. use Composer\Util\Platform;
  16229. use Composer\Util\ProcessExecutor;
  16230. use Composer\Util\Silencer;
  16231. class BinaryInstaller
  16232. {
  16233. protected $binDir;
  16234. protected $binCompat;
  16235. protected $io;
  16236. protected $filesystem;
  16237. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
  16238. {
  16239. $this->binDir = $binDir;
  16240. $this->binCompat = $binCompat;
  16241. $this->io = $io;
  16242. $this->filesystem = $filesystem ?: new Filesystem();
  16243. }
  16244. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  16245. {
  16246. $binaries = $this->getBinaries($package);
  16247. if (!$binaries) {
  16248. return;
  16249. }
  16250. foreach ($binaries as $bin) {
  16251. $binPath = $installPath.'/'.$bin;
  16252. if (!file_exists($binPath)) {
  16253. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  16254. continue;
  16255. }
  16256. $binPath = realpath($binPath);
  16257. $this->initializeBinDir();
  16258. $link = $this->binDir.'/'.basename($bin);
  16259. if (file_exists($link)) {
  16260. if (is_link($link)) {
  16261. Silencer::call('chmod', $link, 0777 & ~umask());
  16262. }
  16263. if ($warnOnOverwrite) {
  16264. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  16265. }
  16266. continue;
  16267. }
  16268. if ($this->binCompat === "auto") {
  16269. if (Platform::isWindows()) {
  16270. $this->installFullBinaries($binPath, $link, $bin, $package);
  16271. } else {
  16272. $this->installSymlinkBinaries($binPath, $link);
  16273. }
  16274. } elseif ($this->binCompat === "full") {
  16275. $this->installFullBinaries($binPath, $link, $bin, $package);
  16276. }
  16277. Silencer::call('chmod', $link, 0777 & ~umask());
  16278. }
  16279. }
  16280. public function removeBinaries(PackageInterface $package)
  16281. {
  16282. $this->initializeBinDir();
  16283. $binaries = $this->getBinaries($package);
  16284. if (!$binaries) {
  16285. return;
  16286. }
  16287. foreach ($binaries as $bin) {
  16288. $link = $this->binDir.'/'.basename($bin);
  16289. if (is_link($link) || file_exists($link)) {
  16290. $this->filesystem->unlink($link);
  16291. }
  16292. if (file_exists($link.'.bat')) {
  16293. $this->filesystem->unlink($link.'.bat');
  16294. }
  16295. }
  16296. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  16297. Silencer::call('rmdir', $this->binDir);
  16298. }
  16299. }
  16300. public static function determineBinaryCaller($bin)
  16301. {
  16302. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  16303. return 'call';
  16304. }
  16305. $handle = fopen($bin, 'r');
  16306. $line = fgets($handle);
  16307. fclose($handle);
  16308. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  16309. return trim($match[1]);
  16310. }
  16311. return 'php';
  16312. }
  16313. protected function getBinaries(PackageInterface $package)
  16314. {
  16315. return $package->getBinaries();
  16316. }
  16317. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  16318. {
  16319. if ('.bat' !== substr($binPath, -4)) {
  16320. $this->installUnixyProxyBinaries($binPath, $link);
  16321. @chmod($link, 0777 & ~umask());
  16322. $link .= '.bat';
  16323. if (file_exists($link)) {
  16324. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  16325. }
  16326. }
  16327. if (!file_exists($link)) {
  16328. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  16329. }
  16330. }
  16331. protected function installSymlinkBinaries($binPath, $link)
  16332. {
  16333. if (!$this->filesystem->relativeSymlink($binPath, $link)) {
  16334. $this->installUnixyProxyBinaries($binPath, $link);
  16335. }
  16336. }
  16337. protected function installUnixyProxyBinaries($binPath, $link)
  16338. {
  16339. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  16340. }
  16341. protected function initializeBinDir()
  16342. {
  16343. $this->filesystem->ensureDirectoryExists($this->binDir);
  16344. $this->binDir = realpath($this->binDir);
  16345. }
  16346. protected function generateWindowsProxyCode($bin, $link)
  16347. {
  16348. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16349. $caller = self::determineBinaryCaller($bin);
  16350. return "@ECHO OFF\r\n".
  16351. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  16352. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  16353. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  16354. }
  16355. protected function generateUnixyProxyCode($bin, $link)
  16356. {
  16357. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16358. $binDir = ProcessExecutor::escape(dirname($binPath));
  16359. $binFile = basename($binPath);
  16360. $proxyCode = <<<PROXY
  16361. #!/usr/bin/env sh
  16362. dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  16363. if [ -d /proc/cygdrive ]; then
  16364. case \$(which php) in
  16365. \$(readlink -n /proc/cygdrive)/*)
  16366. # We are in Cygwin using Windows php, so the path must be translated
  16367. dir=\$(cygpath -m "\$dir");
  16368. ;;
  16369. esac
  16370. fi
  16371. "\${dir}/$binFile" "\$@"
  16372. PROXY;
  16373. return $proxyCode;
  16374. }
  16375. }
  16376. <?php
  16377. namespace Composer\Installer;
  16378. use Composer\Package\PackageInterface;
  16379. interface BinaryPresenceInterface
  16380. {
  16381. public function ensureBinariesPresence(PackageInterface $package);
  16382. }
  16383. <?php
  16384. namespace Composer\Installer;
  16385. use Composer\IO\IOInterface;
  16386. use Composer\IO\ConsoleIO;
  16387. use Composer\Package\PackageInterface;
  16388. use Composer\Package\AliasPackage;
  16389. use Composer\Repository\RepositoryInterface;
  16390. use Composer\Repository\InstalledRepositoryInterface;
  16391. use Composer\DependencyResolver\Operation\OperationInterface;
  16392. use Composer\DependencyResolver\Operation\InstallOperation;
  16393. use Composer\DependencyResolver\Operation\UpdateOperation;
  16394. use Composer\DependencyResolver\Operation\UninstallOperation;
  16395. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  16396. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  16397. use Composer\EventDispatcher\EventDispatcher;
  16398. use Composer\Util\StreamContextFactory;
  16399. use Composer\Util\Loop;
  16400. use React\Promise\PromiseInterface;
  16401. class InstallationManager
  16402. {
  16403. private $installers = array();
  16404. private $cache = array();
  16405. private $notifiablePackages = array();
  16406. private $loop;
  16407. private $io;
  16408. private $eventDispatcher;
  16409. private $outputProgress;
  16410. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  16411. {
  16412. $this->loop = $loop;
  16413. $this->io = $io;
  16414. $this->eventDispatcher = $eventDispatcher;
  16415. }
  16416. public function reset()
  16417. {
  16418. $this->notifiablePackages = array();
  16419. }
  16420. public function addInstaller(InstallerInterface $installer)
  16421. {
  16422. array_unshift($this->installers, $installer);
  16423. $this->cache = array();
  16424. }
  16425. public function removeInstaller(InstallerInterface $installer)
  16426. {
  16427. if (false !== ($key = array_search($installer, $this->installers, true))) {
  16428. array_splice($this->installers, $key, 1);
  16429. $this->cache = array();
  16430. }
  16431. }
  16432. public function disablePlugins()
  16433. {
  16434. foreach ($this->installers as $i => $installer) {
  16435. if (!$installer instanceof PluginInstaller) {
  16436. continue;
  16437. }
  16438. unset($this->installers[$i]);
  16439. }
  16440. }
  16441. public function getInstaller($type)
  16442. {
  16443. $type = strtolower($type);
  16444. if (isset($this->cache[$type])) {
  16445. return $this->cache[$type];
  16446. }
  16447. foreach ($this->installers as $installer) {
  16448. if ($installer->supports($type)) {
  16449. return $this->cache[$type] = $installer;
  16450. }
  16451. }
  16452. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  16453. }
  16454. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16455. {
  16456. if ($package instanceof AliasPackage) {
  16457. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  16458. }
  16459. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  16460. }
  16461. public function ensureBinariesPresence(PackageInterface $package)
  16462. {
  16463. try {
  16464. $installer = $this->getInstaller($package->getType());
  16465. } catch (\InvalidArgumentException $e) {
  16466. return;
  16467. }
  16468. if ($installer instanceof BinaryPresenceInterface) {
  16469. $installer->ensureBinariesPresence($package);
  16470. }
  16471. }
  16472. public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
  16473. {
  16474. $cleanupPromises = array();
  16475. $loop = $this->loop;
  16476. $runCleanup = function () use (&$cleanupPromises, $loop) {
  16477. $promises = array();
  16478. $loop->abortJobs();
  16479. foreach ($cleanupPromises as $cleanup) {
  16480. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup) {
  16481. $promise = $cleanup();
  16482. if (!$promise instanceof PromiseInterface) {
  16483. $resolve();
  16484. } else {
  16485. $promise->then(function () use ($resolve) {
  16486. $resolve();
  16487. });
  16488. }
  16489. });
  16490. }
  16491. if (!empty($promises)) {
  16492. $loop->wait($promises);
  16493. }
  16494. };
  16495. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  16496. $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler');
  16497. $prevHandler = null;
  16498. $windowsHandler = null;
  16499. if ($handleInterruptsUnix) {
  16500. pcntl_async_signals(true);
  16501. $prevHandler = pcntl_signal_get_handler(SIGINT);
  16502. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler) {
  16503. $runCleanup();
  16504. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  16505. call_user_func($prevHandler, $sig);
  16506. }
  16507. exit(130);
  16508. });
  16509. }
  16510. if ($handleInterruptsWindows) {
  16511. $windowsHandler = function () use ($runCleanup) {
  16512. $runCleanup();
  16513. exit(130);
  16514. };
  16515. sapi_windows_set_ctrl_handler($windowsHandler);
  16516. }
  16517. try {
  16518. $batches = array();
  16519. $batch = array();
  16520. foreach ($operations as $index => $operation) {
  16521. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16522. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16523. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  16524. if ($batch) {
  16525. $batches[] = $batch;
  16526. }
  16527. $batches[] = array($index => $operation);
  16528. $batch = array();
  16529. continue;
  16530. }
  16531. }
  16532. $batch[$index] = $operation;
  16533. }
  16534. if ($batch) {
  16535. $batches[] = $batch;
  16536. }
  16537. foreach ($batches as $batch) {
  16538. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  16539. }
  16540. } catch (\Exception $e) {
  16541. $runCleanup();
  16542. if ($handleInterruptsUnix) {
  16543. pcntl_signal(SIGINT, $prevHandler);
  16544. }
  16545. if ($handleInterruptsWindows) {
  16546. sapi_windows_set_ctrl_handler($prevHandler, false);
  16547. }
  16548. throw $e;
  16549. }
  16550. if ($handleInterruptsUnix) {
  16551. pcntl_signal(SIGINT, $prevHandler);
  16552. }
  16553. if ($handleInterruptsWindows) {
  16554. sapi_windows_set_ctrl_handler($prevHandler, false);
  16555. }
  16556. $repo->write($devMode, $this);
  16557. }
  16558. private function downloadAndExecuteBatch(RepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
  16559. {
  16560. $promises = array();
  16561. foreach ($operations as $index => $operation) {
  16562. $opType = $operation->getOperationType();
  16563. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16564. continue;
  16565. }
  16566. if ($opType === 'update') {
  16567. $package = $operation->getTargetPackage();
  16568. $initialPackage = $operation->getInitialPackage();
  16569. } else {
  16570. $package = $operation->getPackage();
  16571. $initialPackage = null;
  16572. }
  16573. $installer = $this->getInstaller($package->getType());
  16574. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  16575. if (!$package->getInstallationSource()) {
  16576. return;
  16577. }
  16578. return $installer->cleanup($opType, $package, $initialPackage);
  16579. };
  16580. if ($opType !== 'uninstall') {
  16581. $promise = $installer->download($package, $initialPackage);
  16582. if ($promise) {
  16583. $promises[] = $promise;
  16584. }
  16585. }
  16586. }
  16587. if (count($promises)) {
  16588. $this->waitOnPromises($promises);
  16589. }
  16590. $batches = array();
  16591. $batch = array();
  16592. foreach ($operations as $index => $operation) {
  16593. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16594. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16595. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  16596. if ($batch) {
  16597. $batches[] = $batch;
  16598. }
  16599. $batches[] = array($index => $operation);
  16600. $batch = array();
  16601. continue;
  16602. }
  16603. }
  16604. $batch[$index] = $operation;
  16605. }
  16606. if ($batch) {
  16607. $batches[] = $batch;
  16608. }
  16609. foreach ($batches as $batch) {
  16610. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  16611. }
  16612. }
  16613. private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
  16614. {
  16615. $promises = array();
  16616. $postExecCallbacks = array();
  16617. foreach ($operations as $index => $operation) {
  16618. $opType = $operation->getOperationType();
  16619. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16620. if ($this->io->isDebug()) {
  16621. $this->io->writeError(' - ' . $operation->show(false));
  16622. }
  16623. $this->$opType($repo, $operation);
  16624. continue;
  16625. }
  16626. if ($opType === 'update') {
  16627. $package = $operation->getTargetPackage();
  16628. $initialPackage = $operation->getInitialPackage();
  16629. } else {
  16630. $package = $operation->getPackage();
  16631. $initialPackage = null;
  16632. }
  16633. $installer = $this->getInstaller($package->getType());
  16634. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  16635. if (defined($event) && $runScripts && $this->eventDispatcher) {
  16636. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16637. }
  16638. $dispatcher = $this->eventDispatcher;
  16639. $installManager = $this;
  16640. $io = $this->io;
  16641. $promise = $installer->prepare($opType, $package, $initialPackage);
  16642. if (!$promise instanceof PromiseInterface) {
  16643. $promise = \React\Promise\resolve();
  16644. }
  16645. $promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
  16646. return $installManager->$opType($repo, $operation);
  16647. })->then($cleanupPromises[$index])
  16648. ->then(function () use ($installManager, $devMode, $repo) {
  16649. $repo->write($devMode, $installManager);
  16650. }, function ($e) use ($opType, $package, $io) {
  16651. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  16652. throw $e;
  16653. });
  16654. $postExecCallbacks[] = function () use ($opType, $runScripts, $dispatcher, $devMode, $repo, $allOperations, $operation) {
  16655. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  16656. if (defined($event) && $runScripts && $dispatcher) {
  16657. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16658. }
  16659. };
  16660. $promises[] = $promise;
  16661. }
  16662. if (count($promises)) {
  16663. $this->waitOnPromises($promises);
  16664. }
  16665. foreach ($postExecCallbacks as $cb) {
  16666. $cb();
  16667. }
  16668. }
  16669. private function waitOnPromises(array $promises)
  16670. {
  16671. $progress = null;
  16672. if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
  16673. $progress = $this->io->getProgressBar();
  16674. }
  16675. $this->loop->wait($promises, $progress);
  16676. if ($progress) {
  16677. $progress->clear();
  16678. }
  16679. }
  16680. public function install(RepositoryInterface $repo, InstallOperation $operation)
  16681. {
  16682. $package = $operation->getPackage();
  16683. $installer = $this->getInstaller($package->getType());
  16684. $promise = $installer->install($repo, $package);
  16685. $this->markForNotification($package);
  16686. return $promise;
  16687. }
  16688. public function update(RepositoryInterface $repo, UpdateOperation $operation)
  16689. {
  16690. $initial = $operation->getInitialPackage();
  16691. $target = $operation->getTargetPackage();
  16692. $initialType = $initial->getType();
  16693. $targetType = $target->getType();
  16694. if ($initialType === $targetType) {
  16695. $installer = $this->getInstaller($initialType);
  16696. $promise = $installer->update($repo, $initial, $target);
  16697. $this->markForNotification($target);
  16698. } else {
  16699. $this->getInstaller($initialType)->uninstall($repo, $initial);
  16700. $installer = $this->getInstaller($targetType);
  16701. $promise = $installer->install($repo, $target);
  16702. }
  16703. return $promise;
  16704. }
  16705. public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
  16706. {
  16707. $package = $operation->getPackage();
  16708. $installer = $this->getInstaller($package->getType());
  16709. return $installer->uninstall($repo, $package);
  16710. }
  16711. public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  16712. {
  16713. $package = $operation->getPackage();
  16714. if (!$repo->hasPackage($package)) {
  16715. $repo->addPackage(clone $package);
  16716. }
  16717. }
  16718. public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  16719. {
  16720. $package = $operation->getPackage();
  16721. $repo->removePackage($package);
  16722. }
  16723. public function getInstallPath(PackageInterface $package)
  16724. {
  16725. $installer = $this->getInstaller($package->getType());
  16726. return $installer->getInstallPath($package);
  16727. }
  16728. public function setOutputProgress($outputProgress)
  16729. {
  16730. $this->outputProgress = $outputProgress;
  16731. }
  16732. public function notifyInstalls(IOInterface $io)
  16733. {
  16734. $promises = array();
  16735. try {
  16736. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  16737. if (strpos($repoUrl, '%package%')) {
  16738. foreach ($packages as $package) {
  16739. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  16740. $params = array(
  16741. 'version' => $package->getPrettyVersion(),
  16742. 'version_normalized' => $package->getVersion(),
  16743. );
  16744. $opts = array(
  16745. 'retry-auth-failure' => false,
  16746. 'http' => array(
  16747. 'method' => 'POST',
  16748. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  16749. 'content' => http_build_query($params, '', '&'),
  16750. 'timeout' => 3,
  16751. ),
  16752. );
  16753. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  16754. }
  16755. continue;
  16756. }
  16757. $postData = array('downloads' => array());
  16758. foreach ($packages as $package) {
  16759. $postData['downloads'][] = array(
  16760. 'name' => $package->getPrettyName(),
  16761. 'version' => $package->getVersion(),
  16762. );
  16763. }
  16764. $opts = array(
  16765. 'retry-auth-failure' => false,
  16766. 'http' => array(
  16767. 'method' => 'POST',
  16768. 'header' => array('Content-Type: application/json'),
  16769. 'content' => json_encode($postData),
  16770. 'timeout' => 6,
  16771. ),
  16772. );
  16773. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  16774. }
  16775. $this->loop->wait($promises);
  16776. } catch (\Exception $e) {
  16777. }
  16778. $this->reset();
  16779. }
  16780. private function markForNotification(PackageInterface $package)
  16781. {
  16782. if ($package->getNotificationUrl()) {
  16783. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  16784. }
  16785. }
  16786. }
  16787. <?php
  16788. namespace Composer\Installer;
  16789. use Composer\Composer;
  16790. use Composer\DependencyResolver\PolicyInterface;
  16791. use Composer\DependencyResolver\Request;
  16792. use Composer\DependencyResolver\Pool;
  16793. use Composer\DependencyResolver\Transaction;
  16794. use Composer\EventDispatcher\Event;
  16795. use Composer\IO\IOInterface;
  16796. use Composer\Repository\RepositorySet;
  16797. class InstallerEvent extends Event
  16798. {
  16799. private $composer;
  16800. private $io;
  16801. private $devMode;
  16802. private $executeOperations;
  16803. private $transaction;
  16804. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
  16805. {
  16806. parent::__construct($eventName);
  16807. $this->composer = $composer;
  16808. $this->io = $io;
  16809. $this->devMode = $devMode;
  16810. $this->executeOperations = $executeOperations;
  16811. $this->transaction = $transaction;
  16812. }
  16813. public function getComposer()
  16814. {
  16815. return $this->composer;
  16816. }
  16817. public function getIO()
  16818. {
  16819. return $this->io;
  16820. }
  16821. public function isDevMode()
  16822. {
  16823. return $this->devMode;
  16824. }
  16825. public function isExecutingOperations()
  16826. {
  16827. return $this->executeOperations;
  16828. }
  16829. public function getTransaction()
  16830. {
  16831. return $this->transaction;
  16832. }
  16833. }
  16834. <?php
  16835. namespace Composer\Installer;
  16836. class InstallerEvents
  16837. {
  16838. const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  16839. }
  16840. <?php
  16841. namespace Composer\Installer;
  16842. use Composer\Package\PackageInterface;
  16843. use Composer\Repository\InstalledRepositoryInterface;
  16844. use InvalidArgumentException;
  16845. use React\Promise\PromiseInterface;
  16846. interface InstallerInterface
  16847. {
  16848. public function supports($packageType);
  16849. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  16850. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  16851. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
  16852. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  16853. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  16854. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  16855. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
  16856. public function getInstallPath(PackageInterface $package);
  16857. }
  16858. <?php
  16859. namespace Composer\Installer;
  16860. use Composer\Composer;
  16861. use Composer\IO\IOInterface;
  16862. use Composer\Repository\InstalledRepositoryInterface;
  16863. use Composer\Package\PackageInterface;
  16864. use Composer\Util\Filesystem;
  16865. use Composer\Util\Silencer;
  16866. use Composer\Util\Platform;
  16867. use React\Promise\PromiseInterface;
  16868. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  16869. {
  16870. protected $composer;
  16871. protected $vendorDir;
  16872. protected $binDir;
  16873. protected $downloadManager;
  16874. protected $io;
  16875. protected $type;
  16876. protected $filesystem;
  16877. protected $binCompat;
  16878. protected $binaryInstaller;
  16879. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  16880. {
  16881. $this->composer = $composer;
  16882. $this->downloadManager = $composer->getDownloadManager();
  16883. $this->io = $io;
  16884. $this->type = $type;
  16885. $this->filesystem = $filesystem ?: new Filesystem();
  16886. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  16887. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
  16888. }
  16889. public function supports($packageType)
  16890. {
  16891. return $packageType === $this->type || null === $this->type;
  16892. }
  16893. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16894. {
  16895. if (!$repo->hasPackage($package)) {
  16896. return false;
  16897. }
  16898. $installPath = $this->getInstallPath($package);
  16899. if (is_readable($installPath)) {
  16900. return true;
  16901. }
  16902. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  16903. }
  16904. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  16905. {
  16906. $this->initializeVendorDir();
  16907. $downloadPath = $this->getInstallPath($package);
  16908. return $this->downloadManager->download($package, $downloadPath, $prevPackage);
  16909. }
  16910. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16911. {
  16912. $this->initializeVendorDir();
  16913. $downloadPath = $this->getInstallPath($package);
  16914. return $this->downloadManager->prepare($type, $package, $downloadPath, $prevPackage);
  16915. }
  16916. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16917. {
  16918. $this->initializeVendorDir();
  16919. $downloadPath = $this->getInstallPath($package);
  16920. return $this->downloadManager->cleanup($type, $package, $downloadPath, $prevPackage);
  16921. }
  16922. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  16923. {
  16924. $this->initializeVendorDir();
  16925. $downloadPath = $this->getInstallPath($package);
  16926. if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
  16927. $this->binaryInstaller->removeBinaries($package);
  16928. }
  16929. $promise = $this->installCode($package);
  16930. if (!$promise instanceof PromiseInterface) {
  16931. $promise = \React\Promise\resolve();
  16932. }
  16933. $binaryInstaller = $this->binaryInstaller;
  16934. $installPath = $this->getInstallPath($package);
  16935. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
  16936. $binaryInstaller->installBinaries($package, $installPath);
  16937. if (!$repo->hasPackage($package)) {
  16938. $repo->addPackage(clone $package);
  16939. }
  16940. });
  16941. }
  16942. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  16943. {
  16944. if (!$repo->hasPackage($initial)) {
  16945. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  16946. }
  16947. $this->initializeVendorDir();
  16948. $this->binaryInstaller->removeBinaries($initial);
  16949. $promise = $this->updateCode($initial, $target);
  16950. if (!$promise instanceof PromiseInterface) {
  16951. $promise = \React\Promise\resolve();
  16952. }
  16953. $binaryInstaller = $this->binaryInstaller;
  16954. $installPath = $this->getInstallPath($target);
  16955. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
  16956. $binaryInstaller->installBinaries($target, $installPath);
  16957. $repo->removePackage($initial);
  16958. if (!$repo->hasPackage($target)) {
  16959. $repo->addPackage(clone $target);
  16960. }
  16961. });
  16962. }
  16963. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  16964. {
  16965. if (!$repo->hasPackage($package)) {
  16966. throw new \InvalidArgumentException('Package is not installed: '.$package);
  16967. }
  16968. $promise = $this->removeCode($package);
  16969. if (!$promise instanceof PromiseInterface) {
  16970. $promise = \React\Promise\resolve();
  16971. }
  16972. $binaryInstaller = $this->binaryInstaller;
  16973. $downloadPath = $this->getPackageBasePath($package);
  16974. $filesystem = $this->filesystem;
  16975. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
  16976. $binaryInstaller->removeBinaries($package);
  16977. $repo->removePackage($package);
  16978. if (strpos($package->getName(), '/')) {
  16979. $packageVendorDir = dirname($downloadPath);
  16980. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  16981. Silencer::call('rmdir', $packageVendorDir);
  16982. }
  16983. }
  16984. });
  16985. }
  16986. public function getInstallPath(PackageInterface $package)
  16987. {
  16988. $this->initializeVendorDir();
  16989. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  16990. $targetDir = $package->getTargetDir();
  16991. return $basePath . ($targetDir ? '/'.$targetDir : '');
  16992. }
  16993. public function ensureBinariesPresence(PackageInterface $package)
  16994. {
  16995. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  16996. }
  16997. protected function getPackageBasePath(PackageInterface $package)
  16998. {
  16999. $installPath = $this->getInstallPath($package);
  17000. $targetDir = $package->getTargetDir();
  17001. if ($targetDir) {
  17002. return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  17003. }
  17004. return $installPath;
  17005. }
  17006. protected function installCode(PackageInterface $package)
  17007. {
  17008. $downloadPath = $this->getInstallPath($package);
  17009. return $this->downloadManager->install($package, $downloadPath);
  17010. }
  17011. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  17012. {
  17013. $initialDownloadPath = $this->getInstallPath($initial);
  17014. $targetDownloadPath = $this->getInstallPath($target);
  17015. if ($targetDownloadPath !== $initialDownloadPath) {
  17016. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  17017. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  17018. ) {
  17019. $promise = $this->removeCode($initial);
  17020. if (!$promise instanceof PromiseInterface) {
  17021. $promise = \React\Promise\resolve();
  17022. }
  17023. $self = $this;
  17024. return $promise->then(function () use ($self, $target) {
  17025. $reflMethod = new \ReflectionMethod($self, 'installCode');
  17026. $reflMethod->setAccessible(true);
  17027. return $reflMethod->invoke($self, $target);
  17028. });
  17029. }
  17030. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  17031. }
  17032. return $this->downloadManager->update($initial, $target, $targetDownloadPath);
  17033. }
  17034. protected function removeCode(PackageInterface $package)
  17035. {
  17036. $downloadPath = $this->getPackageBasePath($package);
  17037. return $this->downloadManager->remove($package, $downloadPath);
  17038. }
  17039. protected function initializeVendorDir()
  17040. {
  17041. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  17042. $this->vendorDir = realpath($this->vendorDir);
  17043. }
  17044. }
  17045. <?php
  17046. namespace Composer\Installer;
  17047. use Composer\Repository\InstalledRepositoryInterface;
  17048. use Composer\Package\PackageInterface;
  17049. use Composer\Package\Version\VersionParser;
  17050. use Composer\IO\IOInterface;
  17051. use Composer\DependencyResolver\Operation\UpdateOperation;
  17052. use Composer\DependencyResolver\Operation\InstallOperation;
  17053. use Composer\DependencyResolver\Operation\UninstallOperation;
  17054. class MetapackageInstaller implements InstallerInterface
  17055. {
  17056. private $io;
  17057. public function __construct(IOInterface $io)
  17058. {
  17059. $this->io = $io;
  17060. }
  17061. public function supports($packageType)
  17062. {
  17063. return $packageType === 'metapackage';
  17064. }
  17065. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17066. {
  17067. return $repo->hasPackage($package);
  17068. }
  17069. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17070. {
  17071. }
  17072. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17073. {
  17074. }
  17075. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17076. {
  17077. }
  17078. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17079. {
  17080. $this->io->writeError(" - " . InstallOperation::format($package));
  17081. $repo->addPackage(clone $package);
  17082. }
  17083. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17084. {
  17085. if (!$repo->hasPackage($initial)) {
  17086. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17087. }
  17088. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  17089. $repo->removePackage($initial);
  17090. $repo->addPackage(clone $target);
  17091. }
  17092. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17093. {
  17094. if (!$repo->hasPackage($package)) {
  17095. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17096. }
  17097. $this->io->writeError(" - " . UninstallOperation::format($package));
  17098. $repo->removePackage($package);
  17099. }
  17100. public function getInstallPath(PackageInterface $package)
  17101. {
  17102. return '';
  17103. }
  17104. }
  17105. <?php
  17106. namespace Composer\Installer;
  17107. use Composer\Repository\InstalledRepositoryInterface;
  17108. use Composer\Package\PackageInterface;
  17109. class NoopInstaller implements InstallerInterface
  17110. {
  17111. public function supports($packageType)
  17112. {
  17113. return true;
  17114. }
  17115. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17116. {
  17117. return $repo->hasPackage($package);
  17118. }
  17119. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17120. {
  17121. }
  17122. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17123. {
  17124. }
  17125. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17126. {
  17127. }
  17128. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17129. {
  17130. if (!$repo->hasPackage($package)) {
  17131. $repo->addPackage(clone $package);
  17132. }
  17133. }
  17134. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17135. {
  17136. if (!$repo->hasPackage($initial)) {
  17137. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17138. }
  17139. $repo->removePackage($initial);
  17140. if (!$repo->hasPackage($target)) {
  17141. $repo->addPackage(clone $target);
  17142. }
  17143. }
  17144. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17145. {
  17146. if (!$repo->hasPackage($package)) {
  17147. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17148. }
  17149. $repo->removePackage($package);
  17150. }
  17151. public function getInstallPath(PackageInterface $package)
  17152. {
  17153. $targetDir = $package->getTargetDir();
  17154. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  17155. }
  17156. }
  17157. <?php
  17158. namespace Composer\Installer;
  17159. use Composer\Composer;
  17160. use Composer\IO\IOInterface;
  17161. use Composer\DependencyResolver\Operation\OperationInterface;
  17162. use Composer\DependencyResolver\PolicyInterface;
  17163. use Composer\DependencyResolver\Request;
  17164. use Composer\Repository\RepositoryInterface;
  17165. use Composer\Repository\RepositorySet;
  17166. use Composer\EventDispatcher\Event;
  17167. class PackageEvent extends Event
  17168. {
  17169. private $composer;
  17170. private $io;
  17171. private $devMode;
  17172. private $localRepo;
  17173. private $operations;
  17174. private $operation;
  17175. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  17176. {
  17177. parent::__construct($eventName);
  17178. $this->composer = $composer;
  17179. $this->io = $io;
  17180. $this->devMode = $devMode;
  17181. $this->localRepo = $localRepo;
  17182. $this->operations = $operations;
  17183. $this->operation = $operation;
  17184. }
  17185. public function getComposer()
  17186. {
  17187. return $this->composer;
  17188. }
  17189. public function getIO()
  17190. {
  17191. return $this->io;
  17192. }
  17193. public function isDevMode()
  17194. {
  17195. return $this->devMode;
  17196. }
  17197. public function getLocalRepo()
  17198. {
  17199. return $this->localRepo;
  17200. }
  17201. public function getOperations()
  17202. {
  17203. return $this->operations;
  17204. }
  17205. public function getOperation()
  17206. {
  17207. return $this->operation;
  17208. }
  17209. }
  17210. <?php
  17211. namespace Composer\Installer;
  17212. class PackageEvents
  17213. {
  17214. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  17215. const POST_PACKAGE_INSTALL = 'post-package-install';
  17216. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  17217. const POST_PACKAGE_UPDATE = 'post-package-update';
  17218. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  17219. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  17220. }
  17221. <?php
  17222. namespace Composer\Installer;
  17223. use Composer\Composer;
  17224. use Composer\IO\IOInterface;
  17225. use Composer\Repository\InstalledRepositoryInterface;
  17226. use Composer\Package\PackageInterface;
  17227. use Composer\Util\Filesystem;
  17228. use React\Promise\PromiseInterface;
  17229. class PluginInstaller extends LibraryInstaller
  17230. {
  17231. public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  17232. {
  17233. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  17234. }
  17235. public function supports($packageType)
  17236. {
  17237. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  17238. }
  17239. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17240. {
  17241. $extra = $package->getExtra();
  17242. if (empty($extra['class'])) {
  17243. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  17244. }
  17245. return parent::download($package, $prevPackage);
  17246. }
  17247. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17248. {
  17249. $promise = parent::install($repo, $package);
  17250. if (!$promise instanceof PromiseInterface) {
  17251. $promise = \React\Promise\resolve();
  17252. }
  17253. $pluginManager = $this->composer->getPluginManager();
  17254. $self = $this;
  17255. return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
  17256. try {
  17257. $pluginManager->registerPackage($package, true);
  17258. } catch (\Exception $e) {
  17259. $self->rollbackInstall($e, $repo, $package);
  17260. }
  17261. });
  17262. }
  17263. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17264. {
  17265. $promise = parent::update($repo, $initial, $target);
  17266. if (!$promise instanceof PromiseInterface) {
  17267. $promise = \React\Promise\resolve();
  17268. }
  17269. $pluginManager = $this->composer->getPluginManager();
  17270. $self = $this;
  17271. return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
  17272. try {
  17273. $pluginManager->deactivatePackage($initial, true);
  17274. $pluginManager->registerPackage($target, true);
  17275. } catch (\Exception $e) {
  17276. $self->rollbackInstall($e, $repo, $target);
  17277. }
  17278. });
  17279. }
  17280. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17281. {
  17282. $this->composer->getPluginManager()->uninstallPackage($package, true);
  17283. return parent::uninstall($repo, $package);
  17284. }
  17285. public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
  17286. {
  17287. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  17288. parent::uninstall($repo, $package);
  17289. throw $e;
  17290. }
  17291. }
  17292. <?php
  17293. namespace Composer\Installer;
  17294. use Composer\Package\PackageInterface;
  17295. use Composer\Downloader\DownloadManager;
  17296. use Composer\Repository\InstalledRepositoryInterface;
  17297. use Composer\Util\Filesystem;
  17298. class ProjectInstaller implements InstallerInterface
  17299. {
  17300. private $installPath;
  17301. private $downloadManager;
  17302. private $filesystem;
  17303. public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
  17304. {
  17305. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  17306. $this->downloadManager = $dm;
  17307. $this->filesystem = $fs;
  17308. }
  17309. public function supports($packageType)
  17310. {
  17311. return true;
  17312. }
  17313. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17314. {
  17315. return false;
  17316. }
  17317. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17318. {
  17319. $installPath = $this->installPath;
  17320. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  17321. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  17322. }
  17323. if (!is_dir($installPath)) {
  17324. mkdir($installPath, 0777, true);
  17325. }
  17326. return $this->downloadManager->download($package, $installPath, $prevPackage);
  17327. }
  17328. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17329. {
  17330. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  17331. }
  17332. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17333. {
  17334. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  17335. }
  17336. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17337. {
  17338. return $this->downloadManager->install($package, $this->installPath);
  17339. }
  17340. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17341. {
  17342. throw new \InvalidArgumentException("not supported");
  17343. }
  17344. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17345. {
  17346. throw new \InvalidArgumentException("not supported");
  17347. }
  17348. public function getInstallPath(PackageInterface $package)
  17349. {
  17350. return $this->installPath;
  17351. }
  17352. }
  17353. <?php
  17354. namespace Composer\Installer;
  17355. use Composer\IO\IOInterface;
  17356. use Composer\Package\PackageInterface;
  17357. use Composer\Repository\InstalledRepository;
  17358. use Symfony\Component\Console\Formatter\OutputFormatter;
  17359. class SuggestedPackagesReporter
  17360. {
  17361. const MODE_LIST = 1;
  17362. const MODE_BY_PACKAGE = 2;
  17363. const MODE_BY_SUGGESTION = 4;
  17364. protected $suggestedPackages = array();
  17365. private $io;
  17366. public function __construct(IOInterface $io)
  17367. {
  17368. $this->io = $io;
  17369. }
  17370. public function getPackages()
  17371. {
  17372. return $this->suggestedPackages;
  17373. }
  17374. public function addPackage($source, $target, $reason)
  17375. {
  17376. $this->suggestedPackages[] = array(
  17377. 'source' => $source,
  17378. 'target' => $target,
  17379. 'reason' => $reason,
  17380. );
  17381. return $this;
  17382. }
  17383. public function addSuggestionsFromPackage(PackageInterface $package)
  17384. {
  17385. $source = $package->getPrettyName();
  17386. foreach ($package->getSuggests() as $target => $reason) {
  17387. $this->addPackage(
  17388. $source,
  17389. $target,
  17390. $reason
  17391. );
  17392. }
  17393. return $this;
  17394. }
  17395. public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17396. {
  17397. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17398. $suggesters = array();
  17399. $suggested = array();
  17400. foreach ($suggestedPackages as $suggestion) {
  17401. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  17402. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  17403. }
  17404. ksort($suggesters);
  17405. ksort($suggested);
  17406. if ($mode & self::MODE_LIST) {
  17407. foreach (array_keys($suggested) as $name) {
  17408. $this->io->write(sprintf('<info>%s</info>', $name));
  17409. }
  17410. return 0;
  17411. }
  17412. if ($mode & self::MODE_BY_PACKAGE) {
  17413. foreach ($suggesters as $suggester => $suggestions) {
  17414. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  17415. foreach ($suggestions as $suggestion => $reason) {
  17416. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  17417. }
  17418. $this->io->write('');
  17419. }
  17420. }
  17421. if ($mode & self::MODE_BY_SUGGESTION) {
  17422. if ($mode & self::MODE_BY_PACKAGE) {
  17423. $this->io->write(str_repeat('-', 78));
  17424. }
  17425. foreach ($suggested as $suggestion => $suggesters) {
  17426. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  17427. foreach ($suggesters as $suggester => $reason) {
  17428. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  17429. }
  17430. $this->io->write('');
  17431. }
  17432. }
  17433. if ($onlyDependentsOf) {
  17434. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  17435. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  17436. if ($diff) {
  17437. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  17438. }
  17439. }
  17440. return $this;
  17441. }
  17442. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17443. {
  17444. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17445. if ($suggestedPackages) {
  17446. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  17447. }
  17448. return $this;
  17449. }
  17450. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17451. {
  17452. $suggestedPackages = $this->getPackages();
  17453. $installedNames = array();
  17454. if (null !== $installedRepo && !empty($suggestedPackages)) {
  17455. foreach ($installedRepo->getPackages() as $package) {
  17456. $installedNames = array_merge(
  17457. $installedNames,
  17458. $package->getNames()
  17459. );
  17460. }
  17461. }
  17462. $sourceFilter = array();
  17463. if ($onlyDependentsOf) {
  17464. $sourceFilter = array_map(function ($link) {
  17465. return $link->getTarget();
  17466. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  17467. $sourceFilter[] = $onlyDependentsOf->getName();
  17468. }
  17469. $suggestions = array();
  17470. foreach ($suggestedPackages as $suggestion) {
  17471. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  17472. continue;
  17473. }
  17474. $suggestions[] = $suggestion;
  17475. }
  17476. return $suggestions;
  17477. }
  17478. private function escapeOutput($string)
  17479. {
  17480. return OutputFormatter::escape(
  17481. $this->removeControlCharacters($string)
  17482. );
  17483. }
  17484. private function removeControlCharacters($string)
  17485. {
  17486. return preg_replace(
  17487. '/[[:cntrl:]]/',
  17488. '',
  17489. str_replace("\n", ' ', $string)
  17490. );
  17491. }
  17492. }
  17493. <?php
  17494. namespace Composer\Json;
  17495. use JsonSchema\Validator;
  17496. use Seld\JsonLint\JsonParser;
  17497. use Seld\JsonLint\ParsingException;
  17498. use Composer\Util\HttpDownloader;
  17499. use Composer\IO\IOInterface;
  17500. use Composer\Downloader\TransportException;
  17501. class JsonFile
  17502. {
  17503. const LAX_SCHEMA = 1;
  17504. const STRICT_SCHEMA = 2;
  17505. const JSON_UNESCAPED_SLASHES = 64;
  17506. const JSON_PRETTY_PRINT = 128;
  17507. const JSON_UNESCAPED_UNICODE = 256;
  17508. const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
  17509. private $path;
  17510. private $httpDownloader;
  17511. private $io;
  17512. public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  17513. {
  17514. $this->path = $path;
  17515. if (null === $httpDownloader && preg_match('{^https?://}i', $path)) {
  17516. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  17517. }
  17518. $this->httpDownloader = $httpDownloader;
  17519. $this->io = $io;
  17520. }
  17521. public function getPath()
  17522. {
  17523. return $this->path;
  17524. }
  17525. public function exists()
  17526. {
  17527. return is_file($this->path);
  17528. }
  17529. public function read()
  17530. {
  17531. try {
  17532. if ($this->httpDownloader) {
  17533. $json = $this->httpDownloader->get($this->path)->getBody();
  17534. } else {
  17535. if ($this->io && $this->io->isDebug()) {
  17536. $this->io->writeError('Reading ' . $this->path);
  17537. }
  17538. $json = file_get_contents($this->path);
  17539. }
  17540. } catch (TransportException $e) {
  17541. throw new \RuntimeException($e->getMessage(), 0, $e);
  17542. } catch (\Exception $e) {
  17543. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  17544. }
  17545. return static::parseJson($json, $this->path);
  17546. }
  17547. public function write(array $hash, $options = 448)
  17548. {
  17549. if ($this->path === 'php://memory') {
  17550. file_put_contents($this->path, static::encode($hash, $options));
  17551. return;
  17552. }
  17553. $dir = dirname($this->path);
  17554. if (!is_dir($dir)) {
  17555. if (file_exists($dir)) {
  17556. throw new \UnexpectedValueException(
  17557. realpath($dir).' exists and is not a directory.'
  17558. );
  17559. }
  17560. if (!@mkdir($dir, 0777, true)) {
  17561. throw new \UnexpectedValueException(
  17562. $dir.' does not exist and could not be created.'
  17563. );
  17564. }
  17565. }
  17566. $retries = 3;
  17567. while ($retries--) {
  17568. try {
  17569. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  17570. break;
  17571. } catch (\Exception $e) {
  17572. if ($retries) {
  17573. usleep(500000);
  17574. continue;
  17575. }
  17576. throw $e;
  17577. }
  17578. }
  17579. }
  17580. private function filePutContentsIfModified($path, $content)
  17581. {
  17582. $currentContent = @file_get_contents($path);
  17583. if (!$currentContent || ($currentContent != $content)) {
  17584. return file_put_contents($path, $content);
  17585. }
  17586. return 0;
  17587. }
  17588. public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
  17589. {
  17590. $content = file_get_contents($this->path);
  17591. $data = json_decode($content);
  17592. if (null === $data && 'null' !== $content) {
  17593. self::validateSyntax($content, $this->path);
  17594. }
  17595. if (null === $schemaFile) {
  17596. $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
  17597. }
  17598. if (false === strpos($schemaFile, '://')) {
  17599. $schemaFile = 'file://' . $schemaFile;
  17600. }
  17601. $schemaData = (object) array('$ref' => $schemaFile);
  17602. if ($schema === self::LAX_SCHEMA) {
  17603. $schemaData->additionalProperties = true;
  17604. $schemaData->required = array();
  17605. }
  17606. $validator = new Validator();
  17607. $validator->check($data, $schemaData);
  17608. if (!$validator->isValid()) {
  17609. $errors = array();
  17610. foreach ((array) $validator->getErrors() as $error) {
  17611. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  17612. }
  17613. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  17614. }
  17615. return true;
  17616. }
  17617. public static function encode($data, $options = 448)
  17618. {
  17619. if (PHP_VERSION_ID >= 50400) {
  17620. $json = json_encode($data, $options);
  17621. if (false === $json) {
  17622. self::throwEncodeError(json_last_error());
  17623. }
  17624. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  17625. $json = preg_replace('/\[\s+\]/', '[]', $json);
  17626. $json = preg_replace('/\{\s+\}/', '{}', $json);
  17627. }
  17628. return $json;
  17629. }
  17630. $json = json_encode($data);
  17631. if (false === $json) {
  17632. self::throwEncodeError(json_last_error());
  17633. }
  17634. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  17635. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  17636. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  17637. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  17638. return $json;
  17639. }
  17640. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  17641. }
  17642. private static function throwEncodeError($code)
  17643. {
  17644. switch ($code) {
  17645. case JSON_ERROR_DEPTH:
  17646. $msg = 'Maximum stack depth exceeded';
  17647. break;
  17648. case JSON_ERROR_STATE_MISMATCH:
  17649. $msg = 'Underflow or the modes mismatch';
  17650. break;
  17651. case JSON_ERROR_CTRL_CHAR:
  17652. $msg = 'Unexpected control character found';
  17653. break;
  17654. case JSON_ERROR_UTF8:
  17655. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  17656. break;
  17657. default:
  17658. $msg = 'Unknown error';
  17659. }
  17660. throw new \RuntimeException('JSON encoding failed: '.$msg);
  17661. }
  17662. public static function parseJson($json, $file = null)
  17663. {
  17664. if (null === $json) {
  17665. return;
  17666. }
  17667. $data = json_decode($json, true);
  17668. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  17669. self::validateSyntax($json, $file);
  17670. }
  17671. return $data;
  17672. }
  17673. protected static function validateSyntax($json, $file = null)
  17674. {
  17675. $parser = new JsonParser();
  17676. $result = $parser->lint($json);
  17677. if (null === $result) {
  17678. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  17679. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  17680. }
  17681. return true;
  17682. }
  17683. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  17684. }
  17685. }
  17686. <?php
  17687. namespace Composer\Json;
  17688. class JsonFormatter
  17689. {
  17690. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  17691. {
  17692. $result = '';
  17693. $pos = 0;
  17694. $strLen = strlen($json);
  17695. $indentStr = ' ';
  17696. $newLine = "\n";
  17697. $outOfQuotes = true;
  17698. $buffer = '';
  17699. $noescape = true;
  17700. for ($i = 0; $i < $strLen; $i++) {
  17701. $char = substr($json, $i, 1);
  17702. if ('"' === $char && $noescape) {
  17703. $outOfQuotes = !$outOfQuotes;
  17704. }
  17705. if (!$outOfQuotes) {
  17706. $buffer .= $char;
  17707. $noescape = '\\' === $char ? !$noescape : true;
  17708. continue;
  17709. }
  17710. if ('' !== $buffer) {
  17711. if ($unescapeSlashes) {
  17712. $buffer = str_replace('\\/', '/', $buffer);
  17713. }
  17714. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  17715. $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  17716. $l = strlen($match[1]);
  17717. if ($l % 2) {
  17718. $code = hexdec($match[2]);
  17719. if (0xD800 <= $code && 0xDFFF >= $code) {
  17720. return $match[0];
  17721. }
  17722. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  17723. pack('H*', $match[2]),
  17724. 'UTF-8',
  17725. 'UCS-2BE'
  17726. );
  17727. }
  17728. return $match[0];
  17729. }, $buffer);
  17730. }
  17731. $result .= $buffer.$char;
  17732. $buffer = '';
  17733. continue;
  17734. }
  17735. if (':' === $char) {
  17736. $char .= ' ';
  17737. } elseif ('}' === $char || ']' === $char) {
  17738. $pos--;
  17739. $prevChar = substr($json, $i - 1, 1);
  17740. if ('{' !== $prevChar && '[' !== $prevChar) {
  17741. $result .= $newLine;
  17742. for ($j = 0; $j < $pos; $j++) {
  17743. $result .= $indentStr;
  17744. }
  17745. } else {
  17746. $result = rtrim($result);
  17747. }
  17748. }
  17749. $result .= $char;
  17750. if (',' === $char || '{' === $char || '[' === $char) {
  17751. $result .= $newLine;
  17752. if ('{' === $char || '[' === $char) {
  17753. $pos++;
  17754. }
  17755. for ($j = 0; $j < $pos; $j++) {
  17756. $result .= $indentStr;
  17757. }
  17758. }
  17759. }
  17760. return $result;
  17761. }
  17762. }
  17763. <?php
  17764. namespace Composer\Json;
  17765. use Composer\Repository\PlatformRepository;
  17766. class JsonManipulator
  17767. {
  17768. private static $DEFINES = '(?(DEFINE)
  17769. (?<number> -? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)? )
  17770. (?<boolean> true | false | null )
  17771. (?<string> " ([^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  17772. (?<array> \[ (?: (?&json) \s* (?: , (?&json) \s* )* )? \s* \] )
  17773. (?<pair> \s* (?&string) \s* : (?&json) \s* )
  17774. (?<object> \{ (?: (?&pair) (?: , (?&pair) )* )? \s* \} )
  17775. (?<json> \s* (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  17776. )';
  17777. private $contents;
  17778. private $newline;
  17779. private $indent;
  17780. public function __construct($contents)
  17781. {
  17782. $contents = trim($contents);
  17783. if ($contents === '') {
  17784. $contents = '{}';
  17785. }
  17786. if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
  17787. throw new \InvalidArgumentException('The json file must be an object ({})');
  17788. }
  17789. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  17790. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  17791. $this->detectIndenting();
  17792. }
  17793. public function getContents()
  17794. {
  17795. return $this->contents . $this->newline;
  17796. }
  17797. public function addLink($type, $package, $constraint, $sortPackages = false)
  17798. {
  17799. $decoded = JsonFile::parseJson($this->contents);
  17800. if (!isset($decoded[$type])) {
  17801. return $this->addMainKey($type, array($package => $constraint));
  17802. }
  17803. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  17804. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  17805. if (!$this->pregMatch($regex, $this->contents, $matches)) {
  17806. return false;
  17807. }
  17808. $links = $matches['value'];
  17809. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  17810. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  17811. if ($this->pregMatch($regex, $links, $packageMatches)) {
  17812. $existingPackage = $packageMatches['package'];
  17813. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  17814. $links = preg_replace_callback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  17815. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  17816. }, $links);
  17817. } else {
  17818. if ($this->pregMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  17819. $links = preg_replace(
  17820. '{'.preg_quote($match[1]).'$}',
  17821. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  17822. $links
  17823. );
  17824. } else {
  17825. $links = '{' . $this->newline .
  17826. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  17827. $this->indent . '}';
  17828. }
  17829. }
  17830. if (true === $sortPackages) {
  17831. $requirements = json_decode($links, true);
  17832. $this->sortPackages($requirements);
  17833. $links = $this->format($requirements);
  17834. }
  17835. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  17836. return true;
  17837. }
  17838. private function sortPackages(array &$packages = array())
  17839. {
  17840. $prefix = function ($requirement) {
  17841. if (PlatformRepository::isPlatformPackage($requirement)) {
  17842. return preg_replace(
  17843. array(
  17844. '/^php/',
  17845. '/^hhvm/',
  17846. '/^ext/',
  17847. '/^lib/',
  17848. '/^\D/',
  17849. ),
  17850. array(
  17851. '0-$0',
  17852. '1-$0',
  17853. '2-$0',
  17854. '3-$0',
  17855. '4-$0',
  17856. ),
  17857. $requirement
  17858. );
  17859. }
  17860. return '5-'.$requirement;
  17861. };
  17862. uksort($packages, function ($a, $b) use ($prefix) {
  17863. return strnatcmp($prefix($a), $prefix($b));
  17864. });
  17865. }
  17866. public function addRepository($name, $config, $append = true)
  17867. {
  17868. return $this->addSubNode('repositories', $name, $config, $append);
  17869. }
  17870. public function removeRepository($name)
  17871. {
  17872. return $this->removeSubNode('repositories', $name);
  17873. }
  17874. public function addConfigSetting($name, $value)
  17875. {
  17876. return $this->addSubNode('config', $name, $value);
  17877. }
  17878. public function removeConfigSetting($name)
  17879. {
  17880. return $this->removeSubNode('config', $name);
  17881. }
  17882. public function addProperty($name, $value)
  17883. {
  17884. if (strpos($name, 'suggest.') === 0) {
  17885. return $this->addSubNode('suggest', substr($name, 8), $value);
  17886. }
  17887. if (strpos($name, 'extra.') === 0) {
  17888. return $this->addSubNode('extra', substr($name, 6), $value);
  17889. }
  17890. if (strpos($name, 'scripts.') === 0) {
  17891. return $this->addSubNode('scripts', substr($name, 8), $value);
  17892. }
  17893. return $this->addMainKey($name, $value);
  17894. }
  17895. public function removeProperty($name)
  17896. {
  17897. if (strpos($name, 'suggest.') === 0) {
  17898. return $this->removeSubNode('suggest', substr($name, 8));
  17899. }
  17900. if (strpos($name, 'extra.') === 0) {
  17901. return $this->removeSubNode('extra', substr($name, 6));
  17902. }
  17903. if (strpos($name, 'scripts.') === 0) {
  17904. return $this->removeSubNode('scripts', substr($name, 8));
  17905. }
  17906. return $this->removeMainKey($name);
  17907. }
  17908. public function addSubNode($mainNode, $name, $value, $append = true)
  17909. {
  17910. $decoded = JsonFile::parseJson($this->contents);
  17911. $subName = null;
  17912. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  17913. list($name, $subName) = explode('.', $name, 2);
  17914. }
  17915. if (!isset($decoded[$mainNode])) {
  17916. if ($subName !== null) {
  17917. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  17918. } else {
  17919. $this->addMainKey($mainNode, array($name => $value));
  17920. }
  17921. return true;
  17922. }
  17923. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  17924. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  17925. try {
  17926. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  17927. return false;
  17928. }
  17929. } catch (\RuntimeException $e) {
  17930. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  17931. return false;
  17932. }
  17933. throw $e;
  17934. }
  17935. $children = $match['content'];
  17936. if (!@json_decode($children)) {
  17937. return false;
  17938. }
  17939. $that = $this;
  17940. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  17941. if ($this->pregMatch($childRegex, $children, $matches)) {
  17942. $children = preg_replace_callback($childRegex, function ($matches) use ($subName, $value, $that) {
  17943. if ($subName !== null) {
  17944. $curVal = json_decode($matches['content'], true);
  17945. if (!is_array($curVal)) {
  17946. $curVal = array();
  17947. }
  17948. $curVal[$subName] = $value;
  17949. $value = $curVal;
  17950. }
  17951. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  17952. }, $children);
  17953. } else {
  17954. $this->pregMatch('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  17955. $whitespace = '';
  17956. if (!empty($match['trailingspace'])) {
  17957. $whitespace = $match['trailingspace'];
  17958. }
  17959. if (!empty($match['content'])) {
  17960. if ($subName !== null) {
  17961. $value = array($subName => $value);
  17962. }
  17963. if ($append) {
  17964. $children = preg_replace(
  17965. '#'.$whitespace.'}$#',
  17966. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  17967. $children
  17968. );
  17969. } else {
  17970. $whitespace = '';
  17971. if (!empty($match['leadingspace'])) {
  17972. $whitespace = $match['leadingspace'];
  17973. }
  17974. $children = preg_replace(
  17975. '#^{'.$whitespace.'#',
  17976. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  17977. $children
  17978. );
  17979. }
  17980. } else {
  17981. if ($subName !== null) {
  17982. $value = array($subName => $value);
  17983. }
  17984. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  17985. }
  17986. }
  17987. $this->contents = preg_replace_callback($nodeRegex, function ($m) use ($children) {
  17988. return $m['start'] . $children . $m['end'];
  17989. }, $this->contents);
  17990. return true;
  17991. }
  17992. public function removeSubNode($mainNode, $name)
  17993. {
  17994. $decoded = JsonFile::parseJson($this->contents);
  17995. if (empty($decoded[$mainNode])) {
  17996. return true;
  17997. }
  17998. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  17999. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  18000. try {
  18001. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  18002. return false;
  18003. }
  18004. } catch (\RuntimeException $e) {
  18005. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  18006. return false;
  18007. }
  18008. throw $e;
  18009. }
  18010. $children = $match['content'];
  18011. if (!@json_decode($children, true)) {
  18012. return false;
  18013. }
  18014. $subName = null;
  18015. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  18016. list($name, $subName) = explode('.', $name, 2);
  18017. }
  18018. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  18019. return true;
  18020. }
  18021. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  18022. if ($this->pregMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  18023. if (preg_match_all('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  18024. $bestMatch = '';
  18025. foreach ($matches[0] as $match) {
  18026. if (strlen($bestMatch) < strlen($match)) {
  18027. $bestMatch = $match;
  18028. }
  18029. }
  18030. $childrenClean = preg_replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  18031. if (1 !== $count) {
  18032. $childrenClean = preg_replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  18033. if (1 !== $count) {
  18034. return false;
  18035. }
  18036. }
  18037. }
  18038. } else {
  18039. $childrenClean = $children;
  18040. }
  18041. if (!isset($childrenClean)) {
  18042. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  18043. }
  18044. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  18045. if (empty($match['content'])) {
  18046. $newline = $this->newline;
  18047. $indent = $this->indent;
  18048. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($indent, $newline) {
  18049. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  18050. }, $this->contents);
  18051. if ($subName !== null) {
  18052. $curVal = json_decode($children, true);
  18053. unset($curVal[$name][$subName]);
  18054. $this->addSubNode($mainNode, $name, $curVal[$name]);
  18055. }
  18056. return true;
  18057. }
  18058. $that = $this;
  18059. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  18060. if ($subName !== null) {
  18061. $curVal = json_decode($matches['content'], true);
  18062. unset($curVal[$name][$subName]);
  18063. $childrenClean = $that->format($curVal);
  18064. }
  18065. return $matches['start'] . $childrenClean . $matches['end'];
  18066. }, $this->contents);
  18067. return true;
  18068. }
  18069. public function addMainKey($key, $content)
  18070. {
  18071. $decoded = JsonFile::parseJson($this->contents);
  18072. $content = $this->format($content);
  18073. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18074. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  18075. if (isset($decoded[$key]) && $this->pregMatch($regex, $this->contents, $matches)) {
  18076. if (!@json_decode('{'.$matches['key'].'}')) {
  18077. return false;
  18078. }
  18079. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  18080. return true;
  18081. }
  18082. if ($this->pregMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  18083. $this->contents = preg_replace(
  18084. '#'.$match[1].'\}$#',
  18085. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  18086. $this->contents
  18087. );
  18088. return true;
  18089. }
  18090. $this->contents = preg_replace(
  18091. '#\}$#',
  18092. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  18093. $this->contents
  18094. );
  18095. return true;
  18096. }
  18097. public function removeMainKey($key)
  18098. {
  18099. $decoded = JsonFile::parseJson($this->contents);
  18100. if (!array_key_exists($key, $decoded)) {
  18101. return true;
  18102. }
  18103. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18104. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  18105. if ($this->pregMatch($regex, $this->contents, $matches)) {
  18106. if (!@json_decode('{'.$matches['removal'].'}')) {
  18107. return false;
  18108. }
  18109. if (preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
  18110. $matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  18111. }
  18112. $this->contents = $matches['start'] . $matches['end'];
  18113. if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
  18114. $this->contents = "{\n}";
  18115. }
  18116. return true;
  18117. }
  18118. return false;
  18119. }
  18120. public function removeMainKeyIfEmpty($key)
  18121. {
  18122. $decoded = JsonFile::parseJson($this->contents);
  18123. if (!array_key_exists($key, $decoded)) {
  18124. return true;
  18125. }
  18126. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  18127. return $this->removeMainKey($key);
  18128. }
  18129. return false;
  18130. }
  18131. public function format($data, $depth = 0)
  18132. {
  18133. if (is_array($data)) {
  18134. reset($data);
  18135. if (is_numeric(key($data))) {
  18136. foreach ($data as $key => $val) {
  18137. $data[$key] = $this->format($val, $depth + 1);
  18138. }
  18139. return '['.implode(', ', $data).']';
  18140. }
  18141. $out = '{' . $this->newline;
  18142. $elems = array();
  18143. foreach ($data as $key => $val) {
  18144. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  18145. }
  18146. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  18147. }
  18148. return JsonFile::encode($data);
  18149. }
  18150. protected function detectIndenting()
  18151. {
  18152. if ($this->pregMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  18153. $this->indent = $match[1];
  18154. } else {
  18155. $this->indent = ' ';
  18156. }
  18157. }
  18158. protected function pregMatch($re, $str, &$matches = array())
  18159. {
  18160. $count = preg_match($re, $str, $matches);
  18161. if ($count === false) {
  18162. switch (preg_last_error()) {
  18163. case PREG_NO_ERROR:
  18164. throw new \RuntimeException('Failed to execute regex: PREG_NO_ERROR', PREG_NO_ERROR);
  18165. case PREG_INTERNAL_ERROR:
  18166. throw new \RuntimeException('Failed to execute regex: PREG_INTERNAL_ERROR', PREG_INTERNAL_ERROR);
  18167. case PREG_BACKTRACK_LIMIT_ERROR:
  18168. throw new \RuntimeException('Failed to execute regex: PREG_BACKTRACK_LIMIT_ERROR', PREG_BACKTRACK_LIMIT_ERROR);
  18169. case PREG_RECURSION_LIMIT_ERROR:
  18170. throw new \RuntimeException('Failed to execute regex: PREG_RECURSION_LIMIT_ERROR', PREG_RECURSION_LIMIT_ERROR);
  18171. case PREG_BAD_UTF8_ERROR:
  18172. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_ERROR);
  18173. case PREG_BAD_UTF8_OFFSET_ERROR:
  18174. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_OFFSET_ERROR', PREG_BAD_UTF8_OFFSET_ERROR);
  18175. case 6:
  18176. if (PHP_VERSION_ID > 70000) {
  18177. throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6);
  18178. }
  18179. default:
  18180. throw new \RuntimeException('Failed to execute regex: Unknown error');
  18181. }
  18182. }
  18183. return $count;
  18184. }
  18185. }
  18186. <?php
  18187. namespace Composer\Json;
  18188. use Exception;
  18189. class JsonValidationException extends Exception
  18190. {
  18191. protected $errors;
  18192. public function __construct($message, $errors = array(), Exception $previous = null)
  18193. {
  18194. $this->errors = $errors;
  18195. parent::__construct($message, 0, $previous);
  18196. }
  18197. public function getErrors()
  18198. {
  18199. return $this->errors;
  18200. }
  18201. }
  18202. <?php
  18203. namespace Composer\Package;
  18204. use Composer\Semver\Constraint\Constraint;
  18205. use Composer\Package\Version\VersionParser;
  18206. class AliasPackage extends BasePackage implements CompletePackageInterface
  18207. {
  18208. protected $version;
  18209. protected $prettyVersion;
  18210. protected $dev;
  18211. protected $rootPackageAlias = false;
  18212. protected $stability;
  18213. protected $hasSelfVersionRequires = false;
  18214. protected $aliasOf;
  18215. protected $requires;
  18216. protected $devRequires;
  18217. protected $conflicts;
  18218. protected $provides;
  18219. protected $replaces;
  18220. public function __construct(PackageInterface $aliasOf, $version, $prettyVersion)
  18221. {
  18222. parent::__construct($aliasOf->getName());
  18223. $this->version = $version;
  18224. $this->prettyVersion = $prettyVersion;
  18225. $this->aliasOf = $aliasOf;
  18226. $this->stability = VersionParser::parseStability($version);
  18227. $this->dev = $this->stability === 'dev';
  18228. foreach (Link::$TYPES as $type) {
  18229. $links = $aliasOf->{'get' . ucfirst($type)}();
  18230. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  18231. }
  18232. }
  18233. public function getAliasOf()
  18234. {
  18235. return $this->aliasOf;
  18236. }
  18237. public function getVersion()
  18238. {
  18239. return $this->version;
  18240. }
  18241. public function getStability()
  18242. {
  18243. return $this->stability;
  18244. }
  18245. public function getPrettyVersion()
  18246. {
  18247. return $this->prettyVersion;
  18248. }
  18249. public function isDev()
  18250. {
  18251. return $this->dev;
  18252. }
  18253. public function getRequires()
  18254. {
  18255. return $this->requires;
  18256. }
  18257. public function getConflicts()
  18258. {
  18259. return $this->conflicts;
  18260. }
  18261. public function getProvides()
  18262. {
  18263. return $this->provides;
  18264. }
  18265. public function getReplaces()
  18266. {
  18267. return $this->replaces;
  18268. }
  18269. public function getDevRequires()
  18270. {
  18271. return $this->devRequires;
  18272. }
  18273. public function setRootPackageAlias($value)
  18274. {
  18275. return $this->rootPackageAlias = $value;
  18276. }
  18277. public function isRootPackageAlias()
  18278. {
  18279. return $this->rootPackageAlias;
  18280. }
  18281. protected function replaceSelfVersionDependencies(array $links, $linkType)
  18282. {
  18283. $prettyVersion = $this->prettyVersion;
  18284. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  18285. $prettyVersion = $this->aliasOf->getPrettyVersion();
  18286. }
  18287. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  18288. $newLinks = array();
  18289. foreach ($links as $link) {
  18290. if ('self.version' === $link->getPrettyConstraint()) {
  18291. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18292. $constraint->setPrettyString($prettyVersion);
  18293. }
  18294. }
  18295. $links = array_merge($links, $newLinks);
  18296. } else {
  18297. foreach ($links as $index => $link) {
  18298. if ('self.version' === $link->getPrettyConstraint()) {
  18299. if ($linkType === Link::TYPE_REQUIRE) {
  18300. $this->hasSelfVersionRequires = true;
  18301. }
  18302. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18303. $constraint->setPrettyString($prettyVersion);
  18304. }
  18305. }
  18306. }
  18307. return $links;
  18308. }
  18309. public function hasSelfVersionRequires()
  18310. {
  18311. return $this->hasSelfVersionRequires;
  18312. }
  18313. public function getType()
  18314. {
  18315. return $this->aliasOf->getType();
  18316. }
  18317. public function getTargetDir()
  18318. {
  18319. return $this->aliasOf->getTargetDir();
  18320. }
  18321. public function getExtra()
  18322. {
  18323. return $this->aliasOf->getExtra();
  18324. }
  18325. public function setInstallationSource($type)
  18326. {
  18327. $this->aliasOf->setInstallationSource($type);
  18328. }
  18329. public function getInstallationSource()
  18330. {
  18331. return $this->aliasOf->getInstallationSource();
  18332. }
  18333. public function getSourceType()
  18334. {
  18335. return $this->aliasOf->getSourceType();
  18336. }
  18337. public function getSourceUrl()
  18338. {
  18339. return $this->aliasOf->getSourceUrl();
  18340. }
  18341. public function getSourceUrls()
  18342. {
  18343. return $this->aliasOf->getSourceUrls();
  18344. }
  18345. public function getSourceReference()
  18346. {
  18347. return $this->aliasOf->getSourceReference();
  18348. }
  18349. public function setSourceReference($reference)
  18350. {
  18351. return $this->aliasOf->setSourceReference($reference);
  18352. }
  18353. public function setSourceMirrors($mirrors)
  18354. {
  18355. return $this->aliasOf->setSourceMirrors($mirrors);
  18356. }
  18357. public function getSourceMirrors()
  18358. {
  18359. return $this->aliasOf->getSourceMirrors();
  18360. }
  18361. public function getDistType()
  18362. {
  18363. return $this->aliasOf->getDistType();
  18364. }
  18365. public function getDistUrl()
  18366. {
  18367. return $this->aliasOf->getDistUrl();
  18368. }
  18369. public function getDistUrls()
  18370. {
  18371. return $this->aliasOf->getDistUrls();
  18372. }
  18373. public function getDistReference()
  18374. {
  18375. return $this->aliasOf->getDistReference();
  18376. }
  18377. public function setDistReference($reference)
  18378. {
  18379. return $this->aliasOf->setDistReference($reference);
  18380. }
  18381. public function getDistSha1Checksum()
  18382. {
  18383. return $this->aliasOf->getDistSha1Checksum();
  18384. }
  18385. public function setTransportOptions(array $options)
  18386. {
  18387. return $this->aliasOf->setTransportOptions($options);
  18388. }
  18389. public function getTransportOptions()
  18390. {
  18391. return $this->aliasOf->getTransportOptions();
  18392. }
  18393. public function setDistMirrors($mirrors)
  18394. {
  18395. return $this->aliasOf->setDistMirrors($mirrors);
  18396. }
  18397. public function getDistMirrors()
  18398. {
  18399. return $this->aliasOf->getDistMirrors();
  18400. }
  18401. public function getScripts()
  18402. {
  18403. return $this->aliasOf->getScripts();
  18404. }
  18405. public function getLicense()
  18406. {
  18407. return $this->aliasOf->getLicense();
  18408. }
  18409. public function getAutoload()
  18410. {
  18411. return $this->aliasOf->getAutoload();
  18412. }
  18413. public function getDevAutoload()
  18414. {
  18415. return $this->aliasOf->getDevAutoload();
  18416. }
  18417. public function getIncludePaths()
  18418. {
  18419. return $this->aliasOf->getIncludePaths();
  18420. }
  18421. public function getRepositories()
  18422. {
  18423. return $this->aliasOf->getRepositories();
  18424. }
  18425. public function getReleaseDate()
  18426. {
  18427. return $this->aliasOf->getReleaseDate();
  18428. }
  18429. public function getBinaries()
  18430. {
  18431. return $this->aliasOf->getBinaries();
  18432. }
  18433. public function getKeywords()
  18434. {
  18435. return $this->aliasOf->getKeywords();
  18436. }
  18437. public function getDescription()
  18438. {
  18439. return $this->aliasOf->getDescription();
  18440. }
  18441. public function getHomepage()
  18442. {
  18443. return $this->aliasOf->getHomepage();
  18444. }
  18445. public function getSuggests()
  18446. {
  18447. return $this->aliasOf->getSuggests();
  18448. }
  18449. public function getAuthors()
  18450. {
  18451. return $this->aliasOf->getAuthors();
  18452. }
  18453. public function getSupport()
  18454. {
  18455. return $this->aliasOf->getSupport();
  18456. }
  18457. public function getFunding()
  18458. {
  18459. return $this->aliasOf->getFunding();
  18460. }
  18461. public function getNotificationUrl()
  18462. {
  18463. return $this->aliasOf->getNotificationUrl();
  18464. }
  18465. public function getArchiveName()
  18466. {
  18467. return $this->aliasOf->getArchiveName();
  18468. }
  18469. public function getArchiveExcludes()
  18470. {
  18471. return $this->aliasOf->getArchiveExcludes();
  18472. }
  18473. public function isDefaultBranch()
  18474. {
  18475. return $this->aliasOf->isDefaultBranch();
  18476. }
  18477. public function isAbandoned()
  18478. {
  18479. return $this->aliasOf->isAbandoned();
  18480. }
  18481. public function getReplacementPackage()
  18482. {
  18483. return $this->aliasOf->getReplacementPackage();
  18484. }
  18485. public function __toString()
  18486. {
  18487. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ':''). 'alias of '.$this->aliasOf->getVersion().')';
  18488. }
  18489. public function setDistUrl($url)
  18490. {
  18491. return $this->aliasOf->setDistUrl($url);
  18492. }
  18493. public function setDistType($type)
  18494. {
  18495. return $this->aliasOf->setDistType($type);
  18496. }
  18497. public function setSourceDistReferences($reference)
  18498. {
  18499. return $this->aliasOf->setSourceDistReferences($reference);
  18500. }
  18501. }
  18502. <?php
  18503. namespace Composer\Package\Archiver;
  18504. use FilterIterator;
  18505. use PharData;
  18506. class ArchivableFilesFilter extends FilterIterator
  18507. {
  18508. private $dirs = array();
  18509. public function accept()
  18510. {
  18511. $file = $this->getInnerIterator()->current();
  18512. if ($file->isDir()) {
  18513. $this->dirs[] = (string) $file;
  18514. return false;
  18515. }
  18516. return true;
  18517. }
  18518. public function addEmptyDir(PharData $phar, $sources)
  18519. {
  18520. foreach ($this->dirs as $filepath) {
  18521. $localname = str_replace($sources . "/", '', $filepath);
  18522. $phar->addEmptyDir($localname);
  18523. }
  18524. }
  18525. }
  18526. <?php
  18527. namespace Composer\Package\Archiver;
  18528. use Composer\Util\Filesystem;
  18529. use FilesystemIterator;
  18530. use Symfony\Component\Finder\Finder;
  18531. use Symfony\Component\Finder\SplFileInfo;
  18532. class ArchivableFilesFinder extends \FilterIterator
  18533. {
  18534. protected $finder;
  18535. public function __construct($sources, array $excludes, $ignoreFilters = false)
  18536. {
  18537. $fs = new Filesystem();
  18538. $sources = $fs->normalizePath(realpath($sources));
  18539. if ($ignoreFilters) {
  18540. $filters = array();
  18541. } else {
  18542. $filters = array(
  18543. new HgExcludeFilter($sources),
  18544. new GitExcludeFilter($sources),
  18545. new ComposerExcludeFilter($sources, $excludes),
  18546. );
  18547. }
  18548. $this->finder = new Finder();
  18549. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  18550. if ($file->isLink() && strpos($file->getRealPath(), $sources) !== 0) {
  18551. return false;
  18552. }
  18553. $relativePath = preg_replace(
  18554. '#^'.preg_quote($sources, '#').'#',
  18555. '',
  18556. $fs->normalizePath($file->getRealPath())
  18557. );
  18558. $exclude = false;
  18559. foreach ($filters as $filter) {
  18560. $exclude = $filter->filter($relativePath, $exclude);
  18561. }
  18562. return !$exclude;
  18563. };
  18564. if (method_exists($filter, 'bindTo')) {
  18565. $filter = $filter->bindTo(null);
  18566. }
  18567. $this->finder
  18568. ->in($sources)
  18569. ->filter($filter)
  18570. ->ignoreVCS(true)
  18571. ->ignoreDotFiles(false);
  18572. parent::__construct($this->finder->getIterator());
  18573. }
  18574. public function accept()
  18575. {
  18576. $current = $this->getInnerIterator()->current();
  18577. if (!$current->isDir()) {
  18578. return true;
  18579. }
  18580. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  18581. return !$iterator->valid();
  18582. }
  18583. }
  18584. <?php
  18585. namespace Composer\Package\Archiver;
  18586. use Composer\Downloader\DownloadManager;
  18587. use Composer\Package\PackageInterface;
  18588. use Composer\Package\RootPackageInterface;
  18589. use Composer\Util\Filesystem;
  18590. use Composer\Util\Loop;
  18591. use Composer\Json\JsonFile;
  18592. class ArchiveManager
  18593. {
  18594. protected $downloadManager;
  18595. protected $loop;
  18596. protected $archivers = array();
  18597. protected $overwriteFiles = true;
  18598. public function __construct(DownloadManager $downloadManager, Loop $loop)
  18599. {
  18600. $this->downloadManager = $downloadManager;
  18601. $this->loop = $loop;
  18602. }
  18603. public function addArchiver(ArchiverInterface $archiver)
  18604. {
  18605. $this->archivers[] = $archiver;
  18606. }
  18607. public function setOverwriteFiles($overwriteFiles)
  18608. {
  18609. $this->overwriteFiles = $overwriteFiles;
  18610. return $this;
  18611. }
  18612. public function getPackageFilename(PackageInterface $package)
  18613. {
  18614. if ($package->getArchiveName()) {
  18615. $baseName = $package->getArchiveName();
  18616. } else {
  18617. $baseName = preg_replace('#[^a-z0-9-_]#i', '-', $package->getName());
  18618. }
  18619. $nameParts = array($baseName);
  18620. if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  18621. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  18622. } else {
  18623. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  18624. }
  18625. if ($package->getSourceReference()) {
  18626. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  18627. }
  18628. $name = implode('-', array_filter($nameParts, function ($p) {
  18629. return !empty($p);
  18630. }));
  18631. return str_replace('/', '-', $name);
  18632. }
  18633. public function archive(PackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  18634. {
  18635. if (empty($format)) {
  18636. throw new \InvalidArgumentException('Format must be specified');
  18637. }
  18638. $usableArchiver = null;
  18639. foreach ($this->archivers as $archiver) {
  18640. if ($archiver->supports($format, $package->getSourceType())) {
  18641. $usableArchiver = $archiver;
  18642. break;
  18643. }
  18644. }
  18645. if (null === $usableArchiver) {
  18646. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  18647. }
  18648. $filesystem = new Filesystem();
  18649. if ($package instanceof RootPackageInterface) {
  18650. $sourcePath = realpath('.');
  18651. } else {
  18652. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  18653. $filesystem->ensureDirectoryExists($sourcePath);
  18654. try {
  18655. $promise = $this->downloadManager->download($package, $sourcePath);
  18656. $this->loop->wait(array($promise));
  18657. $this->downloadManager->install($package, $sourcePath);
  18658. } catch (\Exception $e) {
  18659. $filesystem->removeDirectory($sourcePath);
  18660. throw $e;
  18661. }
  18662. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  18663. $jsonFile = new JsonFile($composerJsonPath);
  18664. $jsonData = $jsonFile->read();
  18665. if (!empty($jsonData['archive']['name'])) {
  18666. $package->setArchiveName($jsonData['archive']['name']);
  18667. }
  18668. if (!empty($jsonData['archive']['exclude'])) {
  18669. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  18670. }
  18671. }
  18672. }
  18673. if (null === $fileName) {
  18674. $packageName = $this->getPackageFilename($package);
  18675. } else {
  18676. $packageName = $fileName;
  18677. }
  18678. $filesystem->ensureDirectoryExists($targetDir);
  18679. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  18680. $filesystem->ensureDirectoryExists(dirname($target));
  18681. if (!$this->overwriteFiles && file_exists($target)) {
  18682. return $target;
  18683. }
  18684. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  18685. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  18686. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  18687. $filesystem->rename($archivePath, $target);
  18688. if (!$package instanceof RootPackageInterface) {
  18689. $filesystem->removeDirectory($sourcePath);
  18690. }
  18691. $filesystem->remove($tempTarget);
  18692. return $target;
  18693. }
  18694. }
  18695. <?php
  18696. namespace Composer\Package\Archiver;
  18697. interface ArchiverInterface
  18698. {
  18699. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  18700. public function supports($format, $sourceType);
  18701. }
  18702. <?php
  18703. namespace Composer\Package\Archiver;
  18704. use Symfony\Component\Finder;
  18705. abstract class BaseExcludeFilter
  18706. {
  18707. protected $sourcePath;
  18708. protected $excludePatterns;
  18709. public function __construct($sourcePath)
  18710. {
  18711. $this->sourcePath = $sourcePath;
  18712. $this->excludePatterns = array();
  18713. }
  18714. public function filter($relativePath, $exclude)
  18715. {
  18716. foreach ($this->excludePatterns as $patternData) {
  18717. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  18718. if ($stripLeadingSlash) {
  18719. $path = substr($relativePath, 1);
  18720. } else {
  18721. $path = $relativePath;
  18722. }
  18723. if (@preg_match($pattern, $path)) {
  18724. $exclude = !$negate;
  18725. }
  18726. }
  18727. return $exclude;
  18728. }
  18729. protected function parseLines(array $lines, $lineParser)
  18730. {
  18731. return array_filter(
  18732. array_map(
  18733. function ($line) use ($lineParser) {
  18734. $line = trim($line);
  18735. if (!$line || 0 === strpos($line, '#')) {
  18736. return null;
  18737. }
  18738. return call_user_func($lineParser, $line);
  18739. },
  18740. $lines
  18741. ),
  18742. function ($pattern) {
  18743. return $pattern !== null;
  18744. }
  18745. );
  18746. }
  18747. protected function generatePatterns($rules)
  18748. {
  18749. $patterns = array();
  18750. foreach ($rules as $rule) {
  18751. $patterns[] = $this->generatePattern($rule);
  18752. }
  18753. return $patterns;
  18754. }
  18755. protected function generatePattern($rule)
  18756. {
  18757. $negate = false;
  18758. $pattern = '{';
  18759. if (strlen($rule) && $rule[0] === '!') {
  18760. $negate = true;
  18761. $rule = substr($rule, 1);
  18762. }
  18763. if (strlen($rule) && $rule[0] === '/') {
  18764. $pattern .= '^/';
  18765. $rule = substr($rule, 1);
  18766. } elseif (strlen($rule) - 1 === strpos($rule, '/')) {
  18767. $pattern .= '/';
  18768. $rule = substr($rule, 0, -1);
  18769. } elseif (false === strpos($rule, '/')) {
  18770. $pattern .= '/';
  18771. }
  18772. $pattern .= substr(Finder\Glob::toRegex($rule), 2, -2) . '(?=$|/)';
  18773. return array($pattern . '}', $negate, false);
  18774. }
  18775. }
  18776. <?php
  18777. namespace Composer\Package\Archiver;
  18778. class ComposerExcludeFilter extends BaseExcludeFilter
  18779. {
  18780. public function __construct($sourcePath, array $excludeRules)
  18781. {
  18782. parent::__construct($sourcePath);
  18783. $this->excludePatterns = $this->generatePatterns($excludeRules);
  18784. }
  18785. }
  18786. <?php
  18787. namespace Composer\Package\Archiver;
  18788. class GitExcludeFilter extends BaseExcludeFilter
  18789. {
  18790. public function __construct($sourcePath)
  18791. {
  18792. parent::__construct($sourcePath);
  18793. if (file_exists($sourcePath.'/.gitignore')) {
  18794. $this->excludePatterns = $this->parseLines(
  18795. file($sourcePath.'/.gitignore'),
  18796. array($this, 'parseGitIgnoreLine')
  18797. );
  18798. }
  18799. if (file_exists($sourcePath.'/.gitattributes')) {
  18800. $this->excludePatterns = array_merge(
  18801. $this->excludePatterns,
  18802. $this->parseLines(
  18803. file($sourcePath.'/.gitattributes'),
  18804. array($this, 'parseGitAttributesLine')
  18805. )
  18806. );
  18807. }
  18808. }
  18809. public function parseGitIgnoreLine($line)
  18810. {
  18811. return $this->generatePattern($line);
  18812. }
  18813. public function parseGitAttributesLine($line)
  18814. {
  18815. $parts = preg_split('#\s+#', $line);
  18816. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  18817. return $this->generatePattern($parts[0]);
  18818. }
  18819. return null;
  18820. }
  18821. }
  18822. <?php
  18823. namespace Composer\Package\Archiver;
  18824. use Symfony\Component\Finder;
  18825. class HgExcludeFilter extends BaseExcludeFilter
  18826. {
  18827. const HG_IGNORE_REGEX = 1;
  18828. const HG_IGNORE_GLOB = 2;
  18829. protected $patternMode;
  18830. public function __construct($sourcePath)
  18831. {
  18832. parent::__construct($sourcePath);
  18833. $this->patternMode = self::HG_IGNORE_REGEX;
  18834. if (file_exists($sourcePath.'/.hgignore')) {
  18835. $this->excludePatterns = $this->parseLines(
  18836. file($sourcePath.'/.hgignore'),
  18837. array($this, 'parseHgIgnoreLine')
  18838. );
  18839. }
  18840. }
  18841. public function parseHgIgnoreLine($line)
  18842. {
  18843. if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)) {
  18844. if ($matches[1] === 'glob') {
  18845. $this->patternMode = self::HG_IGNORE_GLOB;
  18846. } else {
  18847. $this->patternMode = self::HG_IGNORE_REGEX;
  18848. }
  18849. return null;
  18850. }
  18851. if ($this->patternMode == self::HG_IGNORE_GLOB) {
  18852. return $this->patternFromGlob($line);
  18853. }
  18854. return $this->patternFromRegex($line);
  18855. }
  18856. protected function patternFromGlob($line)
  18857. {
  18858. $pattern = '#'.substr(Finder\Glob::toRegex($line), 2, -1).'#';
  18859. $pattern = str_replace('[^/]*', '.*', $pattern);
  18860. return array($pattern, false, true);
  18861. }
  18862. public function patternFromRegex($line)
  18863. {
  18864. $pattern = '#'.preg_replace('/((?:\\\\\\\\)*)(\\\\?)#/', '\1\2\2\\#', $line).'#';
  18865. return array($pattern, false, true);
  18866. }
  18867. }
  18868. <?php
  18869. namespace Composer\Package\Archiver;
  18870. class PharArchiver implements ArchiverInterface
  18871. {
  18872. protected static $formats = array(
  18873. 'zip' => \Phar::ZIP,
  18874. 'tar' => \Phar::TAR,
  18875. 'tar.gz' => \Phar::TAR,
  18876. 'tar.bz2' => \Phar::TAR,
  18877. );
  18878. protected static $compressFormats = array(
  18879. 'tar.gz' => \Phar::GZ,
  18880. 'tar.bz2' => \Phar::BZ2,
  18881. );
  18882. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  18883. {
  18884. $sources = realpath($sources);
  18885. if (file_exists($target)) {
  18886. unlink($target);
  18887. }
  18888. try {
  18889. $filename = substr($target, 0, strrpos($target, $format) - 1);
  18890. if (isset(static::$compressFormats[$format])) {
  18891. $target = $filename . '.tar';
  18892. }
  18893. $phar = new \PharData($target, null, null, static::$formats[$format]);
  18894. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  18895. $filesOnly = new ArchivableFilesFilter($files);
  18896. $phar->buildFromIterator($filesOnly, $sources);
  18897. $filesOnly->addEmptyDir($phar, $sources);
  18898. if (isset(static::$compressFormats[$format])) {
  18899. if (!$phar->canCompress(static::$compressFormats[$format])) {
  18900. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  18901. }
  18902. unlink($target);
  18903. $phar->compress(static::$compressFormats[$format]);
  18904. $target = $filename . '.' . $format;
  18905. }
  18906. return $target;
  18907. } catch (\UnexpectedValueException $e) {
  18908. $message = sprintf(
  18909. "Could not create archive '%s' from '%s': %s",
  18910. $target,
  18911. $sources,
  18912. $e->getMessage()
  18913. );
  18914. throw new \RuntimeException($message, $e->getCode(), $e);
  18915. }
  18916. }
  18917. public function supports($format, $sourceType)
  18918. {
  18919. return isset(static::$formats[$format]);
  18920. }
  18921. }
  18922. <?php
  18923. namespace Composer\Package\Archiver;
  18924. use ZipArchive;
  18925. use Composer\Util\Filesystem;
  18926. class ZipArchiver implements ArchiverInterface
  18927. {
  18928. protected static $formats = array(
  18929. 'zip' => 1,
  18930. );
  18931. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  18932. {
  18933. $fs = new Filesystem();
  18934. $sources = $fs->normalizePath($sources);
  18935. $zip = new ZipArchive();
  18936. $res = $zip->open($target, ZipArchive::CREATE);
  18937. if ($res === true) {
  18938. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  18939. foreach ($files as $file) {
  18940. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  18941. $localname = $filepath;
  18942. if (strpos($localname, $sources . '/') === 0) {
  18943. $localname = substr($localname, strlen($sources . '/'));
  18944. }
  18945. if ($file->isDir()) {
  18946. $zip->addEmptyDir($localname);
  18947. } else {
  18948. $zip->addFile($filepath, $localname);
  18949. }
  18950. if (PHP_VERSION_ID >= 50600) {
  18951. $perms = fileperms($filepath);
  18952. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  18953. }
  18954. }
  18955. if ($zip->close()) {
  18956. return $target;
  18957. }
  18958. }
  18959. $message = sprintf(
  18960. "Could not create archive '%s' from '%s': %s",
  18961. $target,
  18962. $sources,
  18963. $zip->getStatusString()
  18964. );
  18965. throw new \RuntimeException($message);
  18966. }
  18967. public function supports($format, $sourceType)
  18968. {
  18969. return isset(static::$formats[$format]) && $this->compressionAvailable();
  18970. }
  18971. private function compressionAvailable()
  18972. {
  18973. return class_exists('ZipArchive');
  18974. }
  18975. }
  18976. <?php
  18977. namespace Composer\Package;
  18978. use Composer\Repository\RepositoryInterface;
  18979. use Composer\Repository\PlatformRepository;
  18980. abstract class BasePackage implements PackageInterface
  18981. {
  18982. public static $supportedLinkTypes = array(
  18983. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  18984. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  18985. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  18986. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  18987. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  18988. );
  18989. const STABILITY_STABLE = 0;
  18990. const STABILITY_RC = 5;
  18991. const STABILITY_BETA = 10;
  18992. const STABILITY_ALPHA = 15;
  18993. const STABILITY_DEV = 20;
  18994. public static $stabilities = array(
  18995. 'stable' => self::STABILITY_STABLE,
  18996. 'RC' => self::STABILITY_RC,
  18997. 'beta' => self::STABILITY_BETA,
  18998. 'alpha' => self::STABILITY_ALPHA,
  18999. 'dev' => self::STABILITY_DEV,
  19000. );
  19001. public $id;
  19002. protected $name;
  19003. protected $prettyName;
  19004. protected $repository;
  19005. protected $transportOptions = array();
  19006. public function __construct($name)
  19007. {
  19008. $this->prettyName = $name;
  19009. $this->name = strtolower($name);
  19010. $this->id = -1;
  19011. }
  19012. public function getName()
  19013. {
  19014. return $this->name;
  19015. }
  19016. public function getPrettyName()
  19017. {
  19018. return $this->prettyName;
  19019. }
  19020. public function getNames($provides = true)
  19021. {
  19022. $names = array(
  19023. $this->getName() => true,
  19024. );
  19025. if ($provides) {
  19026. foreach ($this->getProvides() as $link) {
  19027. $names[$link->getTarget()] = true;
  19028. }
  19029. }
  19030. foreach ($this->getReplaces() as $link) {
  19031. $names[$link->getTarget()] = true;
  19032. }
  19033. return array_keys($names);
  19034. }
  19035. public function setId($id)
  19036. {
  19037. $this->id = $id;
  19038. }
  19039. public function getId()
  19040. {
  19041. return $this->id;
  19042. }
  19043. public function setRepository(RepositoryInterface $repository)
  19044. {
  19045. if ($this->repository && $repository !== $this->repository) {
  19046. throw new \LogicException('A package can only be added to one repository');
  19047. }
  19048. $this->repository = $repository;
  19049. }
  19050. public function getRepository()
  19051. {
  19052. return $this->repository;
  19053. }
  19054. public function getTransportOptions()
  19055. {
  19056. return $this->transportOptions;
  19057. }
  19058. public function setTransportOptions(array $options)
  19059. {
  19060. $this->transportOptions = $options;
  19061. }
  19062. public function isPlatform()
  19063. {
  19064. return $this->getRepository() instanceof PlatformRepository;
  19065. }
  19066. public function getUniqueName()
  19067. {
  19068. return $this->getName().'-'.$this->getVersion();
  19069. }
  19070. public function equals(PackageInterface $package)
  19071. {
  19072. $self = $this;
  19073. if ($this instanceof AliasPackage) {
  19074. $self = $this->getAliasOf();
  19075. }
  19076. if ($package instanceof AliasPackage) {
  19077. $package = $package->getAliasOf();
  19078. }
  19079. return $package === $self;
  19080. }
  19081. public function __toString()
  19082. {
  19083. return $this->getUniqueName();
  19084. }
  19085. public function getPrettyString()
  19086. {
  19087. return $this->getPrettyName().' '.$this->getPrettyVersion();
  19088. }
  19089. public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
  19090. {
  19091. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  19092. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  19093. ) {
  19094. return $this->getPrettyVersion();
  19095. }
  19096. switch ($displayMode) {
  19097. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  19098. case PackageInterface::DISPLAY_SOURCE_REF:
  19099. $reference = $this->getSourceReference();
  19100. break;
  19101. case PackageInterface::DISPLAY_DIST_REF:
  19102. $reference = $this->getDistReference();
  19103. break;
  19104. default:
  19105. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  19106. }
  19107. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  19108. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  19109. }
  19110. return $this->getPrettyVersion() . ' ' . $reference;
  19111. }
  19112. public function getStabilityPriority()
  19113. {
  19114. return self::$stabilities[$this->getStability()];
  19115. }
  19116. public function __clone()
  19117. {
  19118. $this->repository = null;
  19119. $this->id = -1;
  19120. }
  19121. public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
  19122. {
  19123. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  19124. return sprintf($wrap, $cleanedAllowPattern);
  19125. }
  19126. }
  19127. <?php
  19128. namespace Composer\Package\Comparer;
  19129. class Comparer
  19130. {
  19131. private $source;
  19132. private $update;
  19133. private $changed;
  19134. public function setSource($source)
  19135. {
  19136. $this->source = $source;
  19137. }
  19138. public function setUpdate($update)
  19139. {
  19140. $this->update = $update;
  19141. }
  19142. public function getChanged($toString = false, $explicated = false)
  19143. {
  19144. $changed = $this->changed;
  19145. if (!count($changed)) {
  19146. return false;
  19147. }
  19148. if ($explicated) {
  19149. foreach ($changed as $sectionKey => $itemSection) {
  19150. foreach ($itemSection as $itemKey => $item) {
  19151. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  19152. }
  19153. }
  19154. }
  19155. if ($toString) {
  19156. foreach ($changed as $sectionKey => $itemSection) {
  19157. foreach ($itemSection as $itemKey => $item) {
  19158. $changed['string'][] = $item."\r\n";
  19159. }
  19160. }
  19161. $changed = implode("\r\n", $changed['string']);
  19162. }
  19163. return $changed;
  19164. }
  19165. public function doCompare()
  19166. {
  19167. $source = array();
  19168. $destination = array();
  19169. $this->changed = array();
  19170. $currentDirectory = getcwd();
  19171. chdir($this->source);
  19172. $source = $this->doTree('.', $source);
  19173. if (!is_array($source)) {
  19174. return;
  19175. }
  19176. chdir($currentDirectory);
  19177. chdir($this->update);
  19178. $destination = $this->doTree('.', $destination);
  19179. if (!is_array($destination)) {
  19180. exit;
  19181. }
  19182. chdir($currentDirectory);
  19183. foreach ($source as $dir => $value) {
  19184. foreach ($value as $file => $hash) {
  19185. if (isset($destination[$dir][$file])) {
  19186. if ($hash !== $destination[$dir][$file]) {
  19187. $this->changed['changed'][] = $dir.'/'.$file;
  19188. }
  19189. } else {
  19190. $this->changed['removed'][] = $dir.'/'.$file;
  19191. }
  19192. }
  19193. }
  19194. foreach ($destination as $dir => $value) {
  19195. foreach ($value as $file => $hash) {
  19196. if (!isset($source[$dir][$file])) {
  19197. $this->changed['added'][] = $dir.'/'.$file;
  19198. }
  19199. }
  19200. }
  19201. }
  19202. private function doTree($dir, &$array)
  19203. {
  19204. if ($dh = opendir($dir)) {
  19205. while ($file = readdir($dh)) {
  19206. if ($file !== '.' && $file !== '..') {
  19207. if (is_link($dir.'/'.$file)) {
  19208. $array[$dir][$file] = readlink($dir.'/'.$file);
  19209. } elseif (is_dir($dir.'/'.$file)) {
  19210. if (!count($array)) {
  19211. $array[0] = 'Temp';
  19212. }
  19213. if (!$this->doTree($dir.'/'.$file, $array)) {
  19214. return false;
  19215. }
  19216. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  19217. $array[$dir][$file] = md5_file($dir.'/'.$file);
  19218. }
  19219. }
  19220. }
  19221. if (count($array) > 1 && isset($array['0'])) {
  19222. unset($array['0']);
  19223. }
  19224. return $array;
  19225. }
  19226. return false;
  19227. }
  19228. }
  19229. <?php
  19230. namespace Composer\Package;
  19231. class CompletePackage extends Package implements CompletePackageInterface
  19232. {
  19233. protected $repositories;
  19234. protected $license = array();
  19235. protected $keywords;
  19236. protected $authors;
  19237. protected $description;
  19238. protected $homepage;
  19239. protected $scripts = array();
  19240. protected $support = array();
  19241. protected $funding = array();
  19242. protected $abandoned = false;
  19243. public function setScripts(array $scripts)
  19244. {
  19245. $this->scripts = $scripts;
  19246. }
  19247. public function getScripts()
  19248. {
  19249. return $this->scripts;
  19250. }
  19251. public function setRepositories($repositories)
  19252. {
  19253. $this->repositories = $repositories;
  19254. }
  19255. public function getRepositories()
  19256. {
  19257. return $this->repositories;
  19258. }
  19259. public function setLicense(array $license)
  19260. {
  19261. $this->license = $license;
  19262. }
  19263. public function getLicense()
  19264. {
  19265. return $this->license;
  19266. }
  19267. public function setKeywords(array $keywords)
  19268. {
  19269. $this->keywords = $keywords;
  19270. }
  19271. public function getKeywords()
  19272. {
  19273. return $this->keywords;
  19274. }
  19275. public function setAuthors(array $authors)
  19276. {
  19277. $this->authors = $authors;
  19278. }
  19279. public function getAuthors()
  19280. {
  19281. return $this->authors;
  19282. }
  19283. public function setDescription($description)
  19284. {
  19285. $this->description = $description;
  19286. }
  19287. public function getDescription()
  19288. {
  19289. return $this->description;
  19290. }
  19291. public function setHomepage($homepage)
  19292. {
  19293. $this->homepage = $homepage;
  19294. }
  19295. public function getHomepage()
  19296. {
  19297. return $this->homepage;
  19298. }
  19299. public function setSupport(array $support)
  19300. {
  19301. $this->support = $support;
  19302. }
  19303. public function getSupport()
  19304. {
  19305. return $this->support;
  19306. }
  19307. public function setFunding(array $funding)
  19308. {
  19309. $this->funding = $funding;
  19310. }
  19311. public function getFunding()
  19312. {
  19313. return $this->funding;
  19314. }
  19315. public function isAbandoned()
  19316. {
  19317. return (bool) $this->abandoned;
  19318. }
  19319. public function setAbandoned($abandoned)
  19320. {
  19321. $this->abandoned = $abandoned;
  19322. }
  19323. public function getReplacementPackage()
  19324. {
  19325. return \is_string($this->abandoned) ? $this->abandoned : null;
  19326. }
  19327. }
  19328. <?php
  19329. namespace Composer\Package;
  19330. interface CompletePackageInterface extends PackageInterface
  19331. {
  19332. public function getScripts();
  19333. public function getRepositories();
  19334. public function getLicense();
  19335. public function getKeywords();
  19336. public function getDescription();
  19337. public function getHomepage();
  19338. public function getAuthors();
  19339. public function getSupport();
  19340. public function getFunding();
  19341. public function isAbandoned();
  19342. public function getReplacementPackage();
  19343. }
  19344. <?php
  19345. namespace Composer\Package\Dumper;
  19346. use Composer\Package\BasePackage;
  19347. use Composer\Package\PackageInterface;
  19348. use Composer\Package\CompletePackageInterface;
  19349. use Composer\Package\RootPackageInterface;
  19350. class ArrayDumper
  19351. {
  19352. public function dump(PackageInterface $package)
  19353. {
  19354. $keys = array(
  19355. 'binaries' => 'bin',
  19356. 'type',
  19357. 'extra',
  19358. 'installationSource' => 'installation-source',
  19359. 'autoload',
  19360. 'devAutoload' => 'autoload-dev',
  19361. 'notificationUrl' => 'notification-url',
  19362. 'includePaths' => 'include-path',
  19363. );
  19364. $data = array();
  19365. $data['name'] = $package->getPrettyName();
  19366. $data['version'] = $package->getPrettyVersion();
  19367. $data['version_normalized'] = $package->getVersion();
  19368. if ($package->getTargetDir()) {
  19369. $data['target-dir'] = $package->getTargetDir();
  19370. }
  19371. if ($package->getSourceType()) {
  19372. $data['source']['type'] = $package->getSourceType();
  19373. $data['source']['url'] = $package->getSourceUrl();
  19374. if (null !== ($value = $package->getSourceReference())) {
  19375. $data['source']['reference'] = $value;
  19376. }
  19377. if ($mirrors = $package->getSourceMirrors()) {
  19378. $data['source']['mirrors'] = $mirrors;
  19379. }
  19380. }
  19381. if ($package->getDistType()) {
  19382. $data['dist']['type'] = $package->getDistType();
  19383. $data['dist']['url'] = $package->getDistUrl();
  19384. if (null !== ($value = $package->getDistReference())) {
  19385. $data['dist']['reference'] = $value;
  19386. }
  19387. if (null !== ($value = $package->getDistSha1Checksum())) {
  19388. $data['dist']['shasum'] = $value;
  19389. }
  19390. if ($mirrors = $package->getDistMirrors()) {
  19391. $data['dist']['mirrors'] = $mirrors;
  19392. }
  19393. }
  19394. if ($package->getArchiveName()) {
  19395. $data['archive']['name'] = $package->getArchiveName();
  19396. }
  19397. if ($package->getArchiveExcludes()) {
  19398. $data['archive']['exclude'] = $package->getArchiveExcludes();
  19399. }
  19400. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  19401. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  19402. foreach ($links as $link) {
  19403. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  19404. }
  19405. ksort($data[$type]);
  19406. }
  19407. }
  19408. if ($packages = $package->getSuggests()) {
  19409. ksort($packages);
  19410. $data['suggest'] = $packages;
  19411. }
  19412. if ($package->getReleaseDate()) {
  19413. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  19414. }
  19415. if ($package->isDefaultBranch()) {
  19416. $data['default-branch'] = true;
  19417. }
  19418. $data = $this->dumpValues($package, $keys, $data);
  19419. if ($package instanceof CompletePackageInterface) {
  19420. $keys = array(
  19421. 'scripts',
  19422. 'license',
  19423. 'authors',
  19424. 'description',
  19425. 'homepage',
  19426. 'keywords',
  19427. 'repositories',
  19428. 'support',
  19429. 'funding',
  19430. );
  19431. $data = $this->dumpValues($package, $keys, $data);
  19432. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  19433. sort($data['keywords']);
  19434. }
  19435. if ($package->isAbandoned()) {
  19436. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  19437. }
  19438. }
  19439. if ($package instanceof RootPackageInterface) {
  19440. $minimumStability = $package->getMinimumStability();
  19441. if ($minimumStability) {
  19442. $data['minimum-stability'] = $minimumStability;
  19443. }
  19444. }
  19445. if (\count($package->getTransportOptions()) > 0) {
  19446. $data['transport-options'] = $package->getTransportOptions();
  19447. }
  19448. return $data;
  19449. }
  19450. private function dumpValues(PackageInterface $package, array $keys, array $data)
  19451. {
  19452. foreach ($keys as $method => $key) {
  19453. if (is_numeric($method)) {
  19454. $method = $key;
  19455. }
  19456. $getter = 'get'.ucfirst($method);
  19457. $value = $package->$getter();
  19458. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  19459. $data[$key] = $value;
  19460. }
  19461. }
  19462. return $data;
  19463. }
  19464. }
  19465. <?php
  19466. namespace Composer\Package;
  19467. use Composer\Semver\Constraint\ConstraintInterface;
  19468. class Link
  19469. {
  19470. const TYPE_REQUIRE = 'requires';
  19471. const TYPE_DEV_REQUIRE = 'devRequires';
  19472. const TYPE_PROVIDE = 'provides';
  19473. const TYPE_CONFLICT = 'conflicts';
  19474. const TYPE_REPLACE = 'replaces';
  19475. public static $TYPES = array(
  19476. self::TYPE_REQUIRE,
  19477. self::TYPE_DEV_REQUIRE,
  19478. self::TYPE_PROVIDE,
  19479. self::TYPE_CONFLICT,
  19480. self::TYPE_REPLACE,
  19481. );
  19482. protected $source;
  19483. protected $target;
  19484. protected $constraint;
  19485. protected $description;
  19486. protected $prettyConstraint;
  19487. public function __construct(
  19488. $source,
  19489. $target,
  19490. ConstraintInterface $constraint,
  19491. $description = 'relates to',
  19492. $prettyConstraint = null
  19493. ) {
  19494. $this->source = strtolower($source);
  19495. $this->target = strtolower($target);
  19496. $this->constraint = $constraint;
  19497. $this->description = $description;
  19498. $this->prettyConstraint = $prettyConstraint;
  19499. }
  19500. public function getDescription()
  19501. {
  19502. return $this->description;
  19503. }
  19504. public function getSource()
  19505. {
  19506. return $this->source;
  19507. }
  19508. public function getTarget()
  19509. {
  19510. return $this->target;
  19511. }
  19512. public function getConstraint()
  19513. {
  19514. return $this->constraint;
  19515. }
  19516. public function getPrettyConstraint()
  19517. {
  19518. if (null === $this->prettyConstraint) {
  19519. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  19520. }
  19521. return $this->prettyConstraint;
  19522. }
  19523. public function __toString()
  19524. {
  19525. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  19526. }
  19527. public function getPrettyString(PackageInterface $sourcePackage)
  19528. {
  19529. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.($this->constraint ? ' '.$this->constraint->getPrettyString() : '');
  19530. }
  19531. }
  19532. <?php
  19533. namespace Composer\Package\Loader;
  19534. use Composer\Package;
  19535. use Composer\Package\AliasPackage;
  19536. use Composer\Package\Link;
  19537. use Composer\Package\RootAliasPackage;
  19538. use Composer\Package\RootPackageInterface;
  19539. use Composer\Package\Version\VersionParser;
  19540. class ArrayLoader implements LoaderInterface
  19541. {
  19542. protected $versionParser;
  19543. protected $loadOptions;
  19544. public function __construct(VersionParser $parser = null, $loadOptions = false)
  19545. {
  19546. if (!$parser) {
  19547. $parser = new VersionParser;
  19548. }
  19549. $this->versionParser = $parser;
  19550. $this->loadOptions = $loadOptions;
  19551. }
  19552. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  19553. {
  19554. $package = $this->createObject($config, $class);
  19555. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19556. if (isset($config[$type])) {
  19557. $method = 'set'.ucfirst($opts['method']);
  19558. $package->{$method}(
  19559. $this->parseLinks(
  19560. $package->getName(),
  19561. $package->getPrettyVersion(),
  19562. $opts['description'],
  19563. $config[$type]
  19564. )
  19565. );
  19566. }
  19567. }
  19568. $package = $this->configureObject($package, $config);
  19569. return $package;
  19570. }
  19571. public function loadPackages(array $versions, $class)
  19572. {
  19573. $packages = array();
  19574. $linkCache = array();
  19575. foreach ($versions as $version) {
  19576. $package = $this->createObject($version, $class);
  19577. $this->configureCachedLinks($linkCache, $package, $version);
  19578. $package = $this->configureObject($package, $version);
  19579. $packages[] = $package;
  19580. }
  19581. return $packages;
  19582. }
  19583. private function createObject(array $config, $class)
  19584. {
  19585. if (!isset($config['name'])) {
  19586. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  19587. }
  19588. if (!isset($config['version'])) {
  19589. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  19590. }
  19591. if (isset($config['version_normalized'])) {
  19592. $version = $config['version_normalized'];
  19593. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  19594. $version = $this->versionParser->normalize($config['version']);
  19595. }
  19596. } else {
  19597. $version = $this->versionParser->normalize($config['version']);
  19598. }
  19599. return new $class($config['name'], $version, $config['version']);
  19600. }
  19601. private function configureObject($package, array $config)
  19602. {
  19603. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  19604. if (isset($config['target-dir'])) {
  19605. $package->setTargetDir($config['target-dir']);
  19606. }
  19607. if (isset($config['extra']) && \is_array($config['extra'])) {
  19608. $package->setExtra($config['extra']);
  19609. }
  19610. if (isset($config['bin'])) {
  19611. foreach ((array) $config['bin'] as $key => $bin) {
  19612. $config['bin'][$key] = ltrim($bin, '/');
  19613. }
  19614. $package->setBinaries((array) $config['bin']);
  19615. }
  19616. if (isset($config['installation-source'])) {
  19617. $package->setInstallationSource($config['installation-source']);
  19618. }
  19619. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19620. $package->setIsDefaultBranch(true);
  19621. }
  19622. if (isset($config['source'])) {
  19623. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  19624. throw new \UnexpectedValueException(sprintf(
  19625. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  19626. $config['name'],
  19627. json_encode($config['source'])
  19628. ));
  19629. }
  19630. $package->setSourceType($config['source']['type']);
  19631. $package->setSourceUrl($config['source']['url']);
  19632. $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
  19633. if (isset($config['source']['mirrors'])) {
  19634. $package->setSourceMirrors($config['source']['mirrors']);
  19635. }
  19636. }
  19637. if (isset($config['dist'])) {
  19638. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  19639. throw new \UnexpectedValueException(sprintf(
  19640. "Package %s's dist key should be specified as ".
  19641. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  19642. $config['name'],
  19643. json_encode($config['dist'])
  19644. ));
  19645. }
  19646. $package->setDistType($config['dist']['type']);
  19647. $package->setDistUrl($config['dist']['url']);
  19648. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  19649. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  19650. if (isset($config['dist']['mirrors'])) {
  19651. $package->setDistMirrors($config['dist']['mirrors']);
  19652. }
  19653. }
  19654. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  19655. foreach ($config['suggest'] as $target => $reason) {
  19656. if ('self.version' === trim($reason)) {
  19657. $config['suggest'][$target] = $package->getPrettyVersion();
  19658. }
  19659. }
  19660. $package->setSuggests($config['suggest']);
  19661. }
  19662. if (isset($config['autoload'])) {
  19663. $package->setAutoload($config['autoload']);
  19664. }
  19665. if (isset($config['autoload-dev'])) {
  19666. $package->setDevAutoload($config['autoload-dev']);
  19667. }
  19668. if (isset($config['include-path'])) {
  19669. $package->setIncludePaths($config['include-path']);
  19670. }
  19671. if (!empty($config['time'])) {
  19672. $time = preg_match('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  19673. try {
  19674. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  19675. $package->setReleaseDate($date);
  19676. } catch (\Exception $e) {
  19677. }
  19678. }
  19679. if (!empty($config['notification-url'])) {
  19680. $package->setNotificationUrl($config['notification-url']);
  19681. }
  19682. if (!empty($config['archive']['name'])) {
  19683. $package->setArchiveName($config['archive']['name']);
  19684. }
  19685. if (!empty($config['archive']['exclude'])) {
  19686. $package->setArchiveExcludes($config['archive']['exclude']);
  19687. }
  19688. if ($package instanceof Package\CompletePackageInterface) {
  19689. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  19690. foreach ($config['scripts'] as $event => $listeners) {
  19691. $config['scripts'][$event] = (array) $listeners;
  19692. }
  19693. if (isset($config['scripts']['composer'])) {
  19694. trigger_error('The `composer` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  19695. }
  19696. $package->setScripts($config['scripts']);
  19697. }
  19698. if (!empty($config['description']) && \is_string($config['description'])) {
  19699. $package->setDescription($config['description']);
  19700. }
  19701. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  19702. $package->setHomepage($config['homepage']);
  19703. }
  19704. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  19705. $package->setKeywords($config['keywords']);
  19706. }
  19707. if (!empty($config['license'])) {
  19708. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  19709. }
  19710. if (!empty($config['authors']) && \is_array($config['authors'])) {
  19711. $package->setAuthors($config['authors']);
  19712. }
  19713. if (isset($config['support'])) {
  19714. $package->setSupport($config['support']);
  19715. }
  19716. if (!empty($config['funding']) && \is_array($config['funding'])) {
  19717. $package->setFunding($config['funding']);
  19718. }
  19719. if (isset($config['abandoned'])) {
  19720. $package->setAbandoned($config['abandoned']);
  19721. }
  19722. }
  19723. if ($this->loadOptions && isset($config['transport-options'])) {
  19724. $package->setTransportOptions($config['transport-options']);
  19725. }
  19726. if ($aliasNormalized = $this->getBranchAlias($config)) {
  19727. $prettyAlias = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
  19728. if ($package instanceof RootPackageInterface) {
  19729. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  19730. }
  19731. return new AliasPackage($package, $aliasNormalized, $prettyAlias);
  19732. }
  19733. return $package;
  19734. }
  19735. private function configureCachedLinks(&$linkCache, $package, array $config)
  19736. {
  19737. $name = $package->getName();
  19738. $prettyVersion = $package->getPrettyVersion();
  19739. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19740. if (isset($config[$type])) {
  19741. $method = 'set'.ucfirst($opts['method']);
  19742. $links = array();
  19743. foreach ($config[$type] as $prettyTarget => $constraint) {
  19744. $target = strtolower($prettyTarget);
  19745. if ($constraint === 'self.version') {
  19746. $links[$target] = $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint);
  19747. } else {
  19748. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  19749. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint));
  19750. }
  19751. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  19752. $links[$target] = $link;
  19753. }
  19754. }
  19755. $package->{$method}($links);
  19756. }
  19757. }
  19758. }
  19759. public function parseLinks($source, $sourceVersion, $description, $links)
  19760. {
  19761. $res = array();
  19762. foreach ($links as $target => $constraint) {
  19763. $res[strtolower($target)] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  19764. }
  19765. return $res;
  19766. }
  19767. private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
  19768. {
  19769. if (!\is_string($prettyConstraint)) {
  19770. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  19771. }
  19772. if ('self.version' === $prettyConstraint) {
  19773. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  19774. } else {
  19775. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  19776. }
  19777. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  19778. }
  19779. public function getBranchAlias(array $config)
  19780. {
  19781. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  19782. return;
  19783. }
  19784. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  19785. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  19786. if ('-dev' !== substr($targetBranch, -4)) {
  19787. continue;
  19788. }
  19789. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  19790. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  19791. continue;
  19792. }
  19793. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  19794. continue;
  19795. }
  19796. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  19797. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  19798. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  19799. ) {
  19800. continue;
  19801. }
  19802. return $validatedTargetBranch;
  19803. }
  19804. }
  19805. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19806. return VersionParser::DEFAULT_BRANCH_ALIAS;
  19807. }
  19808. }
  19809. }
  19810. <?php
  19811. namespace Composer\Package\Loader;
  19812. class InvalidPackageException extends \Exception
  19813. {
  19814. private $errors;
  19815. private $warnings;
  19816. private $data;
  19817. public function __construct(array $errors, array $warnings, array $data)
  19818. {
  19819. $this->errors = $errors;
  19820. $this->warnings = $warnings;
  19821. $this->data = $data;
  19822. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  19823. }
  19824. public function getData()
  19825. {
  19826. return $this->data;
  19827. }
  19828. public function getErrors()
  19829. {
  19830. return $this->errors;
  19831. }
  19832. public function getWarnings()
  19833. {
  19834. return $this->warnings;
  19835. }
  19836. }
  19837. <?php
  19838. namespace Composer\Package\Loader;
  19839. use Composer\Json\JsonFile;
  19840. class JsonLoader
  19841. {
  19842. private $loader;
  19843. public function __construct(LoaderInterface $loader)
  19844. {
  19845. $this->loader = $loader;
  19846. }
  19847. public function load($json)
  19848. {
  19849. if ($json instanceof JsonFile) {
  19850. $config = $json->read();
  19851. } elseif (file_exists($json)) {
  19852. $config = JsonFile::parseJson(file_get_contents($json), $json);
  19853. } elseif (is_string($json)) {
  19854. $config = JsonFile::parseJson($json);
  19855. } else {
  19856. throw new \InvalidArgumentException(sprintf(
  19857. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  19858. gettype($json)
  19859. ));
  19860. }
  19861. return $this->loader->load($config);
  19862. }
  19863. }
  19864. <?php
  19865. namespace Composer\Package\Loader;
  19866. interface LoaderInterface
  19867. {
  19868. public function load(array $package, $class = 'Composer\Package\CompletePackage');
  19869. }
  19870. <?php
  19871. namespace Composer\Package\Loader;
  19872. use Composer\Package\BasePackage;
  19873. use Composer\Package\AliasPackage;
  19874. use Composer\Config;
  19875. use Composer\IO\IOInterface;
  19876. use Composer\Package\RootPackageInterface;
  19877. use Composer\Repository\RepositoryFactory;
  19878. use Composer\Package\Version\VersionGuesser;
  19879. use Composer\Package\Version\VersionParser;
  19880. use Composer\Package\RootPackage;
  19881. use Composer\Repository\RepositoryManager;
  19882. use Composer\Util\ProcessExecutor;
  19883. class RootPackageLoader extends ArrayLoader
  19884. {
  19885. private $manager;
  19886. private $config;
  19887. private $versionGuesser;
  19888. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  19889. {
  19890. parent::__construct($parser);
  19891. $this->manager = $manager;
  19892. $this->config = $config;
  19893. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  19894. }
  19895. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  19896. {
  19897. if (!isset($config['name'])) {
  19898. $config['name'] = '__root__';
  19899. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  19900. throw new \RuntimeException('Your package name '.$err);
  19901. }
  19902. $autoVersioned = false;
  19903. if (!isset($config['version'])) {
  19904. $commit = null;
  19905. if (isset($config['extra']['branch-version'])) {
  19906. $config['version'] = preg_replace('{(\.x)?(-dev)?$}', '', $config['extra']['branch-version']).'.x-dev';
  19907. } elseif (getenv('COMPOSER_ROOT_VERSION')) {
  19908. $config['version'] = getenv('COMPOSER_ROOT_VERSION');
  19909. } else {
  19910. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  19911. if ($versionData) {
  19912. $config['version'] = $versionData['pretty_version'];
  19913. $config['version_normalized'] = $versionData['version'];
  19914. $commit = $versionData['commit'];
  19915. }
  19916. }
  19917. if (!isset($config['version'])) {
  19918. $config['version'] = '1.0.0';
  19919. $autoVersioned = true;
  19920. }
  19921. if ($commit) {
  19922. $config['source'] = array(
  19923. 'type' => '',
  19924. 'url' => '',
  19925. 'reference' => $commit,
  19926. );
  19927. $config['dist'] = array(
  19928. 'type' => '',
  19929. 'url' => '',
  19930. 'reference' => $commit,
  19931. );
  19932. }
  19933. }
  19934. $realPackage = $package = parent::load($config, $class);
  19935. if ($realPackage instanceof AliasPackage) {
  19936. $realPackage = $package->getAliasOf();
  19937. }
  19938. if ($autoVersioned) {
  19939. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  19940. }
  19941. if (isset($config['minimum-stability'])) {
  19942. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  19943. }
  19944. $aliases = array();
  19945. $stabilityFlags = array();
  19946. $references = array();
  19947. foreach (array('require', 'require-dev') as $linkType) {
  19948. if (isset($config[$linkType])) {
  19949. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  19950. $method = 'get'.ucfirst($linkInfo['method']);
  19951. $links = array();
  19952. foreach ($realPackage->$method() as $link) {
  19953. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  19954. }
  19955. $aliases = $this->extractAliases($links, $aliases);
  19956. $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
  19957. $references = $this->extractReferences($links, $references);
  19958. if (isset($links[$config['name']])) {
  19959. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  19960. 'Did you accidentally name your root package after an external package?', $config['name']));
  19961. }
  19962. }
  19963. }
  19964. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  19965. if (isset($config[$linkType])) {
  19966. foreach ($config[$linkType] as $linkName => $constraint) {
  19967. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  19968. throw new \RuntimeException($linkType.'.'.$err);
  19969. }
  19970. }
  19971. }
  19972. }
  19973. $realPackage->setAliases($aliases);
  19974. $realPackage->setStabilityFlags($stabilityFlags);
  19975. $realPackage->setReferences($references);
  19976. if (isset($config['prefer-stable'])) {
  19977. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  19978. }
  19979. if (isset($config['config'])) {
  19980. $realPackage->setConfig($config['config']);
  19981. }
  19982. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  19983. foreach ($repos as $repo) {
  19984. $this->manager->addRepository($repo);
  19985. }
  19986. $realPackage->setRepositories($this->config->getRepositories());
  19987. return $package;
  19988. }
  19989. private function extractAliases(array $requires, array $aliases)
  19990. {
  19991. foreach ($requires as $reqName => $reqVersion) {
  19992. if (preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  19993. $aliases[] = array(
  19994. 'package' => strtolower($reqName),
  19995. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  19996. 'alias' => $match[2],
  19997. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  19998. );
  19999. } elseif (strpos($reqVersion, ' as ') !== false) {
  20000. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  20001. }
  20002. }
  20003. return $aliases;
  20004. }
  20005. private function extractStabilityFlags(array $requires, array $stabilityFlags, $minimumStability)
  20006. {
  20007. $stabilities = BasePackage::$stabilities;
  20008. $minimumStability = $stabilities[$minimumStability];
  20009. foreach ($requires as $reqName => $reqVersion) {
  20010. $constraints = array();
  20011. $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
  20012. foreach ($orSplit as $orConstraint) {
  20013. $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  20014. foreach ($andSplit as $andConstraint) {
  20015. $constraints[] = $andConstraint;
  20016. }
  20017. }
  20018. $match = false;
  20019. foreach ($constraints as $constraint) {
  20020. if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  20021. $name = strtolower($reqName);
  20022. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  20023. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  20024. continue;
  20025. }
  20026. $stabilityFlags[$name] = $stability;
  20027. $match = true;
  20028. }
  20029. }
  20030. if ($match) {
  20031. continue;
  20032. }
  20033. foreach ($constraints as $constraint) {
  20034. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  20035. if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  20036. $name = strtolower($reqName);
  20037. $stability = $stabilities[$stabilityName];
  20038. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  20039. continue;
  20040. }
  20041. $stabilityFlags[$name] = $stability;
  20042. }
  20043. }
  20044. }
  20045. return $stabilityFlags;
  20046. }
  20047. private function extractReferences(array $requires, array $references)
  20048. {
  20049. foreach ($requires as $reqName => $reqVersion) {
  20050. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  20051. if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  20052. $name = strtolower($reqName);
  20053. $references[$name] = $match[1];
  20054. }
  20055. }
  20056. return $references;
  20057. }
  20058. }
  20059. <?php
  20060. namespace Composer\Package\Loader;
  20061. use Composer\Package\BasePackage;
  20062. use Composer\Semver\Constraint\Constraint;
  20063. use Composer\Package\Version\VersionParser;
  20064. use Composer\Repository\PlatformRepository;
  20065. use Composer\Spdx\SpdxLicenses;
  20066. class ValidatingArrayLoader implements LoaderInterface
  20067. {
  20068. const CHECK_ALL = 3;
  20069. const CHECK_UNBOUND_CONSTRAINTS = 1;
  20070. const CHECK_STRICT_CONSTRAINTS = 2;
  20071. private $loader;
  20072. private $versionParser;
  20073. private $errors;
  20074. private $warnings;
  20075. private $config;
  20076. private $strictName;
  20077. private $flags;
  20078. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  20079. {
  20080. $this->loader = $loader;
  20081. $this->versionParser = $parser ?: new VersionParser();
  20082. $this->strictName = $strictName;
  20083. $this->flags = $flags;
  20084. }
  20085. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  20086. {
  20087. $this->errors = array();
  20088. $this->warnings = array();
  20089. $this->config = $config;
  20090. if ($err = self::hasPackageNamingError($config['name'])) {
  20091. $this->warnings[] = 'Deprecation warning: Your package name '.$err.' Make sure you fix this as Composer 2.0 will error.';
  20092. }
  20093. if ($this->strictName) {
  20094. $this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
  20095. } else {
  20096. $this->validateString('name', true);
  20097. }
  20098. if (!empty($this->config['version'])) {
  20099. try {
  20100. $this->versionParser->normalize($this->config['version']);
  20101. } catch (\Exception $e) {
  20102. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  20103. unset($this->config['version']);
  20104. }
  20105. }
  20106. if (!empty($this->config['config']['platform'])) {
  20107. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  20108. try {
  20109. $this->versionParser->normalize($platform);
  20110. } catch (\Exception $e) {
  20111. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  20112. }
  20113. }
  20114. }
  20115. $this->validateRegex('type', '[A-Za-z0-9-]+');
  20116. $this->validateString('target-dir');
  20117. $this->validateArray('extra');
  20118. if (isset($this->config['bin'])) {
  20119. if (is_string($this->config['bin'])) {
  20120. $this->validateString('bin');
  20121. } else {
  20122. $this->validateFlatArray('bin');
  20123. }
  20124. }
  20125. $this->validateArray('scripts');
  20126. $this->validateString('description');
  20127. $this->validateUrl('homepage');
  20128. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  20129. $releaseDate = null;
  20130. $this->validateString('time');
  20131. if (!empty($this->config['time'])) {
  20132. try {
  20133. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  20134. } catch (\Exception $e) {
  20135. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  20136. unset($this->config['time']);
  20137. }
  20138. }
  20139. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  20140. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  20141. $licenses = (array) $this->config['license'];
  20142. $licenseValidator = new SpdxLicenses();
  20143. foreach ($licenses as $license) {
  20144. if ('proprietary' === $license) {
  20145. continue;
  20146. }
  20147. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  20148. if (!$licenseValidator->validate($licenseToValidate)) {
  20149. if ($licenseValidator->validate(trim($licenseToValidate))) {
  20150. $this->warnings[] = sprintf(
  20151. 'License %s must not contain extra spaces, make sure to trim it.',
  20152. json_encode($license)
  20153. );
  20154. } else {
  20155. $this->warnings[] = sprintf(
  20156. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  20157. 'If the software is closed-source, you may use "proprietary" as license.',
  20158. json_encode($license)
  20159. );
  20160. }
  20161. }
  20162. }
  20163. }
  20164. }
  20165. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  20166. foreach ($this->config['authors'] as $key => $author) {
  20167. if (!is_array($author)) {
  20168. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  20169. unset($this->config['authors'][$key]);
  20170. continue;
  20171. }
  20172. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  20173. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  20174. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  20175. unset($this->config['authors'][$key][$authorData]);
  20176. }
  20177. }
  20178. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  20179. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  20180. unset($this->config['authors'][$key]['homepage']);
  20181. }
  20182. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  20183. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  20184. unset($this->config['authors'][$key]['email']);
  20185. }
  20186. if (empty($this->config['authors'][$key])) {
  20187. unset($this->config['authors'][$key]);
  20188. }
  20189. }
  20190. if (empty($this->config['authors'])) {
  20191. unset($this->config['authors']);
  20192. }
  20193. }
  20194. if ($this->validateArray('support') && !empty($this->config['support'])) {
  20195. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  20196. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  20197. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  20198. unset($this->config['support'][$key]);
  20199. }
  20200. }
  20201. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  20202. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  20203. unset($this->config['support']['email']);
  20204. }
  20205. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc'))) {
  20206. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> URL';
  20207. unset($this->config['support']['irc']);
  20208. }
  20209. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  20210. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  20211. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  20212. unset($this->config['support'][$key]);
  20213. }
  20214. }
  20215. if (empty($this->config['support'])) {
  20216. unset($this->config['support']);
  20217. }
  20218. }
  20219. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  20220. foreach ($this->config['funding'] as $key => $fundingOption) {
  20221. if (!is_array($fundingOption)) {
  20222. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  20223. unset($this->config['funding'][$key]);
  20224. continue;
  20225. }
  20226. foreach (array('type', 'url') as $fundingData) {
  20227. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  20228. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  20229. unset($this->config['funding'][$key][$fundingData]);
  20230. }
  20231. }
  20232. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  20233. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  20234. unset($this->config['funding'][$key]['url']);
  20235. }
  20236. if (empty($this->config['funding'][$key])) {
  20237. unset($this->config['funding'][$key]);
  20238. }
  20239. }
  20240. if (empty($this->config['funding'])) {
  20241. unset($this->config['funding']);
  20242. }
  20243. }
  20244. $unboundConstraint = new Constraint('=', '10000000-dev');
  20245. $stableConstraint = new Constraint('=', '1.0.0');
  20246. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20247. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  20248. foreach ($this->config[$linkType] as $package => $constraint) {
  20249. if ($err = self::hasPackageNamingError($package, true)) {
  20250. $this->warnings[] = 'Deprecation warning: '.$linkType.'.'.$err.' Make sure you fix this as Composer 2.0 will error.';
  20251. } elseif (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
  20252. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  20253. }
  20254. if (!is_string($constraint)) {
  20255. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  20256. unset($this->config[$linkType][$package]);
  20257. } elseif ('self.version' !== $constraint) {
  20258. try {
  20259. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  20260. } catch (\Exception $e) {
  20261. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  20262. unset($this->config[$linkType][$package]);
  20263. continue;
  20264. }
  20265. if (
  20266. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  20267. && 'require' === $linkType
  20268. && $linkConstraint->matches($unboundConstraint)
  20269. && !PlatformRepository::isPlatformPackage($package)
  20270. ) {
  20271. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  20272. } elseif (
  20273. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  20274. && 'require' === $linkType
  20275. && strpos($linkConstraint, '=') === 0
  20276. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  20277. ) {
  20278. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  20279. }
  20280. }
  20281. }
  20282. }
  20283. }
  20284. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  20285. foreach ($this->config['suggest'] as $package => $description) {
  20286. if (!is_string($description)) {
  20287. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  20288. unset($this->config['suggest'][$package]);
  20289. }
  20290. }
  20291. }
  20292. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  20293. if (!isset(BasePackage::$stabilities[$this->config['minimum-stability']])) {
  20294. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  20295. unset($this->config['minimum-stability']);
  20296. }
  20297. }
  20298. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  20299. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  20300. foreach ($this->config['autoload'] as $type => $typeConfig) {
  20301. if (!in_array($type, $types)) {
  20302. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  20303. unset($this->config['autoload'][$type]);
  20304. }
  20305. if ($type === 'psr-4') {
  20306. foreach ($typeConfig as $namespace => $dirs) {
  20307. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  20308. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  20309. }
  20310. }
  20311. }
  20312. }
  20313. }
  20314. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  20315. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  20316. unset($this->config['autoload']['psr-4']);
  20317. }
  20318. $this->validateFlatArray('include-path');
  20319. $this->validateArray('transport-options');
  20320. if (isset($this->config['extra']['branch-alias'])) {
  20321. if (!is_array($this->config['extra']['branch-alias'])) {
  20322. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  20323. } else {
  20324. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  20325. if ('-dev' !== substr($targetBranch, -4)) {
  20326. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  20327. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20328. continue;
  20329. }
  20330. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  20331. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  20332. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  20333. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20334. continue;
  20335. }
  20336. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  20337. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  20338. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  20339. ) {
  20340. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  20341. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20342. }
  20343. }
  20344. }
  20345. }
  20346. if ($this->errors) {
  20347. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  20348. }
  20349. $package = $this->loader->load($this->config, $class);
  20350. $this->config = null;
  20351. return $package;
  20352. }
  20353. public function getWarnings()
  20354. {
  20355. return $this->warnings;
  20356. }
  20357. public function getErrors()
  20358. {
  20359. return $this->errors;
  20360. }
  20361. public static function hasPackageNamingError($name, $isLink = false)
  20362. {
  20363. if (PlatformRepository::isPlatformPackage($name)) {
  20364. return;
  20365. }
  20366. if (!preg_match('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  20367. 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]+)*$".';
  20368. }
  20369. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  20370. $bits = explode('/', strtolower($name));
  20371. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  20372. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  20373. }
  20374. if (preg_match('{\.json$}', $name)) {
  20375. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  20376. }
  20377. if (preg_match('{[A-Z]}', $name)) {
  20378. if ($isLink) {
  20379. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  20380. }
  20381. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  20382. $suggestName = strtolower($suggestName);
  20383. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  20384. }
  20385. }
  20386. private function validateRegex($property, $regex, $mandatory = false)
  20387. {
  20388. if (!$this->validateString($property, $mandatory)) {
  20389. return false;
  20390. }
  20391. if (!preg_match('{^'.$regex.'$}u', $this->config[$property])) {
  20392. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  20393. if ($mandatory) {
  20394. $this->errors[] = $message;
  20395. } else {
  20396. $this->warnings[] = $message;
  20397. }
  20398. unset($this->config[$property]);
  20399. return false;
  20400. }
  20401. return true;
  20402. }
  20403. private function validateString($property, $mandatory = false)
  20404. {
  20405. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  20406. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  20407. unset($this->config[$property]);
  20408. return false;
  20409. }
  20410. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  20411. if ($mandatory) {
  20412. $this->errors[] = $property.' : must be present';
  20413. }
  20414. unset($this->config[$property]);
  20415. return false;
  20416. }
  20417. return true;
  20418. }
  20419. private function validateArray($property, $mandatory = false)
  20420. {
  20421. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  20422. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  20423. unset($this->config[$property]);
  20424. return false;
  20425. }
  20426. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  20427. if ($mandatory) {
  20428. $this->errors[] = $property.' : must be present and contain at least one element';
  20429. }
  20430. unset($this->config[$property]);
  20431. return false;
  20432. }
  20433. return true;
  20434. }
  20435. private function validateFlatArray($property, $regex = null, $mandatory = false)
  20436. {
  20437. if (!$this->validateArray($property, $mandatory)) {
  20438. return false;
  20439. }
  20440. $pass = true;
  20441. foreach ($this->config[$property] as $key => $value) {
  20442. if (!is_string($value) && !is_numeric($value)) {
  20443. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  20444. unset($this->config[$property][$key]);
  20445. $pass = false;
  20446. continue;
  20447. }
  20448. if ($regex && !preg_match('{^'.$regex.'$}u', $value)) {
  20449. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  20450. unset($this->config[$property][$key]);
  20451. $pass = false;
  20452. }
  20453. }
  20454. return $pass;
  20455. }
  20456. private function validateUrl($property, $mandatory = false)
  20457. {
  20458. if (!$this->validateString($property, $mandatory)) {
  20459. return false;
  20460. }
  20461. if (!$this->filterUrl($this->config[$property])) {
  20462. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  20463. unset($this->config[$property]);
  20464. return false;
  20465. }
  20466. return true;
  20467. }
  20468. private function filterUrl($value, array $schemes = array('http', 'https'))
  20469. {
  20470. if ($value === '') {
  20471. return true;
  20472. }
  20473. $bits = parse_url($value);
  20474. if (empty($bits['scheme']) || empty($bits['host'])) {
  20475. return false;
  20476. }
  20477. if (!in_array($bits['scheme'], $schemes, true)) {
  20478. return false;
  20479. }
  20480. return true;
  20481. }
  20482. }
  20483. <?php
  20484. namespace Composer\Package;
  20485. use Composer\Json\JsonFile;
  20486. use Composer\Installer\InstallationManager;
  20487. use Composer\Repository\LockArrayRepository;
  20488. use Composer\Repository\RepositoryManager;
  20489. use Composer\Util\ProcessExecutor;
  20490. use Composer\Package\Dumper\ArrayDumper;
  20491. use Composer\Package\Loader\ArrayLoader;
  20492. use Composer\Package\Version\VersionParser;
  20493. use Composer\Plugin\PluginInterface;
  20494. use Composer\Util\Git as GitUtil;
  20495. use Composer\IO\IOInterface;
  20496. use Seld\JsonLint\ParsingException;
  20497. class Locker
  20498. {
  20499. private $lockFile;
  20500. private $installationManager;
  20501. private $hash;
  20502. private $contentHash;
  20503. private $loader;
  20504. private $dumper;
  20505. private $process;
  20506. private $lockDataCache;
  20507. private $virtualFileWritten;
  20508. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents, ProcessExecutor $process = null)
  20509. {
  20510. $this->lockFile = $lockFile;
  20511. $this->installationManager = $installationManager;
  20512. $this->hash = md5($composerFileContents);
  20513. $this->contentHash = self::getContentHash($composerFileContents);
  20514. $this->loader = new ArrayLoader(null, true);
  20515. $this->dumper = new ArrayDumper();
  20516. $this->process = $process ?: new ProcessExecutor($io);
  20517. }
  20518. public static function getContentHash($composerFileContents)
  20519. {
  20520. $content = json_decode($composerFileContents, true);
  20521. $relevantKeys = array(
  20522. 'name',
  20523. 'version',
  20524. 'require',
  20525. 'require-dev',
  20526. 'conflict',
  20527. 'replace',
  20528. 'provide',
  20529. 'minimum-stability',
  20530. 'prefer-stable',
  20531. 'repositories',
  20532. 'extra',
  20533. );
  20534. $relevantContent = array();
  20535. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  20536. $relevantContent[$key] = $content[$key];
  20537. }
  20538. if (isset($content['config']['platform'])) {
  20539. $relevantContent['config']['platform'] = $content['config']['platform'];
  20540. }
  20541. ksort($relevantContent);
  20542. return md5(json_encode($relevantContent));
  20543. }
  20544. public function isLocked()
  20545. {
  20546. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  20547. return false;
  20548. }
  20549. $data = $this->getLockData();
  20550. return isset($data['packages']);
  20551. }
  20552. public function isFresh()
  20553. {
  20554. $lock = $this->lockFile->read();
  20555. if (!empty($lock['content-hash'])) {
  20556. return $this->contentHash === $lock['content-hash'];
  20557. }
  20558. if (!empty($lock['hash'])) {
  20559. return $this->hash === $lock['hash'];
  20560. }
  20561. return false;
  20562. }
  20563. public function getLockedRepository($withDevReqs = false)
  20564. {
  20565. $lockData = $this->getLockData();
  20566. $packages = new LockArrayRepository();
  20567. $lockedPackages = $lockData['packages'];
  20568. if ($withDevReqs) {
  20569. if (isset($lockData['packages-dev'])) {
  20570. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  20571. } else {
  20572. 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.');
  20573. }
  20574. }
  20575. if (empty($lockedPackages)) {
  20576. return $packages;
  20577. }
  20578. if (isset($lockedPackages[0]['name'])) {
  20579. $packageByName = array();
  20580. foreach ($lockedPackages as $info) {
  20581. $package = $this->loader->load($info);
  20582. $packages->addPackage($package);
  20583. $packageByName[$package->getName()] = $package;
  20584. if ($package instanceof AliasPackage) {
  20585. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  20586. }
  20587. }
  20588. if (isset($lockData['aliases'])) {
  20589. foreach ($lockData['aliases'] as $alias) {
  20590. if (isset($packageByName[$alias['package']])) {
  20591. $aliasPkg = new AliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  20592. $aliasPkg->setRootPackageAlias(true);
  20593. $packages->addPackage($aliasPkg);
  20594. }
  20595. }
  20596. }
  20597. return $packages;
  20598. }
  20599. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  20600. }
  20601. public function getDevPackageNames()
  20602. {
  20603. $names = array();
  20604. $lockData = $this->getLockData();
  20605. if (isset($lockData['packages-dev'])) {
  20606. foreach ($lockData['packages-dev'] as $package) {
  20607. $names[] = strtolower($package['name']);
  20608. }
  20609. }
  20610. return $names;
  20611. }
  20612. public function getPlatformRequirements($withDevReqs = false)
  20613. {
  20614. $lockData = $this->getLockData();
  20615. $requirements = array();
  20616. if (!empty($lockData['platform'])) {
  20617. $requirements = $this->loader->parseLinks(
  20618. '__root__',
  20619. '1.0.0',
  20620. Link::TYPE_REQUIRE,
  20621. isset($lockData['platform']) ? $lockData['platform'] : array()
  20622. );
  20623. }
  20624. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  20625. $devRequirements = $this->loader->parseLinks(
  20626. '__root__',
  20627. '1.0.0',
  20628. Link::TYPE_REQUIRE,
  20629. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  20630. );
  20631. $requirements = array_merge($requirements, $devRequirements);
  20632. }
  20633. return $requirements;
  20634. }
  20635. public function getMinimumStability()
  20636. {
  20637. $lockData = $this->getLockData();
  20638. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  20639. }
  20640. public function getStabilityFlags()
  20641. {
  20642. $lockData = $this->getLockData();
  20643. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  20644. }
  20645. public function getPreferStable()
  20646. {
  20647. $lockData = $this->getLockData();
  20648. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  20649. }
  20650. public function getPreferLowest()
  20651. {
  20652. $lockData = $this->getLockData();
  20653. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  20654. }
  20655. public function getPlatformOverrides()
  20656. {
  20657. $lockData = $this->getLockData();
  20658. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  20659. }
  20660. public function getAliases()
  20661. {
  20662. $lockData = $this->getLockData();
  20663. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  20664. }
  20665. public function getLockData()
  20666. {
  20667. if (null !== $this->lockDataCache) {
  20668. return $this->lockDataCache;
  20669. }
  20670. if (!$this->lockFile->exists()) {
  20671. throw new \LogicException('No lockfile found. Unable to read locked packages');
  20672. }
  20673. return $this->lockDataCache = $this->lockFile->read();
  20674. }
  20675. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
  20676. {
  20677. $aliases = array_map(function ($alias) {
  20678. if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  20679. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  20680. }
  20681. return $alias;
  20682. }, $aliases);
  20683. $lock = array(
  20684. '_readme' => array('This file locks the dependencies of your project to a known state',
  20685. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  20686. 'This file is @gener'.'ated automatically', ),
  20687. 'content-hash' => $this->contentHash,
  20688. 'packages' => null,
  20689. 'packages-dev' => null,
  20690. 'aliases' => $aliases,
  20691. 'minimum-stability' => $minimumStability,
  20692. 'stability-flags' => $stabilityFlags,
  20693. 'prefer-stable' => $preferStable,
  20694. 'prefer-lowest' => $preferLowest,
  20695. );
  20696. $lock['packages'] = $this->lockPackages($packages);
  20697. if (null !== $devPackages) {
  20698. $lock['packages-dev'] = $this->lockPackages($devPackages);
  20699. }
  20700. $lock['platform'] = $platformReqs;
  20701. $lock['platform-dev'] = $platformDevReqs;
  20702. if ($platformOverrides) {
  20703. $lock['platform-overrides'] = $platformOverrides;
  20704. }
  20705. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  20706. try {
  20707. $isLocked = $this->isLocked();
  20708. } catch (ParsingException $e) {
  20709. $isLocked = false;
  20710. }
  20711. if (!$isLocked || $lock !== $this->getLockData()) {
  20712. if ($write) {
  20713. $this->lockFile->write($lock);
  20714. $this->lockDataCache = null;
  20715. $this->virtualFileWritten = false;
  20716. } else {
  20717. $this->virtualFileWritten = true;
  20718. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT));
  20719. }
  20720. return true;
  20721. }
  20722. return false;
  20723. }
  20724. private function lockPackages(array $packages)
  20725. {
  20726. $locked = array();
  20727. foreach ($packages as $package) {
  20728. if ($package instanceof AliasPackage) {
  20729. continue;
  20730. }
  20731. $name = $package->getPrettyName();
  20732. $version = $package->getPrettyVersion();
  20733. if (!$name || !$version) {
  20734. throw new \LogicException(sprintf(
  20735. 'Package "%s" has no version or name and can not be locked',
  20736. $package
  20737. ));
  20738. }
  20739. $spec = $this->dumper->dump($package);
  20740. unset($spec['version_normalized']);
  20741. $time = isset($spec['time']) ? $spec['time'] : null;
  20742. unset($spec['time']);
  20743. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  20744. $time = $this->getPackageTime($package) ?: $time;
  20745. }
  20746. if (null !== $time) {
  20747. $spec['time'] = $time;
  20748. }
  20749. unset($spec['installation-source']);
  20750. $locked[] = $spec;
  20751. }
  20752. usort($locked, function ($a, $b) {
  20753. $comparison = strcmp($a['name'], $b['name']);
  20754. if (0 !== $comparison) {
  20755. return $comparison;
  20756. }
  20757. return strcmp($a['version'], $b['version']);
  20758. });
  20759. return $locked;
  20760. }
  20761. private function getPackageTime(PackageInterface $package)
  20762. {
  20763. if (!function_exists('proc_open')) {
  20764. return null;
  20765. }
  20766. $path = realpath($this->installationManager->getInstallPath($package));
  20767. $sourceType = $package->getSourceType();
  20768. $datetime = null;
  20769. if ($path && in_array($sourceType, array('git', 'hg'))) {
  20770. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  20771. switch ($sourceType) {
  20772. case 'git':
  20773. GitUtil::cleanEnv();
  20774. 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)) {
  20775. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  20776. }
  20777. break;
  20778. case 'hg':
  20779. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) {
  20780. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  20781. }
  20782. break;
  20783. }
  20784. }
  20785. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  20786. }
  20787. }
  20788. <?php
  20789. namespace Composer\Package;
  20790. use Composer\Package\Version\VersionParser;
  20791. use Composer\Util\ComposerMirror;
  20792. class Package extends BasePackage
  20793. {
  20794. protected $type;
  20795. protected $targetDir;
  20796. protected $installationSource;
  20797. protected $sourceType;
  20798. protected $sourceUrl;
  20799. protected $sourceReference;
  20800. protected $sourceMirrors;
  20801. protected $distType;
  20802. protected $distUrl;
  20803. protected $distReference;
  20804. protected $distSha1Checksum;
  20805. protected $distMirrors;
  20806. protected $version;
  20807. protected $prettyVersion;
  20808. protected $releaseDate;
  20809. protected $extra = array();
  20810. protected $binaries = array();
  20811. protected $dev;
  20812. protected $stability;
  20813. protected $notificationUrl;
  20814. protected $requires = array();
  20815. protected $conflicts = array();
  20816. protected $provides = array();
  20817. protected $replaces = array();
  20818. protected $devRequires = array();
  20819. protected $suggests = array();
  20820. protected $autoload = array();
  20821. protected $devAutoload = array();
  20822. protected $includePaths = array();
  20823. protected $archiveName;
  20824. protected $archiveExcludes = array();
  20825. protected $isDefaultBranch = false;
  20826. public function __construct($name, $version, $prettyVersion)
  20827. {
  20828. parent::__construct($name);
  20829. $this->version = $version;
  20830. $this->prettyVersion = $prettyVersion;
  20831. $this->stability = VersionParser::parseStability($version);
  20832. $this->dev = $this->stability === 'dev';
  20833. }
  20834. public function isDev()
  20835. {
  20836. return $this->dev;
  20837. }
  20838. public function setType($type)
  20839. {
  20840. $this->type = $type;
  20841. }
  20842. public function getType()
  20843. {
  20844. return $this->type ?: 'library';
  20845. }
  20846. public function getStability()
  20847. {
  20848. return $this->stability;
  20849. }
  20850. public function setTargetDir($targetDir)
  20851. {
  20852. $this->targetDir = $targetDir;
  20853. }
  20854. public function getTargetDir()
  20855. {
  20856. if (null === $this->targetDir) {
  20857. return;
  20858. }
  20859. return ltrim(preg_replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  20860. }
  20861. public function setExtra(array $extra)
  20862. {
  20863. $this->extra = $extra;
  20864. }
  20865. public function getExtra()
  20866. {
  20867. return $this->extra;
  20868. }
  20869. public function setBinaries(array $binaries)
  20870. {
  20871. $this->binaries = $binaries;
  20872. }
  20873. public function getBinaries()
  20874. {
  20875. return $this->binaries;
  20876. }
  20877. public function setInstallationSource($type)
  20878. {
  20879. $this->installationSource = $type;
  20880. }
  20881. public function getInstallationSource()
  20882. {
  20883. return $this->installationSource;
  20884. }
  20885. public function setSourceType($type)
  20886. {
  20887. $this->sourceType = $type;
  20888. }
  20889. public function getSourceType()
  20890. {
  20891. return $this->sourceType;
  20892. }
  20893. public function setSourceUrl($url)
  20894. {
  20895. $this->sourceUrl = $url;
  20896. }
  20897. public function getSourceUrl()
  20898. {
  20899. return $this->sourceUrl;
  20900. }
  20901. public function setSourceReference($reference)
  20902. {
  20903. $this->sourceReference = $reference;
  20904. }
  20905. public function getSourceReference()
  20906. {
  20907. return $this->sourceReference;
  20908. }
  20909. public function setSourceMirrors($mirrors)
  20910. {
  20911. $this->sourceMirrors = $mirrors;
  20912. }
  20913. public function getSourceMirrors()
  20914. {
  20915. return $this->sourceMirrors;
  20916. }
  20917. public function getSourceUrls()
  20918. {
  20919. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  20920. }
  20921. public function setDistType($type)
  20922. {
  20923. $this->distType = $type;
  20924. }
  20925. public function getDistType()
  20926. {
  20927. return $this->distType;
  20928. }
  20929. public function setDistUrl($url)
  20930. {
  20931. $this->distUrl = $url;
  20932. }
  20933. public function getDistUrl()
  20934. {
  20935. return $this->distUrl;
  20936. }
  20937. public function setDistReference($reference)
  20938. {
  20939. $this->distReference = $reference;
  20940. }
  20941. public function getDistReference()
  20942. {
  20943. return $this->distReference;
  20944. }
  20945. public function setDistSha1Checksum($sha1checksum)
  20946. {
  20947. $this->distSha1Checksum = $sha1checksum;
  20948. }
  20949. public function getDistSha1Checksum()
  20950. {
  20951. return $this->distSha1Checksum;
  20952. }
  20953. public function setDistMirrors($mirrors)
  20954. {
  20955. $this->distMirrors = $mirrors;
  20956. }
  20957. public function getDistMirrors()
  20958. {
  20959. return $this->distMirrors;
  20960. }
  20961. public function getDistUrls()
  20962. {
  20963. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  20964. }
  20965. public function getVersion()
  20966. {
  20967. return $this->version;
  20968. }
  20969. public function getPrettyVersion()
  20970. {
  20971. return $this->prettyVersion;
  20972. }
  20973. public function setReleaseDate(\DateTime $releaseDate)
  20974. {
  20975. $this->releaseDate = $releaseDate;
  20976. }
  20977. public function getReleaseDate()
  20978. {
  20979. return $this->releaseDate;
  20980. }
  20981. public function setRequires(array $requires)
  20982. {
  20983. $this->requires = $requires;
  20984. }
  20985. public function getRequires()
  20986. {
  20987. return $this->requires;
  20988. }
  20989. public function setConflicts(array $conflicts)
  20990. {
  20991. $this->conflicts = $conflicts;
  20992. }
  20993. public function getConflicts()
  20994. {
  20995. return $this->conflicts;
  20996. }
  20997. public function setProvides(array $provides)
  20998. {
  20999. $this->provides = $provides;
  21000. }
  21001. public function getProvides()
  21002. {
  21003. return $this->provides;
  21004. }
  21005. public function setReplaces(array $replaces)
  21006. {
  21007. $this->replaces = $replaces;
  21008. }
  21009. public function getReplaces()
  21010. {
  21011. return $this->replaces;
  21012. }
  21013. public function setDevRequires(array $devRequires)
  21014. {
  21015. $this->devRequires = $devRequires;
  21016. }
  21017. public function getDevRequires()
  21018. {
  21019. return $this->devRequires;
  21020. }
  21021. public function setSuggests(array $suggests)
  21022. {
  21023. $this->suggests = $suggests;
  21024. }
  21025. public function getSuggests()
  21026. {
  21027. return $this->suggests;
  21028. }
  21029. public function setAutoload(array $autoload)
  21030. {
  21031. $this->autoload = $autoload;
  21032. }
  21033. public function getAutoload()
  21034. {
  21035. return $this->autoload;
  21036. }
  21037. public function setDevAutoload(array $devAutoload)
  21038. {
  21039. $this->devAutoload = $devAutoload;
  21040. }
  21041. public function getDevAutoload()
  21042. {
  21043. return $this->devAutoload;
  21044. }
  21045. public function setIncludePaths(array $includePaths)
  21046. {
  21047. $this->includePaths = $includePaths;
  21048. }
  21049. public function getIncludePaths()
  21050. {
  21051. return $this->includePaths;
  21052. }
  21053. public function setNotificationUrl($notificationUrl)
  21054. {
  21055. $this->notificationUrl = $notificationUrl;
  21056. }
  21057. public function getNotificationUrl()
  21058. {
  21059. return $this->notificationUrl;
  21060. }
  21061. public function setArchiveName($name)
  21062. {
  21063. $this->archiveName = $name;
  21064. }
  21065. public function getArchiveName()
  21066. {
  21067. return $this->archiveName;
  21068. }
  21069. public function setArchiveExcludes(array $excludes)
  21070. {
  21071. $this->archiveExcludes = $excludes;
  21072. }
  21073. public function getArchiveExcludes()
  21074. {
  21075. return $this->archiveExcludes;
  21076. }
  21077. public function setIsDefaultBranch($defaultBranch)
  21078. {
  21079. $this->isDefaultBranch = $defaultBranch;
  21080. }
  21081. public function isDefaultBranch()
  21082. {
  21083. return $this->isDefaultBranch;
  21084. }
  21085. public function setSourceDistReferences($reference)
  21086. {
  21087. $this->setSourceReference($reference);
  21088. if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())) {
  21089. $this->setDistReference($reference);
  21090. $this->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  21091. } elseif ($this->getDistReference()) {
  21092. $this->setDistReference($reference);
  21093. }
  21094. }
  21095. public function replaceVersion($version, $prettyVersion)
  21096. {
  21097. $this->version = $version;
  21098. $this->prettyVersion = $prettyVersion;
  21099. $this->stability = VersionParser::parseStability($version);
  21100. $this->dev = $this->stability === 'dev';
  21101. }
  21102. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  21103. {
  21104. if (!$url) {
  21105. return array();
  21106. }
  21107. $urls = array($url);
  21108. if ($mirrors) {
  21109. foreach ($mirrors as $mirror) {
  21110. if ($urlType === 'dist') {
  21111. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
  21112. } elseif ($urlType === 'source' && $type === 'git') {
  21113. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  21114. } elseif ($urlType === 'source' && $type === 'hg') {
  21115. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  21116. } else {
  21117. continue;
  21118. }
  21119. if (!\in_array($mirrorUrl, $urls)) {
  21120. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  21121. $func($urls, $mirrorUrl);
  21122. }
  21123. }
  21124. }
  21125. return $urls;
  21126. }
  21127. }
  21128. <?php
  21129. namespace Composer\Package;
  21130. use Composer\Repository\RepositoryInterface;
  21131. interface PackageInterface
  21132. {
  21133. const DISPLAY_SOURCE_REF_IF_DEV = 0;
  21134. const DISPLAY_SOURCE_REF = 1;
  21135. const DISPLAY_DIST_REF = 2;
  21136. public function getName();
  21137. public function getPrettyName();
  21138. public function getNames($provides = true);
  21139. public function setId($id);
  21140. public function getId();
  21141. public function isDev();
  21142. public function getType();
  21143. public function getTargetDir();
  21144. public function getExtra();
  21145. public function setInstallationSource($type);
  21146. public function getInstallationSource();
  21147. public function getSourceType();
  21148. public function getSourceUrl();
  21149. public function getSourceUrls();
  21150. public function getSourceReference();
  21151. public function getSourceMirrors();
  21152. public function getDistType();
  21153. public function getDistUrl();
  21154. public function getDistUrls();
  21155. public function getDistReference();
  21156. public function getDistSha1Checksum();
  21157. public function getDistMirrors();
  21158. public function getVersion();
  21159. public function getPrettyVersion();
  21160. public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
  21161. public function getReleaseDate();
  21162. public function getStability();
  21163. public function getRequires();
  21164. public function getConflicts();
  21165. public function getProvides();
  21166. public function getReplaces();
  21167. public function getDevRequires();
  21168. public function getSuggests();
  21169. public function getAutoload();
  21170. public function getDevAutoload();
  21171. public function getIncludePaths();
  21172. public function setRepository(RepositoryInterface $repository);
  21173. public function getRepository();
  21174. public function getBinaries();
  21175. public function getUniqueName();
  21176. public function getNotificationUrl();
  21177. public function __toString();
  21178. public function getPrettyString();
  21179. public function getArchiveName();
  21180. public function getArchiveExcludes();
  21181. public function isDefaultBranch();
  21182. public function getTransportOptions();
  21183. public function setSourceReference($reference);
  21184. public function setDistUrl($url);
  21185. public function setDistType($type);
  21186. public function setDistReference($reference);
  21187. public function setSourceDistReferences($reference);
  21188. }
  21189. <?php
  21190. namespace Composer\Package;
  21191. class RootAliasPackage extends AliasPackage implements RootPackageInterface
  21192. {
  21193. public function __construct(RootPackageInterface $aliasOf, $version, $prettyVersion)
  21194. {
  21195. parent::__construct($aliasOf, $version, $prettyVersion);
  21196. }
  21197. public function getAliases()
  21198. {
  21199. return $this->aliasOf->getAliases();
  21200. }
  21201. public function getMinimumStability()
  21202. {
  21203. return $this->aliasOf->getMinimumStability();
  21204. }
  21205. public function getStabilityFlags()
  21206. {
  21207. return $this->aliasOf->getStabilityFlags();
  21208. }
  21209. public function getReferences()
  21210. {
  21211. return $this->aliasOf->getReferences();
  21212. }
  21213. public function getPreferStable()
  21214. {
  21215. return $this->aliasOf->getPreferStable();
  21216. }
  21217. public function getConfig()
  21218. {
  21219. return $this->aliasOf->getConfig();
  21220. }
  21221. public function setRequires(array $require)
  21222. {
  21223. $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
  21224. $this->aliasOf->setRequires($require);
  21225. }
  21226. public function setDevRequires(array $devRequire)
  21227. {
  21228. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
  21229. $this->aliasOf->setDevRequires($devRequire);
  21230. }
  21231. public function setConflicts(array $conflicts)
  21232. {
  21233. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  21234. $this->aliasOf->setConflicts($conflicts);
  21235. }
  21236. public function setProvides(array $provides)
  21237. {
  21238. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  21239. $this->aliasOf->setProvides($provides);
  21240. }
  21241. public function setReplaces(array $replaces)
  21242. {
  21243. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  21244. $this->aliasOf->setReplaces($replaces);
  21245. }
  21246. public function setRepositories($repositories)
  21247. {
  21248. $this->aliasOf->setRepositories($repositories);
  21249. }
  21250. public function setAutoload(array $autoload)
  21251. {
  21252. $this->aliasOf->setAutoload($autoload);
  21253. }
  21254. public function setDevAutoload(array $devAutoload)
  21255. {
  21256. $this->aliasOf->setDevAutoload($devAutoload);
  21257. }
  21258. public function setStabilityFlags(array $stabilityFlags)
  21259. {
  21260. $this->aliasOf->setStabilityFlags($stabilityFlags);
  21261. }
  21262. public function setSuggests(array $suggests)
  21263. {
  21264. $this->aliasOf->setSuggests($suggests);
  21265. }
  21266. public function setExtra(array $extra)
  21267. {
  21268. $this->aliasOf->setExtra($extra);
  21269. }
  21270. public function __clone()
  21271. {
  21272. parent::__clone();
  21273. $this->aliasOf = clone $this->aliasOf;
  21274. }
  21275. }
  21276. <?php
  21277. namespace Composer\Package;
  21278. class RootPackage extends CompletePackage implements RootPackageInterface
  21279. {
  21280. const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  21281. protected $minimumStability = 'stable';
  21282. protected $preferStable = false;
  21283. protected $stabilityFlags = array();
  21284. protected $config = array();
  21285. protected $references = array();
  21286. protected $aliases = array();
  21287. public function setMinimumStability($minimumStability)
  21288. {
  21289. $this->minimumStability = $minimumStability;
  21290. }
  21291. public function getMinimumStability()
  21292. {
  21293. return $this->minimumStability;
  21294. }
  21295. public function setStabilityFlags(array $stabilityFlags)
  21296. {
  21297. $this->stabilityFlags = $stabilityFlags;
  21298. }
  21299. public function getStabilityFlags()
  21300. {
  21301. return $this->stabilityFlags;
  21302. }
  21303. public function setPreferStable($preferStable)
  21304. {
  21305. $this->preferStable = $preferStable;
  21306. }
  21307. public function getPreferStable()
  21308. {
  21309. return $this->preferStable;
  21310. }
  21311. public function setConfig(array $config)
  21312. {
  21313. $this->config = $config;
  21314. }
  21315. public function getConfig()
  21316. {
  21317. return $this->config;
  21318. }
  21319. public function setReferences(array $references)
  21320. {
  21321. $this->references = $references;
  21322. }
  21323. public function getReferences()
  21324. {
  21325. return $this->references;
  21326. }
  21327. public function setAliases(array $aliases)
  21328. {
  21329. $this->aliases = $aliases;
  21330. }
  21331. public function getAliases()
  21332. {
  21333. return $this->aliases;
  21334. }
  21335. }
  21336. <?php
  21337. namespace Composer\Package;
  21338. interface RootPackageInterface extends CompletePackageInterface
  21339. {
  21340. public function getAliases();
  21341. public function getMinimumStability();
  21342. public function getStabilityFlags();
  21343. public function getReferences();
  21344. public function getPreferStable();
  21345. public function getConfig();
  21346. public function setRequires(array $requires);
  21347. public function setDevRequires(array $devRequires);
  21348. public function setConflicts(array $conflicts);
  21349. public function setProvides(array $provides);
  21350. public function setReplaces(array $replaces);
  21351. public function setRepositories($repositories);
  21352. public function setAutoload(array $autoload);
  21353. public function setDevAutoload(array $devAutoload);
  21354. public function setStabilityFlags(array $stabilityFlags);
  21355. public function setSuggests(array $suggests);
  21356. public function setExtra(array $extra);
  21357. }
  21358. <?php
  21359. namespace Composer\Package\Version;
  21360. use Composer\Package\BasePackage;
  21361. class StabilityFilter
  21362. {
  21363. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, $names, $stability)
  21364. {
  21365. foreach ($names as $name) {
  21366. if (isset($stabilityFlags[$name])) {
  21367. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  21368. return true;
  21369. }
  21370. } elseif (isset($acceptableStabilities[$stability])) {
  21371. return true;
  21372. }
  21373. }
  21374. return false;
  21375. }
  21376. }
  21377. <?php
  21378. namespace Composer\Package\Version;
  21379. use Composer\Config;
  21380. use Composer\Repository\Vcs\HgDriver;
  21381. use Composer\IO\NullIO;
  21382. use Composer\Semver\VersionParser as SemverVersionParser;
  21383. use Composer\Util\Git as GitUtil;
  21384. use Composer\Util\HttpDownloader;
  21385. use Composer\Util\ProcessExecutor;
  21386. use Composer\Util\Svn as SvnUtil;
  21387. class VersionGuesser
  21388. {
  21389. private $config;
  21390. private $process;
  21391. private $versionParser;
  21392. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  21393. {
  21394. $this->config = $config;
  21395. $this->process = $process;
  21396. $this->versionParser = $versionParser;
  21397. }
  21398. public function guessVersion(array $packageConfig, $path)
  21399. {
  21400. if (!function_exists('proc_open')) {
  21401. return null;
  21402. }
  21403. $versionData = $this->guessGitVersion($packageConfig, $path);
  21404. if (null !== $versionData && null !== $versionData['version']) {
  21405. return $this->postprocess($versionData);
  21406. }
  21407. $versionData = $this->guessHgVersion($packageConfig, $path);
  21408. if (null !== $versionData && null !== $versionData['version']) {
  21409. return $this->postprocess($versionData);
  21410. }
  21411. $versionData = $this->guessFossilVersion($path);
  21412. if (null !== $versionData && null !== $versionData['version']) {
  21413. return $this->postprocess($versionData);
  21414. }
  21415. $versionData = $this->guessSvnVersion($packageConfig, $path);
  21416. if (null !== $versionData && null !== $versionData['version']) {
  21417. return $this->postprocess($versionData);
  21418. }
  21419. return null;
  21420. }
  21421. private function postprocess(array $versionData)
  21422. {
  21423. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  21424. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  21425. }
  21426. if ('-dev' === substr($versionData['version'], -4) && preg_match('{\.9{7}}', $versionData['version'])) {
  21427. $versionData['pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['version']);
  21428. }
  21429. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && preg_match('{\.9{7}}', $versionData['feature_version'])) {
  21430. $versionData['feature_pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  21431. }
  21432. return $versionData;
  21433. }
  21434. private function guessGitVersion(array $packageConfig, $path)
  21435. {
  21436. GitUtil::cleanEnv();
  21437. $commit = null;
  21438. $version = null;
  21439. $prettyVersion = null;
  21440. $featureVersion = null;
  21441. $featurePrettyVersion = null;
  21442. $isDetached = false;
  21443. if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
  21444. $branches = array();
  21445. $isFeatureBranch = false;
  21446. foreach ($this->process->splitLines($output) as $branch) {
  21447. if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21448. if (
  21449. $match[1] === '(no branch)'
  21450. || strpos($match[1], '(detached ') === 0
  21451. || strpos($match[1], '(HEAD detached at') === 0
  21452. ) {
  21453. $version = 'dev-' . $match[2];
  21454. $prettyVersion = $version;
  21455. $isFeatureBranch = true;
  21456. $isDetached = true;
  21457. } else {
  21458. $version = $this->versionParser->normalizeBranch($match[1]);
  21459. $prettyVersion = 'dev-' . $match[1];
  21460. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  21461. }
  21462. if ($match[2]) {
  21463. $commit = $match[2];
  21464. }
  21465. }
  21466. if ($branch && !preg_match('{^ *.+/HEAD }', $branch)) {
  21467. if (preg_match('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21468. $branches[] = $match[1];
  21469. }
  21470. }
  21471. }
  21472. if ($isFeatureBranch) {
  21473. $featureVersion = $version;
  21474. $featurePrettyVersion = $prettyVersion;
  21475. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  21476. $version = $result['version'];
  21477. $prettyVersion = $result['pretty_version'];
  21478. }
  21479. }
  21480. if (!$version || $isDetached) {
  21481. $result = $this->versionFromGitTags($path);
  21482. if ($result) {
  21483. $version = $result['version'];
  21484. $prettyVersion = $result['pretty_version'];
  21485. $featureVersion = null;
  21486. $featurePrettyVersion = null;
  21487. }
  21488. }
  21489. if (!$commit) {
  21490. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  21491. if (0 === $this->process->execute($command, $output, $path)) {
  21492. $commit = trim($output) ?: null;
  21493. }
  21494. }
  21495. if ($featureVersion) {
  21496. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  21497. }
  21498. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  21499. }
  21500. private function versionFromGitTags($path)
  21501. {
  21502. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  21503. try {
  21504. $version = $this->versionParser->normalize(trim($output));
  21505. return array('version' => $version, 'pretty_version' => trim($output));
  21506. } catch (\Exception $e) {
  21507. }
  21508. }
  21509. return null;
  21510. }
  21511. private function guessHgVersion(array $packageConfig, $path)
  21512. {
  21513. if (0 === $this->process->execute('hg branch', $output, $path)) {
  21514. $branch = trim($output);
  21515. $version = $this->versionParser->normalizeBranch($branch);
  21516. $isFeatureBranch = 0 === strpos($version, 'dev-');
  21517. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  21518. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  21519. }
  21520. if (!$isFeatureBranch) {
  21521. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  21522. }
  21523. $io = new NullIO();
  21524. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  21525. $branches = array_keys($driver->getBranches());
  21526. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  21527. $result['commit'] = '';
  21528. $result['feature_version'] = $version;
  21529. $result['feature_pretty_version'] = $version;
  21530. return $result;
  21531. }
  21532. }
  21533. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  21534. {
  21535. $prettyVersion = $version;
  21536. if (!isset($packageConfig['extra']['branch-alias'][$version])
  21537. || strpos(json_encode($packageConfig), '"self.version"')
  21538. ) {
  21539. $branch = preg_replace('{^dev-}', '', $version);
  21540. $length = PHP_INT_MAX;
  21541. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  21542. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21543. }
  21544. usort($branches, function ($a, $b) {
  21545. $aRemote = 0 === strpos($a, 'remotes/');
  21546. $bRemote = 0 === strpos($b, 'remotes/');
  21547. if ($aRemote !== $bRemote) {
  21548. return $aRemote ? 1 : -1;
  21549. }
  21550. return strnatcasecmp($b, $a);
  21551. });
  21552. foreach ($branches as $candidate) {
  21553. $candidateVersion = preg_replace('{^remotes/\S+/}', '', $candidate);
  21554. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  21555. continue;
  21556. }
  21557. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  21558. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  21559. continue;
  21560. }
  21561. if (strlen($output) < $length) {
  21562. $length = strlen($output);
  21563. $version = $this->versionParser->normalizeBranch($candidateVersion);
  21564. $prettyVersion = 'dev-' . $candidateVersion;
  21565. if ($length === 0) {
  21566. break;
  21567. }
  21568. }
  21569. }
  21570. }
  21571. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21572. }
  21573. private function isFeatureBranch(array $packageConfig, $branchName)
  21574. {
  21575. $nonFeatureBranches = '';
  21576. if (!empty($packageConfig['non-feature-branches'])) {
  21577. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  21578. }
  21579. return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  21580. }
  21581. private function guessFossilVersion($path)
  21582. {
  21583. $version = null;
  21584. $prettyVersion = null;
  21585. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  21586. $branch = trim($output);
  21587. $version = $this->versionParser->normalizeBranch($branch);
  21588. $prettyVersion = 'dev-' . $branch;
  21589. }
  21590. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  21591. try {
  21592. $version = $this->versionParser->normalize(trim($output));
  21593. $prettyVersion = trim($output);
  21594. } catch (\Exception $e) {
  21595. }
  21596. }
  21597. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21598. }
  21599. private function guessSvnVersion(array $packageConfig, $path)
  21600. {
  21601. SvnUtil::cleanEnv();
  21602. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  21603. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  21604. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  21605. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  21606. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  21607. if (preg_match($urlPattern, $output, $matches)) {
  21608. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  21609. $version = $this->versionParser->normalizeBranch($matches[3]);
  21610. $prettyVersion = 'dev-' . $matches[3];
  21611. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21612. }
  21613. $prettyVersion = trim($matches[1]);
  21614. if ($prettyVersion === 'trunk') {
  21615. $version = 'dev-trunk';
  21616. } else {
  21617. $version = $this->versionParser->normalize($prettyVersion);
  21618. }
  21619. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21620. }
  21621. }
  21622. }
  21623. }
  21624. <?php
  21625. namespace Composer\Package\Version;
  21626. use Composer\Repository\PlatformRepository;
  21627. use Composer\Semver\VersionParser as SemverVersionParser;
  21628. use Composer\Semver\Semver;
  21629. class VersionParser extends SemverVersionParser
  21630. {
  21631. const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  21632. private static $constraints = array();
  21633. public function parseConstraints($constraints)
  21634. {
  21635. if (!isset(self::$constraints[$constraints])) {
  21636. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  21637. }
  21638. return self::$constraints[$constraints];
  21639. }
  21640. public function parseNameVersionPairs(array $pairs)
  21641. {
  21642. $pairs = array_values($pairs);
  21643. $result = array();
  21644. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  21645. $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  21646. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  21647. $pair .= ' '.$pairs[$i + 1];
  21648. $i++;
  21649. }
  21650. if (strpos($pair, ' ')) {
  21651. list($name, $version) = explode(' ', $pair, 2);
  21652. $result[] = array('name' => $name, 'version' => $version);
  21653. } else {
  21654. $result[] = array('name' => $pair);
  21655. }
  21656. }
  21657. return $result;
  21658. }
  21659. public static function isUpgrade($normalizedFrom, $normalizedTo)
  21660. {
  21661. if ($normalizedFrom === $normalizedTo) {
  21662. return true;
  21663. }
  21664. $normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedFrom);
  21665. $normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedTo);
  21666. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  21667. return true;
  21668. }
  21669. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  21670. return $sorted[0] === $normalizedFrom;
  21671. }
  21672. }
  21673. <?php
  21674. namespace Composer\Package\Version;
  21675. use Composer\DependencyResolver\Pool;
  21676. use Composer\Package\BasePackage;
  21677. use Composer\Package\PackageInterface;
  21678. use Composer\Plugin\PluginInterface;
  21679. use Composer\Composer;
  21680. use Composer\Package\Loader\ArrayLoader;
  21681. use Composer\Package\Dumper\ArrayDumper;
  21682. use Composer\Repository\RepositorySet;
  21683. use Composer\Repository\PlatformRepository;
  21684. use Composer\Semver\Constraint\Constraint;
  21685. class VersionSelector
  21686. {
  21687. private $repositorySet;
  21688. private $platformConstraints = array();
  21689. private $parser;
  21690. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  21691. {
  21692. $this->repositorySet = $repositorySet;
  21693. if ($platformRepo) {
  21694. foreach ($platformRepo->getPackages() as $package) {
  21695. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  21696. }
  21697. }
  21698. }
  21699. public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $ignorePlatformReqs = false, $repoSetFlags = 0)
  21700. {
  21701. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  21702. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  21703. }
  21704. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  21705. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  21706. if ($this->platformConstraints && true !== $ignorePlatformReqs) {
  21707. $platformConstraints = $this->platformConstraints;
  21708. $ignorePlatformReqs = $ignorePlatformReqs ?: array();
  21709. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $ignorePlatformReqs) {
  21710. $reqs = $pkg->getRequires();
  21711. foreach ($reqs as $name => $link) {
  21712. if (!in_array($name, $ignorePlatformReqs, true) && isset($platformConstraints[$name])) {
  21713. foreach ($platformConstraints[$name] as $constraint) {
  21714. if ($link->getConstraint()->matches($constraint)) {
  21715. continue 2;
  21716. }
  21717. }
  21718. return false;
  21719. }
  21720. }
  21721. return true;
  21722. });
  21723. }
  21724. if (!$candidates) {
  21725. return false;
  21726. }
  21727. $package = reset($candidates);
  21728. $minPriority = BasePackage::$stabilities[$preferredStability];
  21729. foreach ($candidates as $candidate) {
  21730. $candidatePriority = $candidate->getStabilityPriority();
  21731. $currentPriority = $package->getStabilityPriority();
  21732. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  21733. continue;
  21734. }
  21735. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  21736. $package = $candidate;
  21737. continue;
  21738. }
  21739. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  21740. $package = $candidate;
  21741. continue;
  21742. }
  21743. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  21744. $package = $candidate;
  21745. }
  21746. }
  21747. return $package;
  21748. }
  21749. public function findRecommendedRequireVersion(PackageInterface $package)
  21750. {
  21751. $version = $package->getVersion();
  21752. if (!$package->isDev()) {
  21753. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  21754. }
  21755. $loader = new ArrayLoader($this->getParser());
  21756. $dumper = new ArrayDumper();
  21757. $extra = $loader->getBranchAlias($dumper->dump($package));
  21758. if ($extra) {
  21759. $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  21760. if ($count) {
  21761. $extra = str_replace('.9999999', '.0', $extra);
  21762. return $this->transformVersion($extra, $extra, 'dev');
  21763. }
  21764. }
  21765. return $package->getPrettyVersion();
  21766. }
  21767. private function transformVersion($version, $prettyVersion, $stability)
  21768. {
  21769. $semanticVersionParts = explode('.', $version);
  21770. if (count($semanticVersionParts) == 4 && preg_match('{^0\D?}', $semanticVersionParts[3])) {
  21771. if ($semanticVersionParts[0] === '0') {
  21772. unset($semanticVersionParts[3]);
  21773. } else {
  21774. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  21775. }
  21776. $version = implode('.', $semanticVersionParts);
  21777. } else {
  21778. return $prettyVersion;
  21779. }
  21780. if ($stability != 'stable') {
  21781. $version .= '@'.$stability;
  21782. }
  21783. return '^' . $version;
  21784. }
  21785. private function getParser()
  21786. {
  21787. if ($this->parser === null) {
  21788. $this->parser = new VersionParser();
  21789. }
  21790. return $this->parser;
  21791. }
  21792. }
  21793. <?php
  21794. namespace Composer\Platform;
  21795. use Composer\Util\Platform;
  21796. use Composer\Util\ProcessExecutor;
  21797. use Symfony\Component\Process\ExecutableFinder;
  21798. class HhvmDetector
  21799. {
  21800. private static $hhvmVersion;
  21801. private $executableFinder;
  21802. private $processExecutor;
  21803. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  21804. {
  21805. $this->executableFinder = $executableFinder;
  21806. $this->processExecutor = $processExecutor;
  21807. }
  21808. public function reset()
  21809. {
  21810. self::$hhvmVersion = null;
  21811. }
  21812. public function getVersion()
  21813. {
  21814. if (null !== self::$hhvmVersion) {
  21815. return self::$hhvmVersion ?: null;
  21816. }
  21817. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  21818. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  21819. self::$hhvmVersion = false;
  21820. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  21821. $hhvmPath = $this->executableFinder->find('hhvm');
  21822. if ($hhvmPath !== null) {
  21823. $this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
  21824. $exitCode = $this->processExecutor->execute(
  21825. ProcessExecutor::escape($hhvmPath).
  21826. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  21827. self::$hhvmVersion
  21828. );
  21829. if ($exitCode !== 0) {
  21830. self::$hhvmVersion = false;
  21831. }
  21832. }
  21833. }
  21834. return self::$hhvmVersion;
  21835. }
  21836. }
  21837. <?php
  21838. namespace Composer\Platform;
  21839. class Runtime
  21840. {
  21841. public function hasConstant($constant, $class = null)
  21842. {
  21843. return defined(ltrim($class.'::'.$constant, ':'));
  21844. }
  21845. public function getConstant($constant, $class = null)
  21846. {
  21847. return constant(ltrim($class.'::'.$constant, ':'));
  21848. }
  21849. public function hasFunction($fn)
  21850. {
  21851. return function_exists($fn);
  21852. }
  21853. public function invoke($callable, array $arguments = array())
  21854. {
  21855. return call_user_func_array($callable, $arguments);
  21856. }
  21857. public function hasClass($class)
  21858. {
  21859. return class_exists($class, false);
  21860. }
  21861. public function construct($class, array $arguments = array())
  21862. {
  21863. if (empty($arguments)) {
  21864. return new $class;
  21865. }
  21866. $refl = new \ReflectionClass($class);
  21867. return $refl->newInstanceArgs($arguments);
  21868. }
  21869. public function getExtensions()
  21870. {
  21871. return get_loaded_extensions();
  21872. }
  21873. public function getExtensionVersion($extension)
  21874. {
  21875. return phpversion($extension);
  21876. }
  21877. public function getExtensionInfo($extension)
  21878. {
  21879. $reflector = new \ReflectionExtension($extension);
  21880. ob_start();
  21881. $reflector->info();
  21882. return ob_get_clean();
  21883. }
  21884. }
  21885. <?php
  21886. namespace Composer\Platform;
  21887. class Version
  21888. {
  21889. public static function parseOpenssl($opensslVersion, &$isFips)
  21890. {
  21891. $isFips = false;
  21892. if (!preg_match('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?$/', $opensslVersion, $matches)) {
  21893. return null;
  21894. }
  21895. $isFips = strpos($matches['suffix'], 'fips') !== false;
  21896. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  21897. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  21898. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  21899. }
  21900. public static function parseLibjpeg($libjpegVersion)
  21901. {
  21902. if (!preg_match('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  21903. return null;
  21904. }
  21905. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  21906. }
  21907. public static function parseZoneinfoVersion($zoneinfoVersion)
  21908. {
  21909. if (!preg_match('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  21910. return null;
  21911. }
  21912. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  21913. }
  21914. private static function convertAlphaVersionToIntVersion($alpha)
  21915. {
  21916. return strlen($alpha) * (-ord('a')+1) + array_sum(array_map('ord', str_split($alpha)));
  21917. }
  21918. public static function convertLibxpmVersionId($versionId)
  21919. {
  21920. return self::convertVersionId($versionId, 100);
  21921. }
  21922. public static function convertOpenldapVersionId($versionId)
  21923. {
  21924. return self::convertVersionId($versionId, 100);
  21925. }
  21926. private static function convertVersionId($versionId, $base)
  21927. {
  21928. return sprintf(
  21929. '%d.%d.%d',
  21930. $versionId / ($base * $base),
  21931. ($versionId / $base) % $base,
  21932. $versionId % $base
  21933. );
  21934. }
  21935. }
  21936. <?php
  21937. namespace Composer\Plugin\Capability;
  21938. interface Capability
  21939. {
  21940. }
  21941. <?php
  21942. namespace Composer\Plugin\Capability;
  21943. interface CommandProvider extends Capability
  21944. {
  21945. public function getCommands();
  21946. }
  21947. <?php
  21948. namespace Composer\Plugin;
  21949. interface Capable
  21950. {
  21951. public function getCapabilities();
  21952. }
  21953. <?php
  21954. namespace Composer\Plugin;
  21955. use Composer\EventDispatcher\Event;
  21956. use Symfony\Component\Console\Input\InputInterface;
  21957. use Symfony\Component\Console\Output\OutputInterface;
  21958. class CommandEvent extends Event
  21959. {
  21960. private $commandName;
  21961. private $input;
  21962. private $output;
  21963. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  21964. {
  21965. parent::__construct($name, $args, $flags);
  21966. $this->commandName = $commandName;
  21967. $this->input = $input;
  21968. $this->output = $output;
  21969. }
  21970. public function getInput()
  21971. {
  21972. return $this->input;
  21973. }
  21974. public function getOutput()
  21975. {
  21976. return $this->output;
  21977. }
  21978. public function getCommandName()
  21979. {
  21980. return $this->commandName;
  21981. }
  21982. }
  21983. <?php
  21984. namespace Composer\Plugin;
  21985. class PluginEvents
  21986. {
  21987. const INIT = 'init';
  21988. const COMMAND = 'command';
  21989. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  21990. const POST_FILE_DOWNLOAD = 'post-file-download';
  21991. const PRE_COMMAND_RUN = 'pre-command-run';
  21992. const PRE_POOL_CREATE = 'pre-pool-create';
  21993. }
  21994. <?php
  21995. namespace Composer\Plugin;
  21996. use Composer\Composer;
  21997. use Composer\IO\IOInterface;
  21998. interface PluginInterface
  21999. {
  22000. const PLUGIN_API_VERSION = '2.0.0';
  22001. public function activate(Composer $composer, IOInterface $io);
  22002. public function deactivate(Composer $composer, IOInterface $io);
  22003. public function uninstall(Composer $composer, IOInterface $io);
  22004. }
  22005. <?php
  22006. namespace Composer\Plugin;
  22007. use Composer\Composer;
  22008. use Composer\EventDispatcher\EventSubscriberInterface;
  22009. use Composer\IO\IOInterface;
  22010. use Composer\Package\CompletePackage;
  22011. use Composer\Package\Package;
  22012. use Composer\Package\RootPackage;
  22013. use Composer\Package\Version\VersionParser;
  22014. use Composer\Repository\RepositoryInterface;
  22015. use Composer\Repository\InstalledRepository;
  22016. use Composer\Package\PackageInterface;
  22017. use Composer\Package\Link;
  22018. use Composer\Semver\Constraint\Constraint;
  22019. use Composer\Plugin\Capability\Capability;
  22020. use Composer\Util\PackageSorter;
  22021. class PluginManager
  22022. {
  22023. protected $composer;
  22024. protected $io;
  22025. protected $globalComposer;
  22026. protected $versionParser;
  22027. protected $disablePlugins = false;
  22028. protected $plugins = array();
  22029. protected $registeredPlugins = array();
  22030. private static $classCounter = 0;
  22031. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  22032. {
  22033. $this->io = $io;
  22034. $this->composer = $composer;
  22035. $this->globalComposer = $globalComposer;
  22036. $this->versionParser = new VersionParser();
  22037. $this->disablePlugins = $disablePlugins;
  22038. }
  22039. public function loadInstalledPlugins()
  22040. {
  22041. if ($this->disablePlugins) {
  22042. return;
  22043. }
  22044. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  22045. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22046. if ($repo) {
  22047. $this->loadRepository($repo, false);
  22048. }
  22049. if ($globalRepo) {
  22050. $this->loadRepository($globalRepo, true);
  22051. }
  22052. }
  22053. public function getPlugins()
  22054. {
  22055. return $this->plugins;
  22056. }
  22057. public function getGlobalComposer()
  22058. {
  22059. return $this->globalComposer;
  22060. }
  22061. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false, $isGlobalPlugin = false)
  22062. {
  22063. if ($this->disablePlugins) {
  22064. return;
  22065. }
  22066. if ($package->getType() === 'composer-plugin') {
  22067. $requiresComposer = null;
  22068. foreach ($package->getRequires() as $link) {
  22069. if ('composer-plugin-api' === $link->getTarget()) {
  22070. $requiresComposer = $link->getConstraint();
  22071. break;
  22072. }
  22073. }
  22074. if (!$requiresComposer) {
  22075. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  22076. }
  22077. $currentPluginApiVersion = $this->getPluginApiVersion();
  22078. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  22079. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  22080. $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>');
  22081. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  22082. $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>');
  22083. return;
  22084. }
  22085. if ($package->getName() === 'symfony/flex' && preg_match('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  22086. $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>');
  22087. return;
  22088. }
  22089. }
  22090. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22091. if (isset($this->registeredPlugins[$package->getName()])) {
  22092. return;
  22093. }
  22094. $extra = $package->getExtra();
  22095. if (empty($extra['class'])) {
  22096. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  22097. }
  22098. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  22099. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  22100. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22101. $installedRepo = new InstalledRepository(array($localRepo));
  22102. if ($globalRepo) {
  22103. $installedRepo->addRepository($globalRepo);
  22104. }
  22105. $autoloadPackages = array($package->getName() => $package);
  22106. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  22107. $generator = $this->composer->getAutoloadGenerator();
  22108. $autoloads = array();
  22109. foreach ($autoloadPackages as $autoloadPackage) {
  22110. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  22111. $autoloads[] = array($autoloadPackage, $downloadPath);
  22112. }
  22113. $map = $generator->parseAutoloads($autoloads, new RootPackage('dummy/root-package', '1.0.0.0', '1.0.0'));
  22114. $classLoader = $generator->createLoader($map);
  22115. $classLoader->register();
  22116. foreach ($classes as $class) {
  22117. if (class_exists($class, false)) {
  22118. $class = trim($class, '\\');
  22119. $path = $classLoader->findFile($class);
  22120. $code = file_get_contents($path);
  22121. $separatorPos = strrpos($class, '\\');
  22122. $className = $class;
  22123. if ($separatorPos) {
  22124. $className = substr($class, $separatorPos + 1);
  22125. }
  22126. $code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  22127. $code = strtr($code, array(
  22128. '__FILE__' => var_export($path, true),
  22129. '__DIR__' => var_export(dirname($path), true),
  22130. '__CLASS__' => var_export($class, true),
  22131. ));
  22132. $code = preg_replace('/^\s*<\?(php)?/i', '', $code, 1);
  22133. eval($code);
  22134. $class .= '_composer_tmp'.self::$classCounter;
  22135. self::$classCounter++;
  22136. }
  22137. if ($oldInstallerPlugin) {
  22138. $installer = new $class($this->io, $this->composer);
  22139. $this->composer->getInstallationManager()->addInstaller($installer);
  22140. $this->registeredPlugins[$package->getName()] = $installer;
  22141. } elseif (class_exists($class)) {
  22142. $plugin = new $class();
  22143. $this->addPlugin($plugin, $isGlobalPlugin);
  22144. $this->registeredPlugins[$package->getName()] = $plugin;
  22145. } elseif ($failOnMissingClasses) {
  22146. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  22147. }
  22148. }
  22149. }
  22150. public function deactivatePackage(PackageInterface $package)
  22151. {
  22152. if ($this->disablePlugins) {
  22153. return;
  22154. }
  22155. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22156. if (!isset($this->registeredPlugins[$package->getName()])) {
  22157. return;
  22158. }
  22159. if ($oldInstallerPlugin) {
  22160. $installer = $this->registeredPlugins[$package->getName()];
  22161. unset($this->registeredPlugins[$package->getName()]);
  22162. $this->composer->getInstallationManager()->removeInstaller($installer);
  22163. } else {
  22164. $plugin = $this->registeredPlugins[$package->getName()];
  22165. unset($this->registeredPlugins[$package->getName()]);
  22166. $this->removePlugin($plugin);
  22167. }
  22168. }
  22169. public function uninstallPackage(PackageInterface $package)
  22170. {
  22171. if ($this->disablePlugins) {
  22172. return;
  22173. }
  22174. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22175. if (!isset($this->registeredPlugins[$package->getName()])) {
  22176. return;
  22177. }
  22178. if ($oldInstallerPlugin) {
  22179. $this->deactivatePackage($package);
  22180. } else {
  22181. $plugin = $this->registeredPlugins[$package->getName()];
  22182. unset($this->registeredPlugins[$package->getName()]);
  22183. $this->removePlugin($plugin);
  22184. $this->uninstallPlugin($plugin);
  22185. }
  22186. }
  22187. protected function getPluginApiVersion()
  22188. {
  22189. return PluginInterface::PLUGIN_API_VERSION;
  22190. }
  22191. public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false)
  22192. {
  22193. $this->io->writeError('Loading plugin '.get_class($plugin).($isGlobalPlugin ? ' (installed globally)' : ''), true, IOInterface::DEBUG);
  22194. $this->plugins[] = $plugin;
  22195. $plugin->activate($this->composer, $this->io);
  22196. if ($plugin instanceof EventSubscriberInterface) {
  22197. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  22198. }
  22199. }
  22200. public function removePlugin(PluginInterface $plugin)
  22201. {
  22202. $index = array_search($plugin, $this->plugins, true);
  22203. if ($index === false) {
  22204. return;
  22205. }
  22206. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22207. unset($this->plugins[$index]);
  22208. $plugin->deactivate($this->composer, $this->io);
  22209. $this->composer->getEventDispatcher()->removeListener($plugin);
  22210. }
  22211. public function uninstallPlugin(PluginInterface $plugin)
  22212. {
  22213. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22214. $plugin->uninstall($this->composer, $this->io);
  22215. }
  22216. private function loadRepository(RepositoryInterface $repo, $isGlobalRepo)
  22217. {
  22218. $packages = $repo->getPackages();
  22219. $sortedPackages = PackageSorter::sortPackages($packages);
  22220. foreach ($sortedPackages as $package) {
  22221. if (!($package instanceof CompletePackage)) {
  22222. continue;
  22223. }
  22224. if ('composer-plugin' === $package->getType()) {
  22225. $this->registerPackage($package, false, $isGlobalRepo);
  22226. } elseif ('composer-installer' === $package->getType()) {
  22227. $this->registerPackage($package, false, $isGlobalRepo);
  22228. }
  22229. }
  22230. }
  22231. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
  22232. {
  22233. $requires = array_merge(
  22234. $package->getRequires(),
  22235. $package->getDevRequires()
  22236. );
  22237. foreach ($requires as $requireLink) {
  22238. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget(), $requireLink->getConstraint()) as $requiredPackage) {
  22239. if (!isset($collected[$requiredPackage->getName()])) {
  22240. $collected[$requiredPackage->getName()] = $requiredPackage;
  22241. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  22242. }
  22243. }
  22244. }
  22245. return $collected;
  22246. }
  22247. private function getInstallPath(PackageInterface $package, $global = false)
  22248. {
  22249. if (!$global) {
  22250. return $this->composer->getInstallationManager()->getInstallPath($package);
  22251. }
  22252. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  22253. }
  22254. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  22255. {
  22256. if (!($plugin instanceof Capable)) {
  22257. return null;
  22258. }
  22259. $capabilities = (array) $plugin->getCapabilities();
  22260. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  22261. return trim($capabilities[$capability]);
  22262. }
  22263. if (
  22264. array_key_exists($capability, $capabilities)
  22265. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  22266. ) {
  22267. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], 1));
  22268. }
  22269. }
  22270. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  22271. {
  22272. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  22273. if (!class_exists($capabilityClass)) {
  22274. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  22275. }
  22276. $ctorArgs['plugin'] = $plugin;
  22277. $capabilityObj = new $capabilityClass($ctorArgs);
  22278. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  22279. throw new \RuntimeException(
  22280. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  22281. );
  22282. }
  22283. return $capabilityObj;
  22284. }
  22285. }
  22286. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  22287. {
  22288. $capabilities = array();
  22289. foreach ($this->getPlugins() as $plugin) {
  22290. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  22291. $capabilities[] = $capability;
  22292. }
  22293. }
  22294. return $capabilities;
  22295. }
  22296. }
  22297. <?php
  22298. namespace Composer\Plugin;
  22299. use Composer\EventDispatcher\Event;
  22300. use Composer\Package\PackageInterface;
  22301. class PostFileDownloadEvent extends Event
  22302. {
  22303. private $fileName;
  22304. private $checksum;
  22305. private $url;
  22306. private $package;
  22307. public function __construct($name, $fileName, $checksum, $url, PackageInterface $package)
  22308. {
  22309. parent::__construct($name);
  22310. $this->fileName = $fileName;
  22311. $this->checksum = $checksum;
  22312. $this->url = $url;
  22313. $this->package = $package;
  22314. }
  22315. public function getFileName()
  22316. {
  22317. return $this->fileName;
  22318. }
  22319. public function getChecksum() {
  22320. return $this->checksum;
  22321. }
  22322. public function getUrl() {
  22323. return $this->url;
  22324. }
  22325. public function getPackage() {
  22326. return $this->package;
  22327. }
  22328. }
  22329. <?php
  22330. namespace Composer\Plugin;
  22331. use Composer\EventDispatcher\Event;
  22332. use Symfony\Component\Console\Input\InputInterface;
  22333. class PreCommandRunEvent extends Event
  22334. {
  22335. private $input;
  22336. private $command;
  22337. public function __construct($name, InputInterface $input, $command)
  22338. {
  22339. parent::__construct($name);
  22340. $this->input = $input;
  22341. $this->command = $command;
  22342. }
  22343. public function getInput()
  22344. {
  22345. return $this->input;
  22346. }
  22347. public function getCommand()
  22348. {
  22349. return $this->command;
  22350. }
  22351. }
  22352. <?php
  22353. namespace Composer\Plugin;
  22354. use Composer\EventDispatcher\Event;
  22355. use Composer\Util\HttpDownloader;
  22356. class PreFileDownloadEvent extends Event
  22357. {
  22358. private $httpDownloader;
  22359. private $processedUrl;
  22360. private $customCacheKey;
  22361. private $type;
  22362. private $context;
  22363. public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null)
  22364. {
  22365. parent::__construct($name);
  22366. $this->httpDownloader = $httpDownloader;
  22367. $this->processedUrl = $processedUrl;
  22368. $this->type = $type;
  22369. $this->context = $context;
  22370. }
  22371. public function getHttpDownloader()
  22372. {
  22373. return $this->httpDownloader;
  22374. }
  22375. public function getProcessedUrl()
  22376. {
  22377. return $this->processedUrl;
  22378. }
  22379. public function setProcessedUrl($processedUrl)
  22380. {
  22381. $this->processedUrl = $processedUrl;
  22382. }
  22383. public function getCustomCacheKey()
  22384. {
  22385. return $this->customCacheKey;
  22386. }
  22387. public function setCustomCacheKey($customCacheKey)
  22388. {
  22389. $this->customCacheKey = $customCacheKey;
  22390. }
  22391. public function getType()
  22392. {
  22393. return $this->type;
  22394. }
  22395. public function getContext()
  22396. {
  22397. return $this->context;
  22398. }
  22399. }
  22400. <?php
  22401. namespace Composer\Plugin;
  22402. use Composer\EventDispatcher\Event;
  22403. use Symfony\Component\Console\Input\InputInterface;
  22404. use Composer\Repository\RepositoryInterface;
  22405. use Composer\DependencyResolver\Request;
  22406. use Composer\Package\PackageInterface;
  22407. class PrePoolCreateEvent extends Event
  22408. {
  22409. private $repositories;
  22410. private $request;
  22411. private $acceptableStabilities;
  22412. private $stabilityFlags;
  22413. private $rootAliases;
  22414. private $rootReferences;
  22415. private $packages;
  22416. private $unacceptableFixedPackages;
  22417. public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  22418. {
  22419. parent::__construct($name);
  22420. $this->repositories = $repositories;
  22421. $this->request = $request;
  22422. $this->acceptableStabilities = $acceptableStabilities;
  22423. $this->stabilityFlags = $stabilityFlags;
  22424. $this->rootAliases = $rootAliases;
  22425. $this->rootReferences = $rootReferences;
  22426. $this->packages = $packages;
  22427. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  22428. }
  22429. public function getRepositories()
  22430. {
  22431. return $this->repositories;
  22432. }
  22433. public function getRequest()
  22434. {
  22435. return $this->request;
  22436. }
  22437. public function getAcceptableStabilities()
  22438. {
  22439. return $this->acceptableStabilities;
  22440. }
  22441. public function getStabilityFlags()
  22442. {
  22443. return $this->stabilityFlags;
  22444. }
  22445. public function getRootAliases()
  22446. {
  22447. return $this->rootAliases;
  22448. }
  22449. public function getRootReferences()
  22450. {
  22451. return $this->rootReferences;
  22452. }
  22453. public function getPackages()
  22454. {
  22455. return $this->packages;
  22456. }
  22457. public function getUnacceptableFixedPackages()
  22458. {
  22459. return $this->unacceptableFixedPackages;
  22460. }
  22461. public function setPackages(array $packages)
  22462. {
  22463. $this->packages = $packages;
  22464. }
  22465. public function setUnacceptableFixedPackages(array $packages)
  22466. {
  22467. $this->unacceptableFixedPackages = $packages;
  22468. }
  22469. }
  22470. <?php
  22471. namespace Composer\Question;
  22472. use Symfony\Component\Console\Exception\InvalidArgumentException;
  22473. use Symfony\Component\Console\Question\Question;
  22474. class StrictConfirmationQuestion extends Question
  22475. {
  22476. private $trueAnswerRegex;
  22477. private $falseAnswerRegex;
  22478. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  22479. {
  22480. parent::__construct($question, (bool) $default);
  22481. $this->trueAnswerRegex = $trueAnswerRegex;
  22482. $this->falseAnswerRegex = $falseAnswerRegex;
  22483. $this->setNormalizer($this->getDefaultNormalizer());
  22484. $this->setValidator($this->getDefaultValidator());
  22485. }
  22486. private function getDefaultNormalizer()
  22487. {
  22488. $default = $this->getDefault();
  22489. $trueRegex = $this->trueAnswerRegex;
  22490. $falseRegex = $this->falseAnswerRegex;
  22491. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  22492. if (is_bool($answer)) {
  22493. return $answer;
  22494. }
  22495. if (empty($answer) && !empty($default)) {
  22496. return $default;
  22497. }
  22498. if (preg_match($trueRegex, $answer)) {
  22499. return true;
  22500. }
  22501. if (preg_match($falseRegex, $answer)) {
  22502. return false;
  22503. }
  22504. return null;
  22505. };
  22506. }
  22507. private function getDefaultValidator()
  22508. {
  22509. return function ($answer) {
  22510. if (!is_bool($answer)) {
  22511. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  22512. }
  22513. return $answer;
  22514. };
  22515. }
  22516. }
  22517. <?php
  22518. namespace Composer\Repository;
  22519. use Composer\Package\AliasPackage;
  22520. use Composer\Package\PackageInterface;
  22521. use Composer\Package\CompletePackageInterface;
  22522. use Composer\Package\Version\VersionParser;
  22523. use Composer\Package\Version\StabilityFilter;
  22524. use Composer\Semver\Constraint\ConstraintInterface;
  22525. use Composer\Semver\Constraint\Constraint;
  22526. class ArrayRepository implements RepositoryInterface
  22527. {
  22528. protected $packages;
  22529. protected $packageMap;
  22530. public function __construct(array $packages = array())
  22531. {
  22532. foreach ($packages as $package) {
  22533. $this->addPackage($package);
  22534. }
  22535. }
  22536. public function getRepoName()
  22537. {
  22538. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  22539. }
  22540. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  22541. {
  22542. $packages = $this->getPackages();
  22543. $result = array();
  22544. $namesFound = array();
  22545. foreach ($packages as $package) {
  22546. if (array_key_exists($package->getName(), $packageMap)) {
  22547. if (
  22548. (!$packageMap[$package->getName()] || $packageMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  22549. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  22550. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  22551. ) {
  22552. $result[spl_object_hash($package)] = $package;
  22553. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  22554. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  22555. }
  22556. }
  22557. $namesFound[$package->getName()] = true;
  22558. }
  22559. }
  22560. foreach ($packages as $package) {
  22561. if ($package instanceof AliasPackage) {
  22562. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  22563. $result[spl_object_hash($package)] = $package;
  22564. }
  22565. }
  22566. }
  22567. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  22568. }
  22569. public function findPackage($name, $constraint)
  22570. {
  22571. $name = strtolower($name);
  22572. if (!$constraint instanceof ConstraintInterface) {
  22573. $versionParser = new VersionParser();
  22574. $constraint = $versionParser->parseConstraints($constraint);
  22575. }
  22576. foreach ($this->getPackages() as $package) {
  22577. if ($name === $package->getName()) {
  22578. $pkgConstraint = new Constraint('==', $package->getVersion());
  22579. if ($constraint->matches($pkgConstraint)) {
  22580. return $package;
  22581. }
  22582. }
  22583. }
  22584. return null;
  22585. }
  22586. public function findPackages($name, $constraint = null)
  22587. {
  22588. $name = strtolower($name);
  22589. $packages = array();
  22590. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  22591. $versionParser = new VersionParser();
  22592. $constraint = $versionParser->parseConstraints($constraint);
  22593. }
  22594. foreach ($this->getPackages() as $package) {
  22595. if ($name === $package->getName()) {
  22596. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  22597. $packages[] = $package;
  22598. }
  22599. }
  22600. }
  22601. return $packages;
  22602. }
  22603. public function search($query, $mode = 0, $type = null)
  22604. {
  22605. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  22606. $matches = array();
  22607. foreach ($this->getPackages() as $package) {
  22608. $name = $package->getName();
  22609. if (isset($matches[$name])) {
  22610. continue;
  22611. }
  22612. if (preg_match($regex, $name)
  22613. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  22614. ) {
  22615. if (null !== $type && $package->getType() !== $type) {
  22616. continue;
  22617. }
  22618. $matches[$name] = array(
  22619. 'name' => $package->getPrettyName(),
  22620. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  22621. );
  22622. }
  22623. }
  22624. return array_values($matches);
  22625. }
  22626. public function hasPackage(PackageInterface $package)
  22627. {
  22628. if ($this->packageMap === null) {
  22629. $this->packageMap = array();
  22630. foreach ($this->getPackages() as $repoPackage) {
  22631. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  22632. }
  22633. }
  22634. return isset($this->packageMap[$package->getUniqueName()]);
  22635. }
  22636. public function addPackage(PackageInterface $package)
  22637. {
  22638. if (null === $this->packages) {
  22639. $this->initialize();
  22640. }
  22641. $package->setRepository($this);
  22642. $this->packages[] = $package;
  22643. if ($package instanceof AliasPackage) {
  22644. $aliasedPackage = $package->getAliasOf();
  22645. if (null === $aliasedPackage->getRepository()) {
  22646. $this->addPackage($aliasedPackage);
  22647. }
  22648. }
  22649. $this->packageMap = null;
  22650. }
  22651. public function getProviders($packageName)
  22652. {
  22653. $result = array();
  22654. foreach ($this->getPackages() as $candidate) {
  22655. if (isset($result[$candidate->getName()])) {
  22656. continue;
  22657. }
  22658. foreach ($candidate->getProvides() as $link) {
  22659. if ($packageName === $link->getTarget()) {
  22660. $result[$candidate->getName()] = array(
  22661. 'name' => $candidate->getName(),
  22662. 'description' => $candidate->getDescription(),
  22663. 'type' => $candidate->getType(),
  22664. );
  22665. continue 2;
  22666. }
  22667. }
  22668. }
  22669. return $result;
  22670. }
  22671. protected function createAliasPackage(PackageInterface $package, $alias, $prettyAlias)
  22672. {
  22673. return new AliasPackage($package instanceof AliasPackage ? $package->getAliasOf() : $package, $alias, $prettyAlias);
  22674. }
  22675. public function removePackage(PackageInterface $package)
  22676. {
  22677. $packageId = $package->getUniqueName();
  22678. foreach ($this->getPackages() as $key => $repoPackage) {
  22679. if ($packageId === $repoPackage->getUniqueName()) {
  22680. array_splice($this->packages, $key, 1);
  22681. $this->packageMap = null;
  22682. return;
  22683. }
  22684. }
  22685. }
  22686. public function getPackages()
  22687. {
  22688. if (null === $this->packages) {
  22689. $this->initialize();
  22690. }
  22691. return $this->packages;
  22692. }
  22693. public function count()
  22694. {
  22695. if (null === $this->packages) {
  22696. $this->initialize();
  22697. }
  22698. return count($this->packages);
  22699. }
  22700. protected function initialize()
  22701. {
  22702. $this->packages = array();
  22703. }
  22704. }
  22705. <?php
  22706. namespace Composer\Repository;
  22707. use Composer\IO\IOInterface;
  22708. use Composer\Json\JsonFile;
  22709. use Composer\Package\Loader\ArrayLoader;
  22710. use Composer\Package\Loader\LoaderInterface;
  22711. use Composer\Util\Tar;
  22712. use Composer\Util\Zip;
  22713. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22714. {
  22715. protected $loader;
  22716. protected $lookup;
  22717. protected $repoConfig;
  22718. private $io;
  22719. public function __construct(array $repoConfig, IOInterface $io)
  22720. {
  22721. parent::__construct();
  22722. if (!extension_loaded('zip')) {
  22723. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  22724. }
  22725. $this->loader = new ArrayLoader();
  22726. $this->lookup = $repoConfig['url'];
  22727. $this->io = $io;
  22728. $this->repoConfig = $repoConfig;
  22729. }
  22730. public function getRepoName()
  22731. {
  22732. return 'artifact repo ('.$this->lookup.')';
  22733. }
  22734. public function getRepoConfig()
  22735. {
  22736. return $this->repoConfig;
  22737. }
  22738. protected function initialize()
  22739. {
  22740. parent::initialize();
  22741. $this->scanDirectory($this->lookup);
  22742. }
  22743. private function scanDirectory($path)
  22744. {
  22745. $io = $this->io;
  22746. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  22747. $iterator = new \RecursiveIteratorIterator($directory);
  22748. $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar|tar|gz|tgz)$/i');
  22749. foreach ($regex as $file) {
  22750. if (!$file->isFile()) {
  22751. continue;
  22752. }
  22753. $package = $this->getComposerInformation($file);
  22754. if (!$package) {
  22755. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  22756. continue;
  22757. }
  22758. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  22759. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  22760. $this->addPackage($package);
  22761. }
  22762. }
  22763. private function getComposerInformation(\SplFileInfo $file)
  22764. {
  22765. $json = null;
  22766. $fileType = null;
  22767. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  22768. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  22769. $fileType = 'tar';
  22770. } else if ($fileExtension === 'zip') {
  22771. $fileType = 'zip';
  22772. } else {
  22773. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  22774. }
  22775. try {
  22776. if ($fileType === 'tar') {
  22777. $json = Tar::getComposerJson($file->getPathname());
  22778. } else {
  22779. $json = Zip::getComposerJson($file->getPathname());
  22780. }
  22781. } catch (\Exception $exception) {
  22782. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  22783. }
  22784. if (null === $json) {
  22785. return false;
  22786. }
  22787. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  22788. $package['dist'] = array(
  22789. 'type' => $fileType,
  22790. 'url' => strtr($file->getPathname(), '\\', '/'),
  22791. 'shasum' => sha1_file($file->getRealPath()),
  22792. );
  22793. try {
  22794. $package = $this->loader->load($package);
  22795. } catch (\UnexpectedValueException $e) {
  22796. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  22797. }
  22798. return $package;
  22799. }
  22800. }
  22801. <?php
  22802. namespace Composer\Repository;
  22803. use Composer\Package\BasePackage;
  22804. use Composer\Package\Loader\ArrayLoader;
  22805. use Composer\Package\PackageInterface;
  22806. use Composer\Package\AliasPackage;
  22807. use Composer\Package\Version\VersionParser;
  22808. use Composer\Package\Version\StabilityFilter;
  22809. use Composer\Json\JsonFile;
  22810. use Composer\Cache;
  22811. use Composer\Config;
  22812. use Composer\IO\IOInterface;
  22813. use Composer\Semver\CompilingMatcher;
  22814. use Composer\Util\HttpDownloader;
  22815. use Composer\Util\Loop;
  22816. use Composer\Plugin\PluginEvents;
  22817. use Composer\Plugin\PreFileDownloadEvent;
  22818. use Composer\EventDispatcher\EventDispatcher;
  22819. use Composer\Downloader\TransportException;
  22820. use Composer\Semver\Constraint\ConstraintInterface;
  22821. use Composer\Semver\Constraint\Constraint;
  22822. use Composer\Semver\Constraint\MatchAllConstraint;
  22823. use Composer\Util\Http\Response;
  22824. use Composer\Util\MetadataMinifier;
  22825. use Composer\Util\Url;
  22826. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22827. {
  22828. private $repoConfig;
  22829. private $options;
  22830. private $url;
  22831. private $baseUrl;
  22832. private $io;
  22833. private $httpDownloader;
  22834. private $loop;
  22835. protected $cache;
  22836. protected $notifyUrl;
  22837. protected $searchUrl;
  22838. protected $providersApiUrl;
  22839. protected $hasProviders = false;
  22840. protected $providersUrl;
  22841. protected $listUrl;
  22842. protected $hasAvailablePackageList = false;
  22843. protected $availablePackages;
  22844. protected $availablePackagePatterns;
  22845. protected $lazyProvidersUrl;
  22846. protected $providerListing;
  22847. protected $loader;
  22848. private $allowSslDowngrade = false;
  22849. private $eventDispatcher;
  22850. private $sourceMirrors;
  22851. private $distMirrors;
  22852. private $degradedMode = false;
  22853. private $rootData;
  22854. private $hasPartialPackages;
  22855. private $partialPackagesByName;
  22856. public $freshMetadataUrls = array();
  22857. public $packagesNotFoundCache = array();
  22858. public $versionParser;
  22859. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  22860. {
  22861. parent::__construct();
  22862. if (!preg_match('{^[\w.]+\??://}', $repoConfig['url'])) {
  22863. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  22864. }
  22865. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  22866. if (strpos($repoConfig['url'], 'https?') === 0) {
  22867. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  22868. }
  22869. $urlBits = parse_url($repoConfig['url']);
  22870. if ($urlBits === false || empty($urlBits['scheme'])) {
  22871. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  22872. }
  22873. if (!isset($repoConfig['options'])) {
  22874. $repoConfig['options'] = array();
  22875. }
  22876. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  22877. $this->allowSslDowngrade = true;
  22878. }
  22879. $this->options = $repoConfig['options'];
  22880. $this->url = $repoConfig['url'];
  22881. if (preg_match('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  22882. $this->url = $match['proto'].'://repo.packagist.org';
  22883. }
  22884. $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  22885. $this->io = $io;
  22886. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  22887. $this->cache->setReadOnly($config->get('cache-read-only'));
  22888. $this->versionParser = new VersionParser();
  22889. $this->loader = new ArrayLoader($this->versionParser);
  22890. $this->httpDownloader = $httpDownloader;
  22891. $this->eventDispatcher = $eventDispatcher;
  22892. $this->repoConfig = $repoConfig;
  22893. $this->loop = new Loop($this->httpDownloader);
  22894. }
  22895. public function getRepoName()
  22896. {
  22897. return 'composer repo ('.Url::sanitize($this->url).')';
  22898. }
  22899. public function getRepoConfig()
  22900. {
  22901. return $this->repoConfig;
  22902. }
  22903. public function findPackage($name, $constraint)
  22904. {
  22905. $hasProviders = $this->hasProviders();
  22906. $name = strtolower($name);
  22907. if (!$constraint instanceof ConstraintInterface) {
  22908. $constraint = $this->versionParser->parseConstraints($constraint);
  22909. }
  22910. if ($this->lazyProvidersUrl) {
  22911. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  22912. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  22913. }
  22914. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  22915. return;
  22916. }
  22917. $packages = $this->loadAsyncPackages(array($name => $constraint));
  22918. return reset($packages['packages']);
  22919. }
  22920. if ($hasProviders) {
  22921. foreach ($this->getProviderNames() as $providerName) {
  22922. if ($name === $providerName) {
  22923. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  22924. }
  22925. }
  22926. return;
  22927. }
  22928. return parent::findPackage($name, $constraint);
  22929. }
  22930. public function findPackages($name, $constraint = null)
  22931. {
  22932. $hasProviders = $this->hasProviders();
  22933. $name = strtolower($name);
  22934. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  22935. $constraint = $this->versionParser->parseConstraints($constraint);
  22936. }
  22937. if ($this->lazyProvidersUrl) {
  22938. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  22939. return $this->filterPackages($this->whatProvides($name), $constraint);
  22940. }
  22941. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  22942. return array();
  22943. }
  22944. $result = $this->loadAsyncPackages(array($name => $constraint));
  22945. return $result['packages'];
  22946. }
  22947. if ($hasProviders) {
  22948. foreach ($this->getProviderNames() as $providerName) {
  22949. if ($name === $providerName) {
  22950. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  22951. }
  22952. }
  22953. return array();
  22954. }
  22955. return parent::findPackages($name, $constraint);
  22956. }
  22957. private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
  22958. {
  22959. if (null === $constraint) {
  22960. if ($returnFirstMatch) {
  22961. return reset($packages);
  22962. }
  22963. return $packages;
  22964. }
  22965. $filteredPackages = array();
  22966. foreach ($packages as $package) {
  22967. $pkgConstraint = new Constraint('==', $package->getVersion());
  22968. if ($constraint->matches($pkgConstraint)) {
  22969. if ($returnFirstMatch) {
  22970. return $package;
  22971. }
  22972. $filteredPackages[] = $package;
  22973. }
  22974. }
  22975. if ($returnFirstMatch) {
  22976. return null;
  22977. }
  22978. return $filteredPackages;
  22979. }
  22980. public function getPackages()
  22981. {
  22982. $hasProviders = $this->hasProviders();
  22983. if ($this->lazyProvidersUrl) {
  22984. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  22985. $packageMap = array();
  22986. foreach ($this->availablePackages as $name) {
  22987. $packageMap[$name] = new MatchAllConstraint();
  22988. }
  22989. $result = $this->loadAsyncPackages($packageMap);
  22990. return array_values($result['packages']);
  22991. }
  22992. if ($this->hasPartialPackages()) {
  22993. return array_values($this->partialPackagesByName);
  22994. }
  22995. 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.');
  22996. }
  22997. if ($hasProviders) {
  22998. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  22999. }
  23000. return parent::getPackages();
  23001. }
  23002. public function getPackageNames($packageFilter = null)
  23003. {
  23004. $hasProviders = $this->hasProviders();
  23005. $packageFilterCb = function ($name) {
  23006. return true;
  23007. };
  23008. if (null !== $packageFilter) {
  23009. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  23010. $packageFilterCb = function ($name) use ($packageFilterRegex) {
  23011. return (bool) preg_match($packageFilterRegex, $name);
  23012. };
  23013. }
  23014. if ($this->lazyProvidersUrl) {
  23015. if (is_array($this->availablePackages)) {
  23016. return array_filter(array_keys($this->availablePackages), $packageFilterCb);
  23017. }
  23018. if ($this->listUrl) {
  23019. $url = $this->listUrl;
  23020. if ($packageFilter) {
  23021. $url .= '?filter='.urlencode($packageFilter);
  23022. }
  23023. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23024. return $result['packageNames'];
  23025. }
  23026. if ($this->hasPartialPackages()) {
  23027. return array_filter(array_keys($this->partialPackagesByName), $packageFilterCb);
  23028. }
  23029. return array();
  23030. }
  23031. if ($hasProviders) {
  23032. return array_filter($this->getProviderNames(), $packageFilterCb);
  23033. }
  23034. $names = array();
  23035. foreach ($this->getPackages() as $package) {
  23036. if ($packageFilterCb($package->getName())) {
  23037. $names[] = $package->getPrettyName();
  23038. }
  23039. }
  23040. return $names;
  23041. }
  23042. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23043. {
  23044. $hasProviders = $this->hasProviders();
  23045. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  23046. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23047. }
  23048. $packages = array();
  23049. $namesFound = array();
  23050. if ($hasProviders || $this->hasPartialPackages()) {
  23051. foreach ($packageNameMap as $name => $constraint) {
  23052. $matches = array();
  23053. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  23054. continue;
  23055. }
  23056. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23057. foreach ($candidates as $candidate) {
  23058. if ($candidate->getName() !== $name) {
  23059. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  23060. }
  23061. $namesFound[$name] = true;
  23062. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  23063. $matches[spl_object_hash($candidate)] = $candidate;
  23064. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23065. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  23066. }
  23067. }
  23068. }
  23069. foreach ($candidates as $candidate) {
  23070. if ($candidate instanceof AliasPackage) {
  23071. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23072. $matches[spl_object_hash($candidate)] = $candidate;
  23073. }
  23074. }
  23075. }
  23076. $packages = array_merge($packages, $matches);
  23077. unset($packageNameMap[$name]);
  23078. }
  23079. }
  23080. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  23081. if ($this->hasAvailablePackageList) {
  23082. foreach ($packageNameMap as $name => $constraint) {
  23083. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  23084. unset($packageNameMap[$name]);
  23085. }
  23086. }
  23087. }
  23088. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23089. $packages = array_merge($packages, $result['packages']);
  23090. $namesFound = array_merge($namesFound, $result['namesFound']);
  23091. }
  23092. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  23093. }
  23094. public function search($query, $mode = 0, $type = null)
  23095. {
  23096. $this->loadRootServerFile();
  23097. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  23098. $url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
  23099. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23100. if (empty($search['results'])) {
  23101. return array();
  23102. }
  23103. $results = array();
  23104. foreach ($search['results'] as $result) {
  23105. if (empty($result['virtual'])) {
  23106. $results[] = $result;
  23107. }
  23108. }
  23109. return $results;
  23110. }
  23111. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  23112. $results = array();
  23113. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  23114. foreach ($this->getPackageNames() as $name) {
  23115. if (preg_match($regex, $name)) {
  23116. $results[] = array('name' => $name);
  23117. }
  23118. }
  23119. return $results;
  23120. }
  23121. return parent::search($query, $mode);
  23122. }
  23123. public function getProviders($packageName)
  23124. {
  23125. $this->loadRootServerFile();
  23126. $result = array();
  23127. if ($this->providersApiUrl) {
  23128. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  23129. foreach ($apiResult['providers'] as $provider) {
  23130. $result[$provider['name']] = $provider;
  23131. }
  23132. return $result;
  23133. }
  23134. if ($this->hasPartialPackages()) {
  23135. foreach ($this->partialPackagesByName as $versions) {
  23136. foreach ($versions as $candidate) {
  23137. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  23138. continue;
  23139. }
  23140. $result[$candidate['name']] = array(
  23141. 'name' => $candidate['name'],
  23142. 'description' => isset($candidate['description']) ? $candidate['description'] : '',
  23143. 'type' => isset($candidate['type']) ? $candidate['type'] : '',
  23144. );
  23145. }
  23146. }
  23147. }
  23148. if ($this->packages) {
  23149. $result = array_merge($result, parent::getProviders($packageName));
  23150. }
  23151. return $result;
  23152. }
  23153. private function getProviderNames()
  23154. {
  23155. $this->loadRootServerFile();
  23156. if (null === $this->providerListing) {
  23157. $this->loadProviderListings($this->loadRootServerFile());
  23158. }
  23159. if ($this->lazyProvidersUrl) {
  23160. return array();
  23161. }
  23162. if ($this->providersUrl) {
  23163. return array_keys($this->providerListing);
  23164. }
  23165. return array();
  23166. }
  23167. private function configurePackageTransportOptions(PackageInterface $package)
  23168. {
  23169. foreach ($package->getDistUrls() as $url) {
  23170. if (strpos($url, $this->baseUrl) === 0) {
  23171. $package->setTransportOptions($this->options);
  23172. return;
  23173. }
  23174. }
  23175. }
  23176. private function hasProviders()
  23177. {
  23178. $this->loadRootServerFile();
  23179. return $this->hasProviders;
  23180. }
  23181. private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23182. {
  23183. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  23184. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  23185. return array();
  23186. }
  23187. if (null === $this->providerListing) {
  23188. $this->loadProviderListings($this->loadRootServerFile());
  23189. }
  23190. $useLastModifiedCheck = false;
  23191. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  23192. $hash = null;
  23193. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23194. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23195. $useLastModifiedCheck = true;
  23196. } elseif ($this->providersUrl) {
  23197. if (!isset($this->providerListing[$name])) {
  23198. return array();
  23199. }
  23200. $hash = $this->providerListing[$name]['sha256'];
  23201. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  23202. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23203. } else {
  23204. return array();
  23205. }
  23206. $packages = null;
  23207. if ($cacheKey) {
  23208. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  23209. $packages = json_decode($this->cache->read($cacheKey), true);
  23210. } elseif ($useLastModifiedCheck) {
  23211. if ($contents = $this->cache->read($cacheKey)) {
  23212. $contents = json_decode($contents, true);
  23213. if (isset($alreadyLoaded[$name])) {
  23214. $packages = $contents;
  23215. } elseif (isset($contents['last-modified'])) {
  23216. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  23217. $packages = true === $response ? $contents : $response;
  23218. }
  23219. }
  23220. }
  23221. }
  23222. if (!$packages) {
  23223. try {
  23224. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  23225. } catch (TransportException $e) {
  23226. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  23227. $packages = array('packages' => array());
  23228. if ($e->getStatusCode() === 499) {
  23229. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  23230. }
  23231. } else {
  23232. throw $e;
  23233. }
  23234. }
  23235. }
  23236. $loadingPartialPackage = false;
  23237. } else {
  23238. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  23239. $loadingPartialPackage = true;
  23240. }
  23241. $result = array();
  23242. $versionsToLoad = array();
  23243. foreach ($packages['packages'] as $versions) {
  23244. foreach ($versions as $version) {
  23245. $normalizedName = strtolower($version['name']);
  23246. if ($normalizedName !== $name) {
  23247. continue;
  23248. }
  23249. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  23250. continue;
  23251. }
  23252. if (!isset($versionsToLoad[$version['uid']])) {
  23253. if (!isset($version['version_normalized'])) {
  23254. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23255. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23256. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23257. }
  23258. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  23259. continue;
  23260. }
  23261. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  23262. $versionsToLoad[$version['uid']] = $version;
  23263. }
  23264. }
  23265. }
  23266. }
  23267. $loadedPackages = $this->createPackages($versionsToLoad);
  23268. $uids = array_keys($versionsToLoad);
  23269. foreach ($loadedPackages as $index => $package) {
  23270. $package->setRepository($this);
  23271. $uid = $uids[$index];
  23272. if ($package instanceof AliasPackage) {
  23273. $aliased = $package->getAliasOf();
  23274. $aliased->setRepository($this);
  23275. $result[$uid] = $aliased;
  23276. $result[$uid.'-alias'] = $package;
  23277. } else {
  23278. $result[$uid] = $package;
  23279. }
  23280. }
  23281. return $result;
  23282. }
  23283. protected function initialize()
  23284. {
  23285. parent::initialize();
  23286. $repoData = $this->loadDataFromServer();
  23287. foreach ($this->createPackages($repoData) as $package) {
  23288. $this->addPackage($package);
  23289. }
  23290. }
  23291. public function addPackage(PackageInterface $package)
  23292. {
  23293. parent::addPackage($package);
  23294. $this->configurePackageTransportOptions($package);
  23295. }
  23296. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23297. {
  23298. $this->loadRootServerFile();
  23299. $packages = array();
  23300. $namesFound = array();
  23301. $promises = array();
  23302. $repo = $this;
  23303. if (!$this->lazyProvidersUrl) {
  23304. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  23305. }
  23306. foreach ($packageNames as $name => $constraint) {
  23307. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  23308. $packageNames[$name.'~dev'] = $constraint;
  23309. }
  23310. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  23311. unset($packageNames[$name]);
  23312. }
  23313. }
  23314. foreach ($packageNames as $name => $constraint) {
  23315. $name = strtolower($name);
  23316. $realName = preg_replace('{~dev$}', '', $name);
  23317. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  23318. continue;
  23319. }
  23320. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23321. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  23322. $lastModified = null;
  23323. if ($contents = $this->cache->read($cacheKey)) {
  23324. $contents = json_decode($contents, true);
  23325. $lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
  23326. }
  23327. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  23328. ->then(function ($response) use (&$packages, &$namesFound, $contents, $realName, $constraint, $repo, $acceptableStabilities, $stabilityFlags, $alreadyLoaded) {
  23329. if (true === $response) {
  23330. $response = $contents;
  23331. }
  23332. if (!isset($response['packages'][$realName])) {
  23333. return;
  23334. }
  23335. $versions = $response['packages'][$realName];
  23336. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  23337. $versions = MetadataMinifier::expand($versions);
  23338. }
  23339. $namesFound[$realName] = true;
  23340. $versionsToLoad = array();
  23341. foreach ($versions as $version) {
  23342. if (!isset($version['version_normalized'])) {
  23343. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23344. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23345. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23346. }
  23347. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  23348. continue;
  23349. }
  23350. if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  23351. $versionsToLoad[] = $version;
  23352. }
  23353. }
  23354. $loadedPackages = $repo->createPackages($versionsToLoad);
  23355. foreach ($loadedPackages as $package) {
  23356. $package->setRepository($repo);
  23357. $packages[spl_object_hash($package)] = $package;
  23358. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  23359. $package->getAliasOf()->setRepository($repo);
  23360. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  23361. }
  23362. }
  23363. });
  23364. }
  23365. $this->loop->wait($promises);
  23366. return array('namesFound' => $namesFound, 'packages' => $packages);
  23367. }
  23368. public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
  23369. {
  23370. $versions = array($versionData['version_normalized']);
  23371. if ($alias = $this->loader->getBranchAlias($versionData)) {
  23372. $versions[] = $alias;
  23373. }
  23374. foreach ($versions as $version) {
  23375. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  23376. continue;
  23377. }
  23378. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  23379. continue;
  23380. }
  23381. return true;
  23382. }
  23383. return false;
  23384. }
  23385. protected function loadRootServerFile()
  23386. {
  23387. if (null !== $this->rootData) {
  23388. return $this->rootData;
  23389. }
  23390. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  23391. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  23392. }
  23393. $jsonUrlParts = parse_url($this->url);
  23394. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  23395. $jsonUrl = $this->url;
  23396. } else {
  23397. $jsonUrl = $this->url . '/packages.json';
  23398. }
  23399. $data = $this->fetchFile($jsonUrl, 'packages.json');
  23400. if (!empty($data['notify-batch'])) {
  23401. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  23402. } elseif (!empty($data['notify'])) {
  23403. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  23404. }
  23405. if (!empty($data['search'])) {
  23406. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  23407. }
  23408. if (!empty($data['mirrors'])) {
  23409. foreach ($data['mirrors'] as $mirror) {
  23410. if (!empty($mirror['git-url'])) {
  23411. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  23412. }
  23413. if (!empty($mirror['hg-url'])) {
  23414. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  23415. }
  23416. if (!empty($mirror['dist-url'])) {
  23417. $this->distMirrors[] = array(
  23418. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  23419. 'preferred' => !empty($mirror['preferred']),
  23420. );
  23421. }
  23422. }
  23423. }
  23424. if (!empty($data['providers-lazy-url'])) {
  23425. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  23426. $this->hasProviders = true;
  23427. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23428. }
  23429. if (!empty($data['metadata-url']) && !empty($data['list']) && $data['metadata-url'] === '/p/%package%.json' && $data['list'] === 'https://packagist.org/packages/list.json') {
  23430. $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>');
  23431. unset($data['metadata-url']);
  23432. }
  23433. if (!empty($data['metadata-url'])) {
  23434. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  23435. $this->providersUrl = null;
  23436. $this->hasProviders = false;
  23437. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23438. $this->allowSslDowngrade = false;
  23439. if (!empty($data['available-packages'])) {
  23440. $availPackages = array_map('strtolower', $data['available-packages']);
  23441. $this->availablePackages = array_combine($availPackages, $availPackages);
  23442. $this->hasAvailablePackageList = true;
  23443. }
  23444. if (!empty($data['available-package-patterns'])) {
  23445. $this->availablePackagePatterns = array_map(function ($pattern) {
  23446. return BasePackage::packageNameToRegexp($pattern);
  23447. }, $data['available-package-patterns']);
  23448. $this->hasAvailablePackageList = true;
  23449. }
  23450. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  23451. }
  23452. if ($this->allowSslDowngrade) {
  23453. $this->url = str_replace('https://', 'http://', $this->url);
  23454. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  23455. }
  23456. if (!empty($data['providers-url'])) {
  23457. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  23458. $this->hasProviders = true;
  23459. }
  23460. if (!empty($data['list'])) {
  23461. $this->listUrl = $this->canonicalizeUrl($data['list']);
  23462. }
  23463. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  23464. $this->hasProviders = true;
  23465. }
  23466. if (!empty($data['providers-api'])) {
  23467. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  23468. }
  23469. return $this->rootData = $data;
  23470. }
  23471. private function canonicalizeUrl($url)
  23472. {
  23473. if ('/' === $url[0]) {
  23474. if (preg_match('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  23475. return $matches[0] . $url;
  23476. }
  23477. return $this->url;
  23478. }
  23479. return $url;
  23480. }
  23481. private function loadDataFromServer()
  23482. {
  23483. $data = $this->loadRootServerFile();
  23484. return $this->loadIncludes($data);
  23485. }
  23486. private function hasPartialPackages()
  23487. {
  23488. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  23489. $this->initializePartialPackages();
  23490. }
  23491. return $this->hasPartialPackages;
  23492. }
  23493. private function loadProviderListings($data)
  23494. {
  23495. if (isset($data['providers'])) {
  23496. if (!is_array($this->providerListing)) {
  23497. $this->providerListing = array();
  23498. }
  23499. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  23500. }
  23501. if ($this->providersUrl && isset($data['provider-includes'])) {
  23502. $includes = $data['provider-includes'];
  23503. foreach ($includes as $include => $metadata) {
  23504. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  23505. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  23506. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  23507. $includedData = json_decode($this->cache->read($cacheKey), true);
  23508. } else {
  23509. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  23510. }
  23511. $this->loadProviderListings($includedData);
  23512. }
  23513. }
  23514. }
  23515. private function loadIncludes($data)
  23516. {
  23517. $packages = array();
  23518. if (!isset($data['packages']) && !isset($data['includes'])) {
  23519. foreach ($data as $pkg) {
  23520. foreach ($pkg['versions'] as $metadata) {
  23521. $packages[] = $metadata;
  23522. }
  23523. }
  23524. return $packages;
  23525. }
  23526. if (isset($data['packages'])) {
  23527. foreach ($data['packages'] as $package => $versions) {
  23528. foreach ($versions as $version => $metadata) {
  23529. $packages[] = $metadata;
  23530. }
  23531. }
  23532. }
  23533. if (isset($data['includes'])) {
  23534. foreach ($data['includes'] as $include => $metadata) {
  23535. if (isset($metadata['sha1']) && $this->cache->sha1($include) === $metadata['sha1']) {
  23536. $includedData = json_decode($this->cache->read($include), true);
  23537. } else {
  23538. $includedData = $this->fetchFile($include);
  23539. }
  23540. $packages = array_merge($packages, $this->loadIncludes($includedData));
  23541. }
  23542. }
  23543. return $packages;
  23544. }
  23545. public function createPackages(array $packages, $class = 'Composer\Package\CompletePackage')
  23546. {
  23547. if (!$packages) {
  23548. return array();
  23549. }
  23550. try {
  23551. foreach ($packages as &$data) {
  23552. if (!isset($data['notification-url'])) {
  23553. $data['notification-url'] = $this->notifyUrl;
  23554. }
  23555. }
  23556. $packages = $this->loader->loadPackages($packages, $class);
  23557. foreach ($packages as $package) {
  23558. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  23559. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  23560. }
  23561. $package->setDistMirrors($this->distMirrors);
  23562. $this->configurePackageTransportOptions($package);
  23563. }
  23564. return $packages;
  23565. } catch (\Exception $e) {
  23566. throw new \RuntimeException('Could not load packages '.(isset($packages[0]['name']) ? $packages[0]['name'] : json_encode($packages)).' in '.$this->url.': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
  23567. }
  23568. }
  23569. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  23570. {
  23571. if (null === $cacheKey) {
  23572. $cacheKey = $filename;
  23573. $filename = $this->baseUrl.'/'.$filename;
  23574. }
  23575. if (($pos = strpos($filename, '$')) && preg_match('{^https?://}i', $filename)) {
  23576. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  23577. }
  23578. $retries = 3;
  23579. while ($retries--) {
  23580. try {
  23581. if ($this->eventDispatcher) {
  23582. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23583. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23584. $filename = $preFileDownloadEvent->getProcessedUrl();
  23585. }
  23586. $response = $this->httpDownloader->get($filename, $this->options);
  23587. $json = $response->getBody();
  23588. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  23589. if ($this->allowSslDowngrade) {
  23590. $this->url = str_replace('http://', 'https://', $this->url);
  23591. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  23592. $filename = str_replace('http://', 'https://', $filename);
  23593. }
  23594. if ($retries) {
  23595. usleep(100000);
  23596. continue;
  23597. }
  23598. 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.');
  23599. }
  23600. $data = $response->decodeJson();
  23601. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23602. if ($cacheKey && !$this->cache->isReadOnly()) {
  23603. if ($storeLastModifiedTime) {
  23604. $lastModifiedDate = $response->getHeader('last-modified');
  23605. if ($lastModifiedDate) {
  23606. $data['last-modified'] = $lastModifiedDate;
  23607. $json = json_encode($data);
  23608. }
  23609. }
  23610. $this->cache->write($cacheKey, $json);
  23611. }
  23612. $response->collect();
  23613. break;
  23614. } catch (\Exception $e) {
  23615. if ($e instanceof \LogicException) {
  23616. throw $e;
  23617. }
  23618. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23619. throw $e;
  23620. }
  23621. if ($retries) {
  23622. usleep(100000);
  23623. continue;
  23624. }
  23625. if ($e instanceof RepositorySecurityException) {
  23626. throw $e;
  23627. }
  23628. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  23629. if (!$this->degradedMode) {
  23630. $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>');
  23631. }
  23632. $this->degradedMode = true;
  23633. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  23634. break;
  23635. }
  23636. throw $e;
  23637. }
  23638. }
  23639. if (!isset($data)) {
  23640. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  23641. }
  23642. return $data;
  23643. }
  23644. private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  23645. {
  23646. $retries = 3;
  23647. while ($retries--) {
  23648. try {
  23649. if ($this->eventDispatcher) {
  23650. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23651. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23652. $filename = $preFileDownloadEvent->getProcessedUrl();
  23653. }
  23654. $options = $this->options;
  23655. if (isset($options['http']['header'])) {
  23656. $options['http']['header'] = (array) $options['http']['header'];
  23657. }
  23658. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23659. $response = $this->httpDownloader->get($filename, $options);
  23660. $json = $response->getBody();
  23661. if ($json === '' && $response->getStatusCode() === 304) {
  23662. return true;
  23663. }
  23664. $data = $response->decodeJson();
  23665. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23666. $lastModifiedDate = $response->getHeader('last-modified');
  23667. $response->collect();
  23668. if ($lastModifiedDate) {
  23669. $data['last-modified'] = $lastModifiedDate;
  23670. $json = json_encode($data);
  23671. }
  23672. if (!$this->cache->isReadOnly()) {
  23673. $this->cache->write($cacheKey, $json);
  23674. }
  23675. return $data;
  23676. } catch (\Exception $e) {
  23677. if ($e instanceof \LogicException) {
  23678. throw $e;
  23679. }
  23680. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23681. throw $e;
  23682. }
  23683. if ($retries) {
  23684. usleep(100000);
  23685. continue;
  23686. }
  23687. if (!$this->degradedMode) {
  23688. $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>');
  23689. }
  23690. $this->degradedMode = true;
  23691. return true;
  23692. }
  23693. }
  23694. }
  23695. private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
  23696. {
  23697. $retries = 3;
  23698. if (isset($this->packagesNotFoundCache[$filename])) {
  23699. return \React\Promise\resolve(array('packages' => array()));
  23700. }
  23701. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  23702. return \React\Promise\resolve(true);
  23703. }
  23704. $httpDownloader = $this->httpDownloader;
  23705. if ($this->eventDispatcher) {
  23706. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23707. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23708. $filename = $preFileDownloadEvent->getProcessedUrl();
  23709. }
  23710. $options = $this->options;
  23711. if ($lastModifiedTime) {
  23712. if (isset($options['http']['header'])) {
  23713. $options['http']['header'] = (array) $options['http']['header'];
  23714. }
  23715. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23716. }
  23717. $io = $this->io;
  23718. $url = $this->url;
  23719. $cache = $this->cache;
  23720. $degradedMode =& $this->degradedMode;
  23721. $repo = $this;
  23722. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) {
  23723. if ($response->getStatusCode() === 404) {
  23724. $repo->packagesNotFoundCache[$filename] = true;
  23725. return array('packages' => array());
  23726. }
  23727. $json = $response->getBody();
  23728. if ($json === '' && $response->getStatusCode() === 304) {
  23729. $repo->freshMetadataUrls[$filename] = true;
  23730. return true;
  23731. }
  23732. $data = $response->decodeJson();
  23733. HttpDownloader::outputWarnings($io, $url, $data);
  23734. $lastModifiedDate = $response->getHeader('last-modified');
  23735. $response->collect();
  23736. if ($lastModifiedDate) {
  23737. $data['last-modified'] = $lastModifiedDate;
  23738. $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE);
  23739. }
  23740. if (!$cache->isReadOnly()) {
  23741. $cache->write($cacheKey, $json);
  23742. }
  23743. $repo->freshMetadataUrls[$filename] = true;
  23744. return $data;
  23745. };
  23746. $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) {
  23747. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23748. $repo->packagesNotFoundCache[$filename] = true;
  23749. return false;
  23750. }
  23751. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  23752. $retries = 0;
  23753. }
  23754. if (--$retries > 0) {
  23755. usleep(100000);
  23756. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  23757. }
  23758. if (!$degradedMode) {
  23759. $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>');
  23760. }
  23761. $degradedMode = true;
  23762. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  23763. return $accept(new Response(array('url' => $url), 404, array(), ''));
  23764. }
  23765. throw $e;
  23766. };
  23767. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  23768. }
  23769. private function initializePartialPackages()
  23770. {
  23771. $rootData = $this->loadRootServerFile();
  23772. $this->partialPackagesByName = array();
  23773. foreach ($rootData['packages'] as $package => $versions) {
  23774. foreach ($versions as $version) {
  23775. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  23776. }
  23777. }
  23778. $this->rootData = true;
  23779. }
  23780. protected function lazyProvidersRepoContains($name)
  23781. {
  23782. if (!$this->hasAvailablePackageList) {
  23783. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  23784. }
  23785. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  23786. return true;
  23787. }
  23788. if (is_array($this->availablePackagePatterns)) {
  23789. foreach ($this->availablePackagePatterns as $providerRegex) {
  23790. if (preg_match($providerRegex, $name)) {
  23791. return true;
  23792. }
  23793. }
  23794. }
  23795. return false;
  23796. }
  23797. }
  23798. <?php
  23799. namespace Composer\Repository;
  23800. use Composer\Package\PackageInterface;
  23801. class CompositeRepository implements RepositoryInterface
  23802. {
  23803. private $repositories;
  23804. public function __construct(array $repositories)
  23805. {
  23806. $this->repositories = array();
  23807. foreach ($repositories as $repo) {
  23808. $this->addRepository($repo);
  23809. }
  23810. }
  23811. public function getRepoName()
  23812. {
  23813. return 'composite repo ('.implode(', ', array_map(function ($repo) { return $repo->getRepoName(); }, $this->repositories)).')';
  23814. }
  23815. public function getRepositories()
  23816. {
  23817. return $this->repositories;
  23818. }
  23819. public function hasPackage(PackageInterface $package)
  23820. {
  23821. foreach ($this->repositories as $repository) {
  23822. if ($repository->hasPackage($package)) {
  23823. return true;
  23824. }
  23825. }
  23826. return false;
  23827. }
  23828. public function findPackage($name, $constraint)
  23829. {
  23830. foreach ($this->repositories as $repository) {
  23831. $package = $repository->findPackage($name, $constraint);
  23832. if (null !== $package) {
  23833. return $package;
  23834. }
  23835. }
  23836. return null;
  23837. }
  23838. public function findPackages($name, $constraint = null)
  23839. {
  23840. $packages = array();
  23841. foreach ($this->repositories as $repository) {
  23842. $packages[] = $repository->findPackages($name, $constraint);
  23843. }
  23844. return $packages ? call_user_func_array('array_merge', $packages) : array();
  23845. }
  23846. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23847. {
  23848. $packages = array();
  23849. $namesFound = array();
  23850. foreach ($this->repositories as $repository) {
  23851. $result = $repository->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23852. $packages[] = $result['packages'];
  23853. $namesFound[] = $result['namesFound'];
  23854. }
  23855. return array(
  23856. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  23857. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  23858. );
  23859. }
  23860. public function search($query, $mode = 0, $type = null)
  23861. {
  23862. $matches = array();
  23863. foreach ($this->repositories as $repository) {
  23864. $matches[] = $repository->search($query, $mode, $type);
  23865. }
  23866. return $matches ? call_user_func_array('array_merge', $matches) : array();
  23867. }
  23868. public function getPackages()
  23869. {
  23870. $packages = array();
  23871. foreach ($this->repositories as $repository) {
  23872. $packages[] = $repository->getPackages();
  23873. }
  23874. return $packages ? call_user_func_array('array_merge', $packages) : array();
  23875. }
  23876. public function getProviders($packageName)
  23877. {
  23878. $results = array();
  23879. foreach ($this->repositories as $repository) {
  23880. $results[] = $repository->getProviders($packageName);
  23881. }
  23882. return $results ? call_user_func_array('array_merge', $results) : array();
  23883. }
  23884. public function removePackage(PackageInterface $package)
  23885. {
  23886. foreach ($this->repositories as $repository) {
  23887. $repository->removePackage($package);
  23888. }
  23889. }
  23890. public function count()
  23891. {
  23892. $total = 0;
  23893. foreach ($this->repositories as $repository) {
  23894. $total += $repository->count();
  23895. }
  23896. return $total;
  23897. }
  23898. public function addRepository(RepositoryInterface $repository)
  23899. {
  23900. if ($repository instanceof self) {
  23901. foreach ($repository->getRepositories() as $repo) {
  23902. $this->addRepository($repo);
  23903. }
  23904. } else {
  23905. $this->repositories[] = $repository;
  23906. }
  23907. }
  23908. }
  23909. <?php
  23910. namespace Composer\Repository;
  23911. interface ConfigurableRepositoryInterface
  23912. {
  23913. public function getRepoConfig();
  23914. }
  23915. <?php
  23916. namespace Composer\Repository;
  23917. use Composer\Json\JsonFile;
  23918. use Composer\Package\Loader\ArrayLoader;
  23919. use Composer\Package\RootPackageInterface;
  23920. use Composer\Package\AliasPackage;
  23921. use Composer\Package\Dumper\ArrayDumper;
  23922. use Composer\Installer\InstallationManager;
  23923. use Composer\Util\Filesystem;
  23924. class FilesystemRepository extends WritableArrayRepository
  23925. {
  23926. protected $file;
  23927. private $dumpVersions;
  23928. private $rootPackage;
  23929. public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null)
  23930. {
  23931. parent::__construct();
  23932. $this->file = $repositoryFile;
  23933. $this->dumpVersions = $dumpVersions;
  23934. $this->rootPackage = $rootPackage;
  23935. if ($dumpVersions && !$rootPackage) {
  23936. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  23937. }
  23938. }
  23939. protected function initialize()
  23940. {
  23941. parent::initialize();
  23942. if (!$this->file->exists()) {
  23943. return;
  23944. }
  23945. try {
  23946. $data = $this->file->read();
  23947. if (isset($data['packages'])) {
  23948. $packages = $data['packages'];
  23949. } else {
  23950. $packages = $data;
  23951. }
  23952. if (isset($data['dev-package-names'])) {
  23953. $this->setDevPackageNames($data['dev-package-names']);
  23954. }
  23955. if (!is_array($packages)) {
  23956. throw new \UnexpectedValueException('Could not parse package list from the repository');
  23957. }
  23958. } catch (\Exception $e) {
  23959. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  23960. }
  23961. $loader = new ArrayLoader(null, true);
  23962. foreach ($packages as $packageData) {
  23963. $package = $loader->load($packageData);
  23964. $this->addPackage($package);
  23965. }
  23966. }
  23967. public function reload()
  23968. {
  23969. $this->packages = null;
  23970. $this->initialize();
  23971. }
  23972. public function write($devMode, InstallationManager $installationManager)
  23973. {
  23974. $data = array('packages' => array(), 'dev' => $devMode, 'dev-package-names' => array());
  23975. $dumper = new ArrayDumper();
  23976. $fs = new Filesystem();
  23977. $repoDir = dirname($fs->normalizePath($this->file->getPath()));
  23978. foreach ($this->getCanonicalPackages() as $package) {
  23979. $pkgArray = $dumper->dump($package);
  23980. $path = $installationManager->getInstallPath($package);
  23981. $pkgArray['install-path'] = ('' !== $path && null !== $path) ? $fs->findShortestPath($repoDir, $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path, true) : null;
  23982. $data['packages'][] = $pkgArray;
  23983. if (in_array($package->getName(), $this->devPackageNames, true)) {
  23984. $data['dev-package-names'][] = $package->getName();
  23985. }
  23986. }
  23987. sort($data['dev-package-names']);
  23988. usort($data['packages'], function ($a, $b) {
  23989. return strcmp($a['name'], $b['name']);
  23990. });
  23991. $this->file->write($data);
  23992. if ($this->dumpVersions) {
  23993. $versions = array('versions' => array());
  23994. $packages = $this->getPackages();
  23995. $packages[] = $rootPackage = $this->rootPackage;
  23996. while ($rootPackage instanceof AliasPackage) {
  23997. $rootPackage = $rootPackage->getAliasOf();
  23998. $packages[] = $rootPackage;
  23999. }
  24000. foreach ($packages as $package) {
  24001. if ($package instanceof AliasPackage) {
  24002. continue;
  24003. }
  24004. $reference = null;
  24005. if ($package->getInstallationSource()) {
  24006. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  24007. }
  24008. if (null === $reference) {
  24009. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  24010. }
  24011. $versions['versions'][$package->getName()] = array(
  24012. 'pretty_version' => $package->getPrettyVersion(),
  24013. 'version' => $package->getVersion(),
  24014. 'aliases' => array(),
  24015. 'reference' => $reference,
  24016. );
  24017. if ($package instanceof RootPackageInterface) {
  24018. $versions['root'] = $versions['versions'][$package->getName()];
  24019. $versions['root']['name'] = $package->getName();
  24020. }
  24021. }
  24022. foreach ($packages as $package) {
  24023. foreach ($package->getReplaces() as $replace) {
  24024. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  24025. continue;
  24026. }
  24027. $replaced = $replace->getPrettyConstraint();
  24028. if ($replaced === 'self.version') {
  24029. $replaced = $package->getPrettyVersion();
  24030. }
  24031. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  24032. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  24033. }
  24034. }
  24035. foreach ($package->getProvides() as $provide) {
  24036. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  24037. continue;
  24038. }
  24039. $provided = $provide->getPrettyConstraint();
  24040. if ($provided === 'self.version') {
  24041. $provided = $package->getPrettyVersion();
  24042. }
  24043. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  24044. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  24045. }
  24046. }
  24047. }
  24048. foreach ($packages as $package) {
  24049. if (!$package instanceof AliasPackage) {
  24050. continue;
  24051. }
  24052. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  24053. if ($package instanceof RootPackageInterface) {
  24054. $versions['root']['aliases'][] = $package->getPrettyVersion();
  24055. }
  24056. }
  24057. ksort($versions['versions']);
  24058. ksort($versions);
  24059. $fs->filePutContentsIfModified($repoDir.'/installed.php', '<?php return '.var_export($versions, true).';'."\n");
  24060. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  24061. $installedVersionsClass = str_replace('private static $installed;', 'private static $installed = '.var_export($versions, true).';', $installedVersionsClass);
  24062. $fs->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  24063. if (!class_exists('Composer\InstalledVersions', false)) {
  24064. include $repoDir.'/InstalledVersions.php';
  24065. } else {
  24066. \Composer\InstalledVersions::reload($versions);
  24067. }
  24068. }
  24069. }
  24070. }
  24071. <?php
  24072. namespace Composer\Repository;
  24073. use Composer\Package\PackageInterface;
  24074. use Composer\Package\BasePackage;
  24075. class FilterRepository implements RepositoryInterface
  24076. {
  24077. private $only = array();
  24078. private $exclude = array();
  24079. private $canonical = true;
  24080. private $repo;
  24081. public function __construct(RepositoryInterface $repo, array $options)
  24082. {
  24083. if (isset($options['only'])) {
  24084. if (!is_array($options['only'])) {
  24085. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  24086. }
  24087. $this->only = '{^'.implode('|', array_map(function ($val) {
  24088. return BasePackage::packageNameToRegexp($val, '%s');
  24089. }, $options['only'])) .'$}iD';
  24090. }
  24091. if (isset($options['exclude'])) {
  24092. if (!is_array($options['exclude'])) {
  24093. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  24094. }
  24095. $this->exclude = '{^'.implode('|', array_map(function ($val) {
  24096. return BasePackage::packageNameToRegexp($val, '%s');
  24097. }, $options['exclude'])) .'$}iD';
  24098. }
  24099. if ($this->exclude && $this->only) {
  24100. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  24101. }
  24102. if (isset($options['canonical'])) {
  24103. if (!is_bool($options['canonical'])) {
  24104. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  24105. }
  24106. $this->canonical = $options['canonical'];
  24107. }
  24108. $this->repo = $repo;
  24109. }
  24110. public function getRepoName()
  24111. {
  24112. return $this->repo->getRepoName();
  24113. }
  24114. public function getRepository()
  24115. {
  24116. return $this->repo;
  24117. }
  24118. public function hasPackage(PackageInterface $package)
  24119. {
  24120. return $this->repo->hasPackage($package);
  24121. }
  24122. public function findPackage($name, $constraint)
  24123. {
  24124. if (!$this->isAllowed($name)) {
  24125. return null;
  24126. }
  24127. return $this->repo->findPackage($name, $constraint);
  24128. }
  24129. public function findPackages($name, $constraint = null)
  24130. {
  24131. if (!$this->isAllowed($name)) {
  24132. return array();
  24133. }
  24134. return $this->repo->findPackages($name, $constraint);
  24135. }
  24136. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  24137. {
  24138. foreach ($packageMap as $name => $constraint) {
  24139. if (!$this->isAllowed($name)) {
  24140. unset($packageMap[$name]);
  24141. }
  24142. }
  24143. if (!$packageMap) {
  24144. return array('namesFound' => array(), 'packages' => array());
  24145. }
  24146. $result = $this->repo->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24147. if (!$this->canonical) {
  24148. $result['namesFound'] = array();
  24149. }
  24150. return $result;
  24151. }
  24152. public function search($query, $mode = 0, $type = null)
  24153. {
  24154. $result = array();
  24155. foreach ($this->repo->search($query, $mode, $type) as $package) {
  24156. if ($this->isAllowed($package['name'])) {
  24157. $result[] = $package;
  24158. }
  24159. }
  24160. return $result;
  24161. }
  24162. public function getPackages()
  24163. {
  24164. $result = array();
  24165. foreach ($this->repo->getPackages() as $package) {
  24166. if ($this->isAllowed($package->getName())) {
  24167. $result[] = $package;
  24168. }
  24169. }
  24170. return $result;
  24171. }
  24172. public function getProviders($packageName)
  24173. {
  24174. $result = array();
  24175. foreach ($this->repo->getProviders($packageName) as $provider) {
  24176. if ($this->isAllowed($provider['name'])) {
  24177. $result[] = $provider;
  24178. }
  24179. }
  24180. return $result;
  24181. }
  24182. public function removePackage(PackageInterface $package)
  24183. {
  24184. return $this->repo->removePackage($package);
  24185. }
  24186. public function count()
  24187. {
  24188. if ($this->repo->count() > 0) {
  24189. return count($this->getPackages());
  24190. }
  24191. return 0;
  24192. }
  24193. private function isAllowed($name)
  24194. {
  24195. if (!$this->only && !$this->exclude) {
  24196. return true;
  24197. }
  24198. if ($this->only) {
  24199. return (bool) preg_match($this->only, $name);
  24200. }
  24201. return !preg_match($this->exclude, $name);
  24202. }
  24203. }
  24204. <?php
  24205. namespace Composer\Repository;
  24206. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  24207. {
  24208. public function getRepoName()
  24209. {
  24210. return 'installed '.parent::getRepoName();
  24211. }
  24212. public function isFresh()
  24213. {
  24214. return $this->count() === 0;
  24215. }
  24216. }
  24217. <?php
  24218. namespace Composer\Repository;
  24219. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  24220. {
  24221. public function getRepoName()
  24222. {
  24223. return 'installed '.parent::getRepoName();
  24224. }
  24225. public function isFresh()
  24226. {
  24227. return !$this->file->exists();
  24228. }
  24229. }
  24230. <?php
  24231. namespace Composer\Repository;
  24232. use Composer\Package\Version\VersionParser;
  24233. use Composer\Semver\Constraint\ConstraintInterface;
  24234. use Composer\Semver\Constraint\Constraint;
  24235. use Composer\Semver\Constraint\MatchAllConstraint;
  24236. use Composer\Package\AliasPackage;
  24237. use Composer\Package\RootPackageInterface;
  24238. use Composer\Package\Link;
  24239. class InstalledRepository extends CompositeRepository
  24240. {
  24241. public function findPackagesWithReplacersAndProviders($name, $constraint = null)
  24242. {
  24243. $name = strtolower($name);
  24244. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  24245. $versionParser = new VersionParser();
  24246. $constraint = $versionParser->parseConstraints($constraint);
  24247. }
  24248. $matches = array();
  24249. foreach ($this->getRepositories() as $repo) {
  24250. foreach ($repo->getPackages() as $candidate) {
  24251. if ($name === $candidate->getName()) {
  24252. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  24253. $matches[] = $candidate;
  24254. }
  24255. continue;
  24256. }
  24257. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  24258. if (
  24259. $name === $link->getTarget()
  24260. && ($constraint === null || $link->getConstraint() === null || $constraint->matches($link->getConstraint()))
  24261. ) {
  24262. $matches[] = $candidate;
  24263. continue 2;
  24264. }
  24265. }
  24266. }
  24267. }
  24268. return $matches;
  24269. }
  24270. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  24271. {
  24272. $needles = array_map('strtolower', (array) $needle);
  24273. $results = array();
  24274. if (null === $packagesFound) {
  24275. $packagesFound = $needles;
  24276. }
  24277. $rootPackage = null;
  24278. foreach ($this->getPackages() as $package) {
  24279. if ($package instanceof RootPackageInterface) {
  24280. $rootPackage = $package;
  24281. break;
  24282. }
  24283. }
  24284. foreach ($this->getPackages() as $package) {
  24285. $links = $package->getRequires();
  24286. $packagesInTree = $packagesFound;
  24287. if (!$invert) {
  24288. $links += $package->getReplaces();
  24289. foreach ($package->getReplaces() as $link) {
  24290. foreach ($needles as $needle) {
  24291. if ($link->getSource() === $needle) {
  24292. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24293. if (in_array($link->getTarget(), $packagesInTree)) {
  24294. $results[] = array($package, $link, false);
  24295. continue;
  24296. }
  24297. $packagesInTree[] = $link->getTarget();
  24298. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  24299. $results[] = array($package, $link, $dependents);
  24300. $needles[] = $link->getTarget();
  24301. }
  24302. }
  24303. }
  24304. }
  24305. }
  24306. if ($package instanceof RootPackageInterface) {
  24307. $links += $package->getDevRequires();
  24308. }
  24309. foreach ($links as $link) {
  24310. foreach ($needles as $needle) {
  24311. if ($link->getTarget() === $needle) {
  24312. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24313. if (in_array($link->getSource(), $packagesInTree)) {
  24314. $results[] = array($package, $link, false);
  24315. continue;
  24316. }
  24317. $packagesInTree[] = $link->getSource();
  24318. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  24319. $results[] = array($package, $link, $dependents);
  24320. }
  24321. }
  24322. }
  24323. }
  24324. if ($invert && in_array($package->getName(), $needles)) {
  24325. foreach ($package->getConflicts() as $link) {
  24326. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  24327. $version = new Constraint('=', $pkg->getVersion());
  24328. if ($link->getConstraint()->matches($version) === $invert) {
  24329. $results[] = array($package, $link, false);
  24330. }
  24331. }
  24332. }
  24333. }
  24334. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  24335. foreach ($package->getRequires() as $link) {
  24336. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  24337. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  24338. continue;
  24339. }
  24340. $platformPkg = $this->findPackage($link->getTarget(), '*');
  24341. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  24342. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  24343. continue;
  24344. }
  24345. foreach ($this->getPackages() as $pkg) {
  24346. if (!in_array($link->getTarget(), $pkg->getNames())) {
  24347. continue;
  24348. }
  24349. $version = new Constraint('=', $pkg->getVersion());
  24350. if ($link->getTarget() !== $pkg->getName()) {
  24351. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  24352. if ($link->getTarget() === $prov->getTarget()) {
  24353. $version = $prov->getConstraint();
  24354. break;
  24355. }
  24356. }
  24357. }
  24358. if (!$link->getConstraint()->matches($version)) {
  24359. if ($rootPackage) {
  24360. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  24361. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  24362. $results[] = array($package, $link, false);
  24363. $results[] = array($rootPackage, $rootReq, false);
  24364. continue 3;
  24365. }
  24366. }
  24367. $results[] = array($package, $link, false);
  24368. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, 'does not require', 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  24369. } else {
  24370. $results[] = array($package, $link, false);
  24371. }
  24372. }
  24373. continue 2;
  24374. }
  24375. }
  24376. }
  24377. }
  24378. ksort($results);
  24379. return $results;
  24380. }
  24381. public function getRepoName()
  24382. {
  24383. return 'installed repo ('.implode(', ', array_map(function ($repo) { return $repo->getRepoName(); }, $this->getRepositories())).')';
  24384. }
  24385. public function addRepository(RepositoryInterface $repository)
  24386. {
  24387. if (
  24388. $repository instanceof LockArrayRepository
  24389. || $repository instanceof InstalledRepositoryInterface
  24390. || $repository instanceof RootPackageRepository
  24391. || $repository instanceof PlatformRepository
  24392. ) {
  24393. return parent::addRepository($repository);
  24394. }
  24395. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  24396. }
  24397. }
  24398. <?php
  24399. namespace Composer\Repository;
  24400. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  24401. {
  24402. public function isFresh();
  24403. }
  24404. <?php
  24405. namespace Composer\Repository;
  24406. class InvalidRepositoryException extends \Exception
  24407. {
  24408. }
  24409. <?php
  24410. namespace Composer\Repository;
  24411. class LockArrayRepository extends ArrayRepository
  24412. {
  24413. public function getRepoName()
  24414. {
  24415. return 'lock repo';
  24416. }
  24417. }
  24418. <?php
  24419. namespace Composer\Repository;
  24420. use Composer\Package\Loader\ArrayLoader;
  24421. use Composer\Package\Loader\ValidatingArrayLoader;
  24422. class PackageRepository extends ArrayRepository
  24423. {
  24424. private $config;
  24425. public function __construct(array $config)
  24426. {
  24427. parent::__construct();
  24428. $this->config = $config['package'];
  24429. if (!is_numeric(key($this->config))) {
  24430. $this->config = array($this->config);
  24431. }
  24432. }
  24433. protected function initialize()
  24434. {
  24435. parent::initialize();
  24436. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
  24437. foreach ($this->config as $package) {
  24438. try {
  24439. $package = $loader->load($package);
  24440. } catch (\Exception $e) {
  24441. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  24442. }
  24443. $this->addPackage($package);
  24444. }
  24445. }
  24446. public function getRepoName()
  24447. {
  24448. return preg_replace('{^array }', 'package ', parent::getRepoName());
  24449. }
  24450. }
  24451. <?php
  24452. namespace Composer\Repository;
  24453. use Composer\Config;
  24454. use Composer\IO\IOInterface;
  24455. use Composer\Json\JsonFile;
  24456. use Composer\Package\Loader\ArrayLoader;
  24457. use Composer\Package\Version\VersionGuesser;
  24458. use Composer\Package\Version\VersionParser;
  24459. use Composer\Util\Platform;
  24460. use Composer\Util\ProcessExecutor;
  24461. use Composer\Util\Filesystem;
  24462. use Composer\Util\Url;
  24463. use Composer\Util\Git as GitUtil;
  24464. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  24465. {
  24466. private $loader;
  24467. private $versionGuesser;
  24468. private $url;
  24469. private $repoConfig;
  24470. private $process;
  24471. private $options;
  24472. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  24473. {
  24474. if (!isset($repoConfig['url'])) {
  24475. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  24476. }
  24477. $this->loader = new ArrayLoader(null, true);
  24478. $this->url = Platform::expandPath($repoConfig['url']);
  24479. $this->process = new ProcessExecutor($io);
  24480. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  24481. $this->repoConfig = $repoConfig;
  24482. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  24483. if (!isset($this->options['relative'])) {
  24484. $filesystem = new Filesystem();
  24485. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  24486. }
  24487. parent::__construct();
  24488. }
  24489. public function getRepoName()
  24490. {
  24491. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  24492. }
  24493. public function getRepoConfig()
  24494. {
  24495. return $this->repoConfig;
  24496. }
  24497. protected function initialize()
  24498. {
  24499. parent::initialize();
  24500. $urlMatches = $this->getUrlMatches();
  24501. if (empty($urlMatches)) {
  24502. if (preg_match('{[*{}]}', $this->url)) {
  24503. $url = $this->url;
  24504. while (preg_match('{[*{}]}', $url)) {
  24505. $url = dirname($url);
  24506. }
  24507. if (is_dir($url)) {
  24508. return;
  24509. }
  24510. }
  24511. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  24512. }
  24513. foreach ($urlMatches as $url) {
  24514. $path = realpath($url) . DIRECTORY_SEPARATOR;
  24515. $composerFilePath = $path.'composer.json';
  24516. if (!file_exists($composerFilePath)) {
  24517. continue;
  24518. }
  24519. $json = file_get_contents($composerFilePath);
  24520. $package = JsonFile::parseJson($json, $composerFilePath);
  24521. $package['dist'] = array(
  24522. 'type' => 'path',
  24523. 'url' => $url,
  24524. 'reference' => sha1($json . serialize($this->options)),
  24525. );
  24526. $package['transport-options'] = $this->options;
  24527. if (!isset($package['version']) && isset($package['extra']['branch-version'])) {
  24528. $package['version'] = preg_replace('{(\.x)?(-dev)?$}', '', $package['extra']['branch-version']).'.x-dev';
  24529. }
  24530. if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
  24531. if (
  24532. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  24533. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  24534. && $ref1 === $ref2
  24535. ) {
  24536. $package['version'] = $rootVersion;
  24537. }
  24538. }
  24539. $output = '';
  24540. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  24541. $package['dist']['reference'] = trim($output);
  24542. }
  24543. if (!isset($package['version'])) {
  24544. $versionData = $this->versionGuesser->guessVersion($package, $path);
  24545. if (is_array($versionData) && $versionData['pretty_version']) {
  24546. if (!empty($versionData['feature_pretty_version'])) {
  24547. $package['version'] = $versionData['feature_pretty_version'];
  24548. $this->addPackage($this->loader->load($package));
  24549. }
  24550. $package['version'] = $versionData['pretty_version'];
  24551. } else {
  24552. $package['version'] = 'dev-master';
  24553. }
  24554. }
  24555. $package = $this->loader->load($package);
  24556. $this->addPackage($package);
  24557. }
  24558. }
  24559. private function getUrlMatches()
  24560. {
  24561. $flags = GLOB_MARK | GLOB_ONLYDIR;
  24562. if (defined('GLOB_BRACE')) {
  24563. $flags |= GLOB_BRACE;
  24564. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  24565. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  24566. }
  24567. return array_map(function ($val) {
  24568. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  24569. }, glob($this->url, $flags));
  24570. }
  24571. }
  24572. <?php
  24573. namespace Composer\Repository;
  24574. use Composer\IO\IOInterface;
  24575. use Composer\Semver\VersionParser as SemverVersionParser;
  24576. use Composer\Package\Version\VersionParser;
  24577. use Composer\Package\CompletePackage;
  24578. use Composer\EventDispatcher\EventDispatcher;
  24579. use Composer\Package\Link;
  24580. use Composer\Semver\Constraint\Constraint;
  24581. use Composer\Util\HttpDownloader;
  24582. use Composer\Config;
  24583. use Composer\Factory;
  24584. class PearRepository extends ArrayRepository
  24585. {
  24586. public function __construct()
  24587. {
  24588. throw new \RuntimeException('The PEAR repository has been removed from Composer 2.0');
  24589. }
  24590. }
  24591. <?php
  24592. namespace Composer\Repository;
  24593. use Composer\Composer;
  24594. use Composer\Package\CompletePackage;
  24595. use Composer\Package\Link;
  24596. use Composer\Package\PackageInterface;
  24597. use Composer\Package\Version\VersionParser;
  24598. use Composer\Platform\HhvmDetector;
  24599. use Composer\Platform\Runtime;
  24600. use Composer\Platform\Version;
  24601. use Composer\Plugin\PluginInterface;
  24602. use Composer\Semver\Constraint\Constraint;
  24603. use Composer\Util\Silencer;
  24604. use Composer\XdebugHandler\XdebugHandler;
  24605. class PlatformRepository extends ArrayRepository
  24606. {
  24607. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
  24608. private $versionParser;
  24609. private $overrides = array();
  24610. private $runtime;
  24611. private $hhvmDetector;
  24612. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  24613. {
  24614. $this->runtime = $runtime ?: new Runtime();
  24615. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  24616. foreach ($overrides as $name => $version) {
  24617. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  24618. }
  24619. parent::__construct($packages);
  24620. }
  24621. public function getRepoName()
  24622. {
  24623. return 'platform repo';
  24624. }
  24625. protected function initialize()
  24626. {
  24627. parent::initialize();
  24628. $this->versionParser = new VersionParser();
  24629. foreach ($this->overrides as $override) {
  24630. if (!self::isPlatformPackage($override['name'])) {
  24631. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  24632. }
  24633. $this->addOverriddenPackage($override);
  24634. }
  24635. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  24636. $version = $this->versionParser->normalize($prettyVersion);
  24637. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  24638. $composerPluginApi->setDescription('The Composer Plugin API');
  24639. $this->addPackage($composerPluginApi);
  24640. $prettyVersion = Composer::RUNTIME_API_VERSION;
  24641. $version = $this->versionParser->normalize($prettyVersion);
  24642. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  24643. $composerRuntimeApi->setDescription('The Composer Runtime API');
  24644. $this->addPackage($composerRuntimeApi);
  24645. try {
  24646. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  24647. $version = $this->versionParser->normalize($prettyVersion);
  24648. } catch (\UnexpectedValueException $e) {
  24649. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  24650. $version = $this->versionParser->normalize($prettyVersion);
  24651. }
  24652. $php = new CompletePackage('php', $version, $prettyVersion);
  24653. $php->setDescription('The PHP interpreter');
  24654. $this->addPackage($php);
  24655. if ($this->runtime->getConstant('PHP_DEBUG')) {
  24656. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  24657. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  24658. $this->addPackage($phpdebug);
  24659. }
  24660. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  24661. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  24662. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  24663. $this->addPackage($phpzts);
  24664. }
  24665. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  24666. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  24667. $php64->setDescription('The PHP interpreter, 64bit');
  24668. $this->addPackage($php64);
  24669. }
  24670. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  24671. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  24672. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  24673. $this->addPackage($phpIpv6);
  24674. }
  24675. $loadedExtensions = $this->runtime->getExtensions();
  24676. foreach ($loadedExtensions as $name) {
  24677. if (in_array($name, array('standard', 'Core'))) {
  24678. continue;
  24679. }
  24680. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  24681. }
  24682. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  24683. $this->addExtension('xdebug', $prettyVersion);
  24684. }
  24685. foreach ($loadedExtensions as $name) {
  24686. switch ($name) {
  24687. case 'amqp':
  24688. $info = $this->runtime->getExtensionInfo($name);
  24689. if (preg_match('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  24690. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  24691. }
  24692. if (preg_match('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  24693. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  24694. }
  24695. break;
  24696. case 'bz2':
  24697. $info = $this->runtime->getExtensionInfo($name);
  24698. if (preg_match('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  24699. $this->addLibrary($name, $matches['version']);
  24700. }
  24701. break;
  24702. case 'curl':
  24703. $curlVersion = $this->runtime->invoke('curl_version');
  24704. $this->addLibrary($name, $curlVersion['version']);
  24705. $info = $this->runtime->getExtensionInfo($name);
  24706. if (preg_match('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  24707. $library = strtolower($sslMatches['library']);
  24708. if ($library === 'openssl') {
  24709. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  24710. $this->addLibrary($name.'-openssl'.($isFips ? '-fips': ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl'): array());
  24711. } else {
  24712. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  24713. }
  24714. }
  24715. if (preg_match('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  24716. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  24717. }
  24718. if (preg_match('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  24719. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  24720. }
  24721. break;
  24722. case 'date':
  24723. $info = $this->runtime->getExtensionInfo($name);
  24724. if (preg_match('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  24725. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  24726. }
  24727. if (preg_match('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  24728. $external = $zoneinfoSourceMatches['source'] === 'external';
  24729. if (preg_match('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  24730. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  24731. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  24732. } else {
  24733. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  24734. }
  24735. }
  24736. }
  24737. break;
  24738. case 'fileinfo':
  24739. $info = $this->runtime->getExtensionInfo($name);
  24740. if (preg_match('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  24741. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  24742. }
  24743. break;
  24744. case 'gd':
  24745. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  24746. $info = $this->runtime->getExtensionInfo($name);
  24747. if (preg_match('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  24748. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  24749. }
  24750. if (preg_match('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  24751. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  24752. }
  24753. if (preg_match('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  24754. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  24755. }
  24756. if (preg_match('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  24757. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId($libxpmMatches['versionId']), 'libxpm version for gd');
  24758. }
  24759. break;
  24760. case 'gmp':
  24761. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  24762. break;
  24763. case 'iconv':
  24764. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  24765. break;
  24766. case 'intl':
  24767. $info = $this->runtime->getExtensionInfo($name);
  24768. $description = 'The ICU unicode and globalization support library';
  24769. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  24770. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  24771. } elseif (preg_match('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  24772. $this->addLibrary('icu', $matches['version'], $description);
  24773. }
  24774. if (preg_match('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches)) {
  24775. $this->addLibrary('icu-zoneinfo', Version::parseZoneinfoVersion($zoneinfoMatches['version']), 'zoneinfo ("Olson") database for icu');
  24776. }
  24777. if ($this->runtime->hasClass('ResourceBundle')) {
  24778. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  24779. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  24780. }
  24781. if ($this->runtime->hasClass('IntlChar')) {
  24782. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  24783. }
  24784. break;
  24785. case 'imagick':
  24786. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  24787. preg_match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  24788. $version = $matches['version'];
  24789. if (isset($matches['patch'])) {
  24790. $version .= '.'.$matches['patch'];
  24791. }
  24792. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  24793. break;
  24794. case 'ldap':
  24795. $info = $this->runtime->getExtensionInfo($name);
  24796. if (preg_match('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && preg_match('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  24797. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId($matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  24798. }
  24799. break;
  24800. case 'libxml':
  24801. $libxmlProvides = array_map(function($extension) {
  24802. return $extension . '-libxml';
  24803. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  24804. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  24805. break;
  24806. case 'mbstring':
  24807. $info = $this->runtime->getExtensionInfo($name);
  24808. if (preg_match('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  24809. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  24810. }
  24811. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  24812. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  24813. } elseif (preg_match('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  24814. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  24815. }
  24816. break;
  24817. case 'memcached':
  24818. $info = $this->runtime->getExtensionInfo($name);
  24819. if (preg_match('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  24820. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  24821. }
  24822. break;
  24823. case 'openssl':
  24824. if (preg_match('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  24825. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  24826. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  24827. }
  24828. break;
  24829. case 'pcre':
  24830. $this->addLibrary($name, preg_replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  24831. $info = $this->runtime->getExtensionInfo($name);
  24832. if (preg_match('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  24833. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  24834. }
  24835. break;
  24836. case 'mysqlnd':
  24837. case 'pdo_mysql':
  24838. $info = $this->runtime->getExtensionInfo($name);
  24839. if (preg_match('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  24840. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  24841. }
  24842. break;
  24843. case 'mongodb':
  24844. $info = $this->runtime->getExtensionInfo($name);
  24845. if (preg_match('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  24846. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  24847. }
  24848. if (preg_match('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  24849. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  24850. }
  24851. break;
  24852. case 'pgsql':
  24853. case 'pdo_pgsql':
  24854. $info = $this->runtime->getExtensionInfo($name);
  24855. if (preg_match('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  24856. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  24857. }
  24858. break;
  24859. case 'libsodium':
  24860. case 'sodium':
  24861. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  24862. break;
  24863. case 'sqlite3':
  24864. case 'pdo_sqlite':
  24865. $info = $this->runtime->getExtensionInfo($name);
  24866. if (preg_match('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  24867. $this->addLibrary($name.'-sqlite', $matches['version']);
  24868. }
  24869. break;
  24870. case 'ssh2':
  24871. $info = $this->runtime->getExtensionInfo($name);
  24872. if (preg_match('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  24873. $this->addLibrary($name.'-libssh2', $matches['version']);
  24874. }
  24875. break;
  24876. case 'xsl':
  24877. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  24878. $info = $this->runtime->getExtensionInfo('xsl');
  24879. if (preg_match('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  24880. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  24881. }
  24882. break;
  24883. case 'yaml':
  24884. $info = $this->runtime->getExtensionInfo('yaml');
  24885. if (preg_match('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  24886. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  24887. }
  24888. break;
  24889. case 'zip':
  24890. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  24891. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION','ZipArchive'), null, array('zip'));
  24892. }
  24893. break;
  24894. case 'zlib':
  24895. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  24896. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  24897. } elseif (preg_match('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  24898. $this->addLibrary($name, $matches['version']);
  24899. }
  24900. break;
  24901. default:
  24902. break;
  24903. }
  24904. }
  24905. $hhvmVersion = $this->hhvmDetector->getVersion();
  24906. if ($hhvmVersion) {
  24907. try {
  24908. $prettyVersion = $hhvmVersion;
  24909. $version = $this->versionParser->normalize($prettyVersion);
  24910. } catch (\UnexpectedValueException $e) {
  24911. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  24912. $version = $this->versionParser->normalize($prettyVersion);
  24913. }
  24914. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  24915. $hhvm->setDescription('The HHVM Runtime (64bit)');
  24916. $this->addPackage($hhvm);
  24917. }
  24918. }
  24919. public function addPackage(PackageInterface $package)
  24920. {
  24921. if (isset($this->overrides[$package->getName()])) {
  24922. $overrider = $this->findPackage($package->getName(), '*');
  24923. if ($package->getVersion() === $overrider->getVersion()) {
  24924. $actualText = 'same as actual';
  24925. } else {
  24926. $actualText = 'actual: '.$package->getPrettyVersion();
  24927. }
  24928. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  24929. return;
  24930. }
  24931. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  24932. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  24933. if ($package->getVersion() === $overrider->getVersion()) {
  24934. $actualText = 'same as actual';
  24935. } else {
  24936. $actualText = 'actual: '.$package->getPrettyVersion();
  24937. }
  24938. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  24939. return;
  24940. }
  24941. parent::addPackage($package);
  24942. }
  24943. private function addOverriddenPackage(array $override, $name = null)
  24944. {
  24945. $version = $this->versionParser->normalize($override['version']);
  24946. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  24947. $package->setDescription('Package overridden via config.platform');
  24948. $package->setExtra(array('config.platform' => true));
  24949. parent::addPackage($package);
  24950. return $package;
  24951. }
  24952. private function addExtension($name, $prettyVersion)
  24953. {
  24954. $extraDescription = null;
  24955. try {
  24956. $version = $this->versionParser->normalize($prettyVersion);
  24957. } catch (\UnexpectedValueException $e) {
  24958. $extraDescription = ' (actual version: '.$prettyVersion.')';
  24959. if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  24960. $prettyVersion = $match[1];
  24961. } else {
  24962. $prettyVersion = '0';
  24963. }
  24964. $version = $this->versionParser->normalize($prettyVersion);
  24965. }
  24966. $packageName = $this->buildPackageName($name);
  24967. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  24968. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  24969. if ($name === 'uuid') {
  24970. $ext->setReplaces(array(
  24971. new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion())
  24972. ));
  24973. }
  24974. $this->addPackage($ext);
  24975. }
  24976. private function buildPackageName($name)
  24977. {
  24978. return 'ext-' . str_replace(' ', '-', strtolower($name));
  24979. }
  24980. private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
  24981. {
  24982. try {
  24983. $version = $this->versionParser->normalize($prettyVersion);
  24984. } catch (\UnexpectedValueException $e) {
  24985. return;
  24986. }
  24987. if ($description === null) {
  24988. $description = 'The '.$name.' library';
  24989. }
  24990. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  24991. $lib->setDescription($description);
  24992. $links = function ($alias) use ($name, $version, $lib) {
  24993. return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  24994. };
  24995. $lib->setReplaces(array_map($links, $replaces));
  24996. $lib->setProvides(array_map($links, $provides));
  24997. $this->addPackage($lib);
  24998. }
  24999. public static function isPlatformPackage($name)
  25000. {
  25001. static $cache = array();
  25002. if (isset($cache[$name])) {
  25003. return $cache[$name];
  25004. }
  25005. return $cache[$name] = (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  25006. }
  25007. }
  25008. <?php
  25009. namespace Composer\Repository;
  25010. use Composer\Factory;
  25011. use Composer\IO\IOInterface;
  25012. use Composer\Config;
  25013. use Composer\EventDispatcher\EventDispatcher;
  25014. use Composer\Util\HttpDownloader;
  25015. use Composer\Util\ProcessExecutor;
  25016. use Composer\Json\JsonFile;
  25017. class RepositoryFactory
  25018. {
  25019. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  25020. {
  25021. if (0 === strpos($repository, 'http')) {
  25022. $repoConfig = array('type' => 'composer', 'url' => $repository);
  25023. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  25024. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  25025. $data = $json->read();
  25026. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  25027. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  25028. } elseif ($allowFilesystem) {
  25029. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  25030. } else {
  25031. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  25032. }
  25033. } elseif (strpos($repository, '{') === 0) {
  25034. $repoConfig = JsonFile::parseJson($repository);
  25035. } else {
  25036. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  25037. }
  25038. return $repoConfig;
  25039. }
  25040. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
  25041. {
  25042. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  25043. return static::createRepo($io, $config, $repoConfig, $rm);
  25044. }
  25045. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
  25046. {
  25047. if (!$rm) {
  25048. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25049. }
  25050. $repos = static::createRepos($rm, array($repoConfig));
  25051. return reset($repos);
  25052. }
  25053. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  25054. {
  25055. if (!$config) {
  25056. $config = Factory::createConfig($io);
  25057. }
  25058. if ($io) {
  25059. $io->loadConfiguration($config);
  25060. }
  25061. if (!$rm) {
  25062. if (!$io) {
  25063. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  25064. }
  25065. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25066. }
  25067. return static::createRepos($rm, $config->getRepositories());
  25068. }
  25069. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25070. {
  25071. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  25072. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  25073. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  25074. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  25075. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  25076. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  25077. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  25078. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  25079. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  25080. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  25081. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  25082. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  25083. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  25084. $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
  25085. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  25086. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  25087. return $rm;
  25088. }
  25089. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  25090. {
  25091. $repos = array();
  25092. foreach ($repoConfigs as $index => $repo) {
  25093. if (is_string($repo)) {
  25094. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  25095. }
  25096. if (!is_array($repo)) {
  25097. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  25098. }
  25099. if (!isset($repo['type'])) {
  25100. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  25101. }
  25102. $name = self::generateRepositoryName($index, $repo, $repos);
  25103. if ($repo['type'] === 'filesystem') {
  25104. $repos[$name] = new FilesystemRepository($repo['json']);
  25105. } else {
  25106. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  25107. }
  25108. }
  25109. return $repos;
  25110. }
  25111. public static function generateRepositoryName($index, array $repo, array $existingRepos)
  25112. {
  25113. $name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
  25114. while (isset($existingRepos[$name])) {
  25115. $name .= '2';
  25116. }
  25117. return $name;
  25118. }
  25119. }
  25120. <?php
  25121. namespace Composer\Repository;
  25122. use Composer\Package\PackageInterface;
  25123. use Composer\Package\BasePackage;
  25124. use Composer\Semver\Constraint\ConstraintInterface;
  25125. interface RepositoryInterface extends \Countable
  25126. {
  25127. const SEARCH_FULLTEXT = 0;
  25128. const SEARCH_NAME = 1;
  25129. public function hasPackage(PackageInterface $package);
  25130. public function findPackage($name, $constraint);
  25131. public function findPackages($name, $constraint = null);
  25132. public function getPackages();
  25133. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  25134. public function search($query, $mode = 0, $type = null);
  25135. public function getProviders($packageName);
  25136. public function getRepoName();
  25137. }
  25138. <?php
  25139. namespace Composer\Repository;
  25140. use Composer\IO\IOInterface;
  25141. use Composer\Config;
  25142. use Composer\EventDispatcher\EventDispatcher;
  25143. use Composer\Package\PackageInterface;
  25144. use Composer\Util\HttpDownloader;
  25145. use Composer\Util\ProcessExecutor;
  25146. class RepositoryManager
  25147. {
  25148. private $localRepository;
  25149. private $repositories = array();
  25150. private $repositoryClasses = array();
  25151. private $io;
  25152. private $config;
  25153. private $httpDownloader;
  25154. private $eventDispatcher;
  25155. private $process;
  25156. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25157. {
  25158. $this->io = $io;
  25159. $this->config = $config;
  25160. $this->httpDownloader = $httpDownloader;
  25161. $this->eventDispatcher = $eventDispatcher;
  25162. $this->process = $process ?: new ProcessExecutor($io);
  25163. }
  25164. public function findPackage($name, $constraint)
  25165. {
  25166. foreach ($this->repositories as $repository) {
  25167. if ($package = $repository->findPackage($name, $constraint)) {
  25168. return $package;
  25169. }
  25170. }
  25171. return null;
  25172. }
  25173. public function findPackages($name, $constraint)
  25174. {
  25175. $packages = array();
  25176. foreach ($this->getRepositories() as $repository) {
  25177. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  25178. }
  25179. return $packages;
  25180. }
  25181. public function addRepository(RepositoryInterface $repository)
  25182. {
  25183. $this->repositories[] = $repository;
  25184. }
  25185. public function prependRepository(RepositoryInterface $repository)
  25186. {
  25187. array_unshift($this->repositories, $repository);
  25188. }
  25189. public function createRepository($type, $config, $name = null)
  25190. {
  25191. if (!isset($this->repositoryClasses[$type])) {
  25192. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  25193. }
  25194. if (isset($config['packagist']) && false === $config['packagist']) {
  25195. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  25196. }
  25197. $class = $this->repositoryClasses[$type];
  25198. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  25199. $filterConfig = $config;
  25200. unset($config['only'], $config['exclude'], $config['canonical']);
  25201. }
  25202. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  25203. if (isset($filterConfig)) {
  25204. $repository = new FilterRepository($repository, $filterConfig);
  25205. }
  25206. return $repository;
  25207. }
  25208. public function setRepositoryClass($type, $class)
  25209. {
  25210. $this->repositoryClasses[$type] = $class;
  25211. }
  25212. public function getRepositories()
  25213. {
  25214. return $this->repositories;
  25215. }
  25216. public function setLocalRepository(InstalledRepositoryInterface $repository)
  25217. {
  25218. $this->localRepository = $repository;
  25219. }
  25220. public function getLocalRepository()
  25221. {
  25222. return $this->localRepository;
  25223. }
  25224. }
  25225. <?php
  25226. namespace Composer\Repository;
  25227. class RepositorySecurityException extends \Exception
  25228. {
  25229. }
  25230. <?php
  25231. namespace Composer\Repository;
  25232. use Composer\DependencyResolver\Pool;
  25233. use Composer\DependencyResolver\PoolBuilder;
  25234. use Composer\DependencyResolver\Request;
  25235. use Composer\EventDispatcher\EventDispatcher;
  25236. use Composer\IO\IOInterface;
  25237. use Composer\IO\NullIO;
  25238. use Composer\Package\BasePackage;
  25239. use Composer\Package\AliasPackage;
  25240. use Composer\Package\Version\VersionParser;
  25241. use Composer\Repository\CompositeRepository;
  25242. use Composer\Repository\PlatformRepository;
  25243. use Composer\Repository\LockArrayRepository;
  25244. use Composer\Repository\InstalledRepositoryInterface;
  25245. use Composer\Repository\InstalledRepository;
  25246. use Composer\Semver\Constraint\ConstraintInterface;
  25247. use Composer\Package\Version\StabilityFilter;
  25248. class RepositorySet
  25249. {
  25250. const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  25251. const ALLOW_SHADOWED_REPOSITORIES = 2;
  25252. private $rootAliases;
  25253. private $rootReferences;
  25254. private $repositories = array();
  25255. private $acceptableStabilities;
  25256. private $stabilityFlags;
  25257. private $rootRequires;
  25258. private $locked = false;
  25259. private $allowInstalledRepositories = false;
  25260. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  25261. {
  25262. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  25263. $this->rootReferences = $rootReferences;
  25264. $this->acceptableStabilities = array();
  25265. foreach (BasePackage::$stabilities as $stability => $value) {
  25266. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  25267. $this->acceptableStabilities[$stability] = $value;
  25268. }
  25269. }
  25270. $this->stabilityFlags = $stabilityFlags;
  25271. $this->rootRequires = $rootRequires;
  25272. foreach ($rootRequires as $name => $constraint) {
  25273. if (PlatformRepository::isPlatformPackage($name)) {
  25274. unset($this->rootRequires[$name]);
  25275. }
  25276. }
  25277. }
  25278. public function allowInstalledRepositories($allow = true)
  25279. {
  25280. $this->allowInstalledRepositories = $allow;
  25281. }
  25282. public function getRootRequires()
  25283. {
  25284. return $this->rootRequires;
  25285. }
  25286. public function addRepository(RepositoryInterface $repo)
  25287. {
  25288. if ($this->locked) {
  25289. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  25290. }
  25291. if ($repo instanceof CompositeRepository) {
  25292. $repos = $repo->getRepositories();
  25293. } else {
  25294. $repos = array($repo);
  25295. }
  25296. foreach ($repos as $repo) {
  25297. $this->repositories[] = $repo;
  25298. }
  25299. }
  25300. public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
  25301. {
  25302. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  25303. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  25304. $packages = array();
  25305. if ($loadFromAllRepos) {
  25306. foreach ($this->repositories as $repository) {
  25307. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  25308. }
  25309. } else {
  25310. foreach ($this->repositories as $repository) {
  25311. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  25312. $packages[] = $result['packages'];
  25313. foreach ($result['namesFound'] as $nameFound) {
  25314. if ($name === $nameFound) {
  25315. break 2;
  25316. }
  25317. }
  25318. }
  25319. }
  25320. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  25321. if ($ignoreStability || !$loadFromAllRepos) {
  25322. return $candidates;
  25323. }
  25324. $result = array();
  25325. foreach ($candidates as $candidate) {
  25326. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  25327. $result[] = $candidate;
  25328. }
  25329. }
  25330. return $result;
  25331. }
  25332. public function getProviders($packageName)
  25333. {
  25334. $providers = array();
  25335. foreach ($this->repositories as $repository) {
  25336. if ($repoProviders = $repository->getProviders($packageName)) {
  25337. $providers = array_merge($providers, $repoProviders);
  25338. }
  25339. }
  25340. return $providers;
  25341. }
  25342. public function isPackageAcceptable($names, $stability)
  25343. {
  25344. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  25345. }
  25346. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null)
  25347. {
  25348. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher);
  25349. foreach ($this->repositories as $repo) {
  25350. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25351. throw new \LogicException('The pool can not accept packages from an installed repository');
  25352. }
  25353. }
  25354. $this->locked = true;
  25355. return $poolBuilder->buildPool($this->repositories, $request);
  25356. }
  25357. public function createPoolWithAllPackages()
  25358. {
  25359. foreach ($this->repositories as $repo) {
  25360. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25361. throw new \LogicException('The pool can not accept packages from an installed repository');
  25362. }
  25363. }
  25364. $this->locked = true;
  25365. $packages = array();
  25366. foreach ($this->repositories as $repository) {
  25367. foreach ($repository->getPackages() as $package) {
  25368. $packages[] = $package;
  25369. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  25370. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  25371. while ($package instanceof AliasPackage) {
  25372. $package = $package->getAliasOf();
  25373. }
  25374. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  25375. $aliasPackage->setRootPackageAlias(true);
  25376. $packages[] = $aliasPackage;
  25377. }
  25378. }
  25379. }
  25380. return new Pool($packages);
  25381. }
  25382. public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
  25383. {
  25384. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  25385. }
  25386. public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
  25387. {
  25388. $request = new Request($lockedRepo);
  25389. foreach ($packageNames as $packageName) {
  25390. if (PlatformRepository::isPlatformPackage($packageName)) {
  25391. 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.');
  25392. }
  25393. $request->requireName($packageName);
  25394. }
  25395. return $this->createPool($request, new NullIO());
  25396. }
  25397. private static function getRootAliasesPerPackage(array $aliases)
  25398. {
  25399. $normalizedAliases = array();
  25400. foreach ($aliases as $alias) {
  25401. $normalizedAliases[$alias['package']][$alias['version']] = array(
  25402. 'alias' => $alias['alias'],
  25403. 'alias_normalized' => $alias['alias_normalized'],
  25404. );
  25405. }
  25406. return $normalizedAliases;
  25407. }
  25408. }
  25409. <?php
  25410. namespace Composer\Repository;
  25411. use Composer\Package\RootPackageInterface;
  25412. class RootPackageRepository extends ArrayRepository
  25413. {
  25414. public function __construct(RootPackageInterface $package)
  25415. {
  25416. parent::__construct(array($package));
  25417. }
  25418. public function getRepoName()
  25419. {
  25420. return 'root package repo';
  25421. }
  25422. }
  25423. <?php
  25424. namespace Composer\Repository\Vcs;
  25425. use Composer\Cache;
  25426. use Composer\Downloader\TransportException;
  25427. use Composer\Json\JsonFile;
  25428. use Composer\Util\Bitbucket;
  25429. use Composer\Util\Http\Response;
  25430. abstract class BitbucketDriver extends VcsDriver
  25431. {
  25432. protected $owner;
  25433. protected $repository;
  25434. protected $hasIssues;
  25435. protected $rootIdentifier;
  25436. protected $tags;
  25437. protected $branches;
  25438. protected $branchesUrl = '';
  25439. protected $tagsUrl = '';
  25440. protected $homeUrl = '';
  25441. protected $website = '';
  25442. protected $cloneHttpsUrl = '';
  25443. protected $fallbackDriver;
  25444. protected $vcsType;
  25445. public function initialize()
  25446. {
  25447. preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)$#i', $this->url, $match);
  25448. $this->owner = $match[1];
  25449. $this->repository = $match[2];
  25450. $this->originUrl = 'bitbucket.org';
  25451. $this->cache = new Cache(
  25452. $this->io,
  25453. implode('/', array(
  25454. $this->config->get('cache-repo-dir'),
  25455. $this->originUrl,
  25456. $this->owner,
  25457. $this->repository,
  25458. ))
  25459. );
  25460. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25461. }
  25462. public function getUrl()
  25463. {
  25464. if ($this->fallbackDriver) {
  25465. return $this->fallbackDriver->getUrl();
  25466. }
  25467. return $this->cloneHttpsUrl;
  25468. }
  25469. protected function getRepoData()
  25470. {
  25471. $resource = sprintf(
  25472. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  25473. $this->owner,
  25474. $this->repository,
  25475. http_build_query(
  25476. array('fields' => '-project,-owner'),
  25477. null,
  25478. '&'
  25479. )
  25480. );
  25481. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  25482. if ($this->fallbackDriver) {
  25483. return false;
  25484. }
  25485. $this->parseCloneUrls($repoData['links']['clone']);
  25486. $this->hasIssues = !empty($repoData['has_issues']);
  25487. $this->branchesUrl = $repoData['links']['branches']['href'];
  25488. $this->tagsUrl = $repoData['links']['tags']['href'];
  25489. $this->homeUrl = $repoData['links']['html']['href'];
  25490. $this->website = $repoData['website'];
  25491. $this->vcsType = $repoData['scm'];
  25492. return true;
  25493. }
  25494. public function getComposerInformation($identifier)
  25495. {
  25496. if ($this->fallbackDriver) {
  25497. return $this->fallbackDriver->getComposerInformation($identifier);
  25498. }
  25499. if (!isset($this->infoCache[$identifier])) {
  25500. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  25501. $composer = JsonFile::parseJson($res);
  25502. } else {
  25503. $composer = $this->getBaseComposerInformation($identifier);
  25504. if ($this->shouldCache($identifier)) {
  25505. $this->cache->write($identifier, json_encode($composer));
  25506. }
  25507. }
  25508. if ($composer) {
  25509. if (!isset($composer['support']['source'])) {
  25510. $label = array_search(
  25511. $identifier,
  25512. $this->getTags()
  25513. ) ?: array_search(
  25514. $identifier,
  25515. $this->getBranches()
  25516. ) ?: $identifier;
  25517. if (array_key_exists($label, $tags = $this->getTags())) {
  25518. $hash = $tags[$label];
  25519. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  25520. $hash = $branches[$label];
  25521. }
  25522. if (! isset($hash)) {
  25523. $composer['support']['source'] = sprintf(
  25524. 'https://%s/%s/%s/src',
  25525. $this->originUrl,
  25526. $this->owner,
  25527. $this->repository
  25528. );
  25529. } else {
  25530. $composer['support']['source'] = sprintf(
  25531. 'https://%s/%s/%s/src/%s/?at=%s',
  25532. $this->originUrl,
  25533. $this->owner,
  25534. $this->repository,
  25535. $hash,
  25536. $label
  25537. );
  25538. }
  25539. }
  25540. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  25541. $composer['support']['issues'] = sprintf(
  25542. 'https://%s/%s/%s/issues',
  25543. $this->originUrl,
  25544. $this->owner,
  25545. $this->repository
  25546. );
  25547. }
  25548. if (!isset($composer['homepage'])) {
  25549. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  25550. }
  25551. }
  25552. $this->infoCache[$identifier] = $composer;
  25553. }
  25554. return $this->infoCache[$identifier];
  25555. }
  25556. public function getFileContent($file, $identifier)
  25557. {
  25558. if ($this->fallbackDriver) {
  25559. return $this->fallbackDriver->getFileContent($file, $identifier);
  25560. }
  25561. if (strpos($identifier, '/') !== false) {
  25562. $branches = $this->getBranches();
  25563. if (isset($branches[$identifier])) {
  25564. $identifier = $branches[$identifier];
  25565. }
  25566. }
  25567. $resource = sprintf(
  25568. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  25569. $this->owner,
  25570. $this->repository,
  25571. $identifier,
  25572. $file
  25573. );
  25574. return $this->fetchWithOAuthCredentials($resource)->getBody();
  25575. }
  25576. public function getChangeDate($identifier)
  25577. {
  25578. if ($this->fallbackDriver) {
  25579. return $this->fallbackDriver->getChangeDate($identifier);
  25580. }
  25581. if (strpos($identifier, '/') !== false) {
  25582. $branches = $this->getBranches();
  25583. if (isset($branches[$identifier])) {
  25584. $identifier = $branches[$identifier];
  25585. }
  25586. }
  25587. $resource = sprintf(
  25588. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  25589. $this->owner,
  25590. $this->repository,
  25591. $identifier
  25592. );
  25593. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25594. return new \DateTime($commit['date']);
  25595. }
  25596. public function getSource($identifier)
  25597. {
  25598. if ($this->fallbackDriver) {
  25599. return $this->fallbackDriver->getSource($identifier);
  25600. }
  25601. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  25602. }
  25603. public function getDist($identifier)
  25604. {
  25605. if ($this->fallbackDriver) {
  25606. return $this->fallbackDriver->getDist($identifier);
  25607. }
  25608. $url = sprintf(
  25609. 'https://bitbucket.org/%s/%s/get/%s.zip',
  25610. $this->owner,
  25611. $this->repository,
  25612. $identifier
  25613. );
  25614. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  25615. }
  25616. public function getTags()
  25617. {
  25618. if ($this->fallbackDriver) {
  25619. return $this->fallbackDriver->getTags();
  25620. }
  25621. if (null === $this->tags) {
  25622. $this->tags = array();
  25623. $resource = sprintf(
  25624. '%s?%s',
  25625. $this->tagsUrl,
  25626. http_build_query(
  25627. array(
  25628. 'pagelen' => 100,
  25629. 'fields' => 'values.name,values.target.hash,next',
  25630. 'sort' => '-target.date',
  25631. ),
  25632. null,
  25633. '&'
  25634. )
  25635. );
  25636. $hasNext = true;
  25637. while ($hasNext) {
  25638. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25639. foreach ($tagsData['values'] as $data) {
  25640. $this->tags[$data['name']] = $data['target']['hash'];
  25641. }
  25642. if (empty($tagsData['next'])) {
  25643. $hasNext = false;
  25644. } else {
  25645. $resource = $tagsData['next'];
  25646. }
  25647. }
  25648. if ($this->vcsType === 'hg') {
  25649. unset($this->tags['tip']);
  25650. }
  25651. }
  25652. return $this->tags;
  25653. }
  25654. public function getBranches()
  25655. {
  25656. if ($this->fallbackDriver) {
  25657. return $this->fallbackDriver->getBranches();
  25658. }
  25659. if (null === $this->branches) {
  25660. $this->branches = array();
  25661. $resource = sprintf(
  25662. '%s?%s',
  25663. $this->branchesUrl,
  25664. http_build_query(
  25665. array(
  25666. 'pagelen' => 100,
  25667. 'fields' => 'values.name,values.target.hash,values.heads,next',
  25668. 'sort' => '-target.date',
  25669. ),
  25670. null,
  25671. '&'
  25672. )
  25673. );
  25674. $hasNext = true;
  25675. while ($hasNext) {
  25676. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25677. foreach ($branchData['values'] as $data) {
  25678. if ($this->vcsType === 'hg' && empty($data['heads'])) {
  25679. continue;
  25680. }
  25681. $this->branches[$data['name']] = $data['target']['hash'];
  25682. }
  25683. if (empty($branchData['next'])) {
  25684. $hasNext = false;
  25685. } else {
  25686. $resource = $branchData['next'];
  25687. }
  25688. }
  25689. }
  25690. return $this->branches;
  25691. }
  25692. protected function fetchWithOAuthCredentials($url, $fetchingRepoData = false)
  25693. {
  25694. try {
  25695. return parent::getContents($url);
  25696. } catch (TransportException $e) {
  25697. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  25698. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  25699. if (!$this->io->hasAuthentication($this->originUrl)
  25700. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  25701. ) {
  25702. return parent::getContents($url);
  25703. }
  25704. if (!$this->io->isInteractive() && $fetchingRepoData) {
  25705. if ($this->attemptCloneFallback()) {
  25706. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  25707. }
  25708. }
  25709. }
  25710. throw $e;
  25711. }
  25712. }
  25713. abstract protected function generateSshUrl();
  25714. protected function attemptCloneFallback()
  25715. {
  25716. try {
  25717. $this->setupFallbackDriver($this->generateSshUrl());
  25718. return true;
  25719. } catch (\RuntimeException $e) {
  25720. $this->fallbackDriver = null;
  25721. $this->io->writeError(
  25722. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  25723. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  25724. );
  25725. throw $e;
  25726. }
  25727. }
  25728. abstract protected function setupFallbackDriver($url);
  25729. protected function parseCloneUrls(array $cloneLinks)
  25730. {
  25731. foreach ($cloneLinks as $cloneLink) {
  25732. if ($cloneLink['name'] === 'https') {
  25733. $this->cloneHttpsUrl = preg_replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  25734. }
  25735. }
  25736. }
  25737. protected function getMainBranchData()
  25738. {
  25739. $resource = sprintf(
  25740. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  25741. $this->owner,
  25742. $this->repository
  25743. );
  25744. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25745. if (isset($data['mainbranch'])) {
  25746. return $data['mainbranch'];
  25747. }
  25748. return null;
  25749. }
  25750. }
  25751. <?php
  25752. namespace Composer\Repository\Vcs;
  25753. use Composer\Cache;
  25754. use Composer\Config;
  25755. use Composer\Util\ProcessExecutor;
  25756. use Composer\Util\Filesystem;
  25757. use Composer\IO\IOInterface;
  25758. class FossilDriver extends VcsDriver
  25759. {
  25760. protected $tags;
  25761. protected $branches;
  25762. protected $rootIdentifier;
  25763. protected $repoFile;
  25764. protected $checkoutDir;
  25765. public function initialize()
  25766. {
  25767. $this->checkFossil();
  25768. $this->config->prohibitUrlByConfig($this->url, $this->io);
  25769. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  25770. $this->checkoutDir = $this->url;
  25771. } else {
  25772. if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  25773. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  25774. }
  25775. $localName = preg_replace('{[^a-z0-9]}i', '-', $this->url);
  25776. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  25777. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  25778. $this->updateLocalRepo();
  25779. }
  25780. $this->getTags();
  25781. $this->getBranches();
  25782. }
  25783. protected function checkFossil()
  25784. {
  25785. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  25786. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  25787. }
  25788. }
  25789. protected function updateLocalRepo()
  25790. {
  25791. $fs = new Filesystem();
  25792. $fs->ensureDirectoryExists($this->checkoutDir);
  25793. if (!is_writable(dirname($this->checkoutDir))) {
  25794. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  25795. }
  25796. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  25797. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  25798. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  25799. }
  25800. } else {
  25801. $fs->removeDirectory($this->checkoutDir);
  25802. $fs->remove($this->repoFile);
  25803. $fs->ensureDirectoryExists($this->checkoutDir);
  25804. if (0 !== $this->process->execute(sprintf('fossil clone %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  25805. $output = $this->process->getErrorOutput();
  25806. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  25807. }
  25808. if (0 !== $this->process->execute(sprintf('fossil open %s --nested', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  25809. $output = $this->process->getErrorOutput();
  25810. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  25811. }
  25812. }
  25813. }
  25814. public function getRootIdentifier()
  25815. {
  25816. if (null === $this->rootIdentifier) {
  25817. $this->rootIdentifier = 'trunk';
  25818. }
  25819. return $this->rootIdentifier;
  25820. }
  25821. public function getUrl()
  25822. {
  25823. return $this->url;
  25824. }
  25825. public function getSource($identifier)
  25826. {
  25827. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  25828. }
  25829. public function getDist($identifier)
  25830. {
  25831. return null;
  25832. }
  25833. public function getFileContent($file, $identifier)
  25834. {
  25835. $command = sprintf('fossil cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  25836. $this->process->execute($command, $content, $this->checkoutDir);
  25837. if (!trim($content)) {
  25838. return null;
  25839. }
  25840. return $content;
  25841. }
  25842. public function getChangeDate($identifier)
  25843. {
  25844. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  25845. list(,$date) = explode(' ', trim($output), 3);
  25846. return new \DateTime($date, new \DateTimeZone('UTC'));
  25847. }
  25848. public function getTags()
  25849. {
  25850. if (null === $this->tags) {
  25851. $tags = array();
  25852. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  25853. foreach ($this->process->splitLines($output) as $tag) {
  25854. $tags[$tag] = $tag;
  25855. }
  25856. $this->tags = $tags;
  25857. }
  25858. return $this->tags;
  25859. }
  25860. public function getBranches()
  25861. {
  25862. if (null === $this->branches) {
  25863. $branches = array();
  25864. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  25865. foreach ($this->process->splitLines($output) as $branch) {
  25866. $branch = trim(preg_replace('/^\*/', '', trim($branch)));
  25867. $branches[$branch] = $branch;
  25868. }
  25869. $this->branches = $branches;
  25870. }
  25871. return $this->branches;
  25872. }
  25873. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  25874. {
  25875. if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  25876. return true;
  25877. }
  25878. if (preg_match('!/fossil/|\.fossil!', $url)) {
  25879. return true;
  25880. }
  25881. if (Filesystem::isLocalPath($url)) {
  25882. $url = Filesystem::getPlatformPath($url);
  25883. if (!is_dir($url)) {
  25884. return false;
  25885. }
  25886. $process = new ProcessExecutor($io);
  25887. if ($process->execute('fossil info', $output, $url) === 0) {
  25888. return true;
  25889. }
  25890. }
  25891. return false;
  25892. }
  25893. }
  25894. <?php
  25895. namespace Composer\Repository\Vcs;
  25896. use Composer\Config;
  25897. use Composer\IO\IOInterface;
  25898. class GitBitbucketDriver extends BitbucketDriver
  25899. {
  25900. public function getRootIdentifier()
  25901. {
  25902. if ($this->fallbackDriver) {
  25903. return $this->fallbackDriver->getRootIdentifier();
  25904. }
  25905. if (null === $this->rootIdentifier) {
  25906. if (! $this->getRepoData()) {
  25907. return $this->fallbackDriver->getRootIdentifier();
  25908. }
  25909. if ($this->vcsType !== 'git') {
  25910. throw new \RuntimeException(
  25911. $this->url.' does not appear to be a git repository, use '.
  25912. $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository'
  25913. );
  25914. }
  25915. $mainBranchData = $this->getMainBranchData();
  25916. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  25917. }
  25918. return $this->rootIdentifier;
  25919. }
  25920. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  25921. {
  25922. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/(.+?)\.git$#i', $url)) {
  25923. return false;
  25924. }
  25925. if (!extension_loaded('openssl')) {
  25926. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  25927. return false;
  25928. }
  25929. return true;
  25930. }
  25931. protected function setupFallbackDriver($url)
  25932. {
  25933. $this->fallbackDriver = new GitDriver(
  25934. array('url' => $url),
  25935. $this->io,
  25936. $this->config,
  25937. $this->httpDownloader,
  25938. $this->process
  25939. );
  25940. $this->fallbackDriver->initialize();
  25941. }
  25942. protected function generateSshUrl()
  25943. {
  25944. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  25945. }
  25946. }
  25947. <?php
  25948. namespace Composer\Repository\Vcs;
  25949. use Composer\Util\ProcessExecutor;
  25950. use Composer\Util\Filesystem;
  25951. use Composer\Util\Url;
  25952. use Composer\Util\Git as GitUtil;
  25953. use Composer\IO\IOInterface;
  25954. use Composer\Cache;
  25955. use Composer\Config;
  25956. class GitDriver extends VcsDriver
  25957. {
  25958. protected $tags;
  25959. protected $branches;
  25960. protected $rootIdentifier;
  25961. protected $repoDir;
  25962. public function initialize()
  25963. {
  25964. if (Filesystem::isLocalPath($this->url)) {
  25965. $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url);
  25966. $this->repoDir = $this->url;
  25967. $cacheUrl = realpath($this->url);
  25968. } else {
  25969. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  25970. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  25971. }
  25972. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  25973. GitUtil::cleanEnv();
  25974. $fs = new Filesystem();
  25975. $fs->ensureDirectoryExists(dirname($this->repoDir));
  25976. if (!is_writable(dirname($this->repoDir))) {
  25977. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  25978. }
  25979. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  25980. 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.');
  25981. }
  25982. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  25983. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  25984. if (!is_dir($this->repoDir)) {
  25985. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  25986. }
  25987. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  25988. }
  25989. $cacheUrl = $this->url;
  25990. }
  25991. $this->getTags();
  25992. $this->getBranches();
  25993. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  25994. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25995. }
  25996. public function getRootIdentifier()
  25997. {
  25998. if (null === $this->rootIdentifier) {
  25999. $this->rootIdentifier = 'master';
  26000. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  26001. $branches = $this->process->splitLines($output);
  26002. if (!in_array('* master', $branches)) {
  26003. foreach ($branches as $branch) {
  26004. if ($branch && preg_match('{^\* +(\S+)}', $branch, $match)) {
  26005. $this->rootIdentifier = $match[1];
  26006. break;
  26007. }
  26008. }
  26009. }
  26010. }
  26011. return $this->rootIdentifier;
  26012. }
  26013. public function getUrl()
  26014. {
  26015. return $this->url;
  26016. }
  26017. public function getSource($identifier)
  26018. {
  26019. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  26020. }
  26021. public function getDist($identifier)
  26022. {
  26023. return null;
  26024. }
  26025. public function getFileContent($file, $identifier)
  26026. {
  26027. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26028. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  26029. if (!trim($content)) {
  26030. return null;
  26031. }
  26032. return $content;
  26033. }
  26034. public function getChangeDate($identifier)
  26035. {
  26036. $this->process->execute(sprintf(
  26037. 'git -c log.showSignature=false log -1 --format=%%at %s',
  26038. ProcessExecutor::escape($identifier)
  26039. ), $output, $this->repoDir);
  26040. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  26041. }
  26042. public function getTags()
  26043. {
  26044. if (null === $this->tags) {
  26045. $this->tags = array();
  26046. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  26047. foreach ($output = $this->process->splitLines($output) as $tag) {
  26048. if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  26049. $this->tags[$match[2]] = $match[1];
  26050. }
  26051. }
  26052. }
  26053. return $this->tags;
  26054. }
  26055. public function getBranches()
  26056. {
  26057. if (null === $this->branches) {
  26058. $branches = array();
  26059. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  26060. foreach ($this->process->splitLines($output) as $branch) {
  26061. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  26062. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  26063. $branches[$match[1]] = $match[2];
  26064. }
  26065. }
  26066. }
  26067. $this->branches = $branches;
  26068. }
  26069. return $this->branches;
  26070. }
  26071. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26072. {
  26073. if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  26074. return true;
  26075. }
  26076. if (Filesystem::isLocalPath($url)) {
  26077. $url = Filesystem::getPlatformPath($url);
  26078. if (!is_dir($url)) {
  26079. return false;
  26080. }
  26081. $process = new ProcessExecutor($io);
  26082. if ($process->execute('git tag', $output, $url) === 0) {
  26083. return true;
  26084. }
  26085. }
  26086. if (!$deep) {
  26087. return false;
  26088. }
  26089. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  26090. GitUtil::cleanEnv();
  26091. try {
  26092. $gitUtil->runCommand(function ($url) {
  26093. return 'git ls-remote --heads ' . ProcessExecutor::escape($url);
  26094. }, $url, sys_get_temp_dir());
  26095. } catch (\RuntimeException $e) {
  26096. return false;
  26097. }
  26098. return true;
  26099. }
  26100. }
  26101. <?php
  26102. namespace Composer\Repository\Vcs;
  26103. use Composer\Config;
  26104. use Composer\Downloader\TransportException;
  26105. use Composer\Json\JsonFile;
  26106. use Composer\Cache;
  26107. use Composer\IO\IOInterface;
  26108. use Composer\Util\GitHub;
  26109. use Composer\Util\Http\Response;
  26110. class GitHubDriver extends VcsDriver
  26111. {
  26112. protected $owner;
  26113. protected $repository;
  26114. protected $tags;
  26115. protected $branches;
  26116. protected $rootIdentifier;
  26117. protected $repoData;
  26118. protected $hasIssues;
  26119. protected $isPrivate = false;
  26120. private $isArchived = false;
  26121. private $fundingInfo;
  26122. protected $gitDriver;
  26123. public function initialize()
  26124. {
  26125. preg_match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  26126. $this->owner = $match[3];
  26127. $this->repository = $match[4];
  26128. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  26129. if ($this->originUrl === 'www.github.com') {
  26130. $this->originUrl = 'github.com';
  26131. }
  26132. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  26133. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26134. if ( $this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'] ) ){
  26135. $this->setupGitDriver($this->url);
  26136. return;
  26137. }
  26138. $this->fetchRootIdentifier();
  26139. }
  26140. public function getRepositoryUrl()
  26141. {
  26142. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  26143. }
  26144. public function getRootIdentifier()
  26145. {
  26146. if ($this->gitDriver) {
  26147. return $this->gitDriver->getRootIdentifier();
  26148. }
  26149. return $this->rootIdentifier;
  26150. }
  26151. public function getUrl()
  26152. {
  26153. if ($this->gitDriver) {
  26154. return $this->gitDriver->getUrl();
  26155. }
  26156. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26157. }
  26158. protected function getApiUrl()
  26159. {
  26160. if ('github.com' === $this->originUrl) {
  26161. $apiUrl = 'api.github.com';
  26162. } else {
  26163. $apiUrl = $this->originUrl . '/api/v3';
  26164. }
  26165. return 'https://' . $apiUrl;
  26166. }
  26167. public function getSource($identifier)
  26168. {
  26169. if ($this->gitDriver) {
  26170. return $this->gitDriver->getSource($identifier);
  26171. }
  26172. if ($this->isPrivate) {
  26173. $url = $this->generateSshUrl();
  26174. } else {
  26175. $url = $this->getUrl();
  26176. }
  26177. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  26178. }
  26179. public function getDist($identifier)
  26180. {
  26181. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  26182. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26183. }
  26184. public function getComposerInformation($identifier)
  26185. {
  26186. if ($this->gitDriver) {
  26187. return $this->gitDriver->getComposerInformation($identifier);
  26188. }
  26189. if (!isset($this->infoCache[$identifier])) {
  26190. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26191. $composer = JsonFile::parseJson($res);
  26192. } else {
  26193. $composer = $this->getBaseComposerInformation($identifier);
  26194. if ($this->shouldCache($identifier)) {
  26195. $this->cache->write($identifier, json_encode($composer));
  26196. }
  26197. }
  26198. if ($composer) {
  26199. if (!isset($composer['support']['source'])) {
  26200. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  26201. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  26202. }
  26203. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  26204. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  26205. }
  26206. if (!isset($composer['abandoned']) && $this->isArchived) {
  26207. $composer['abandoned'] = true;
  26208. }
  26209. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  26210. $composer['funding'] = $funding;
  26211. }
  26212. }
  26213. $this->infoCache[$identifier] = $composer;
  26214. }
  26215. return $this->infoCache[$identifier];
  26216. }
  26217. private function getFundingInfo()
  26218. {
  26219. if (null !== $this->fundingInfo) {
  26220. return $this->fundingInfo;
  26221. }
  26222. if ($this->originUrl !== 'github.com') {
  26223. return $this->fundingInfo = false;
  26224. }
  26225. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  26226. try {
  26227. $response = $this->httpDownloader->get($file, array(
  26228. 'retry-auth-failure' => false,
  26229. ))->decodeJson();
  26230. } catch (TransportException $e) {
  26231. continue;
  26232. }
  26233. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  26234. continue;
  26235. }
  26236. break;
  26237. }
  26238. if (empty($funding)) {
  26239. return $this->fundingInfo = false;
  26240. }
  26241. $result = array();
  26242. $key = null;
  26243. foreach (preg_split('{\r?\n}', $funding) as $line) {
  26244. $line = trim($line);
  26245. if (preg_match('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  26246. if (preg_match('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  26247. foreach (array_map('trim', preg_split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  26248. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  26249. }
  26250. } elseif (preg_match('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  26251. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  26252. }
  26253. $key = null;
  26254. } elseif (preg_match('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  26255. $key = $match[1];
  26256. } elseif ($key && preg_match('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  26257. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  26258. }
  26259. }
  26260. foreach ($result as $key => $item) {
  26261. switch ($item['type']) {
  26262. case 'tidelift':
  26263. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  26264. break;
  26265. case 'github':
  26266. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  26267. break;
  26268. case 'patreon':
  26269. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  26270. break;
  26271. case 'otechie':
  26272. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  26273. break;
  26274. case 'open_collective':
  26275. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  26276. break;
  26277. case 'liberapay':
  26278. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  26279. break;
  26280. case 'ko_fi':
  26281. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  26282. break;
  26283. case 'issuehunt':
  26284. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  26285. break;
  26286. case 'community_bridge':
  26287. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  26288. break;
  26289. }
  26290. }
  26291. return $this->fundingInfo = $result;
  26292. }
  26293. public function getFileContent($file, $identifier)
  26294. {
  26295. if ($this->gitDriver) {
  26296. return $this->gitDriver->getFileContent($file, $identifier);
  26297. }
  26298. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  26299. $resource = $this->getContents($resource)->decodeJson();
  26300. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  26301. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  26302. }
  26303. return $content;
  26304. }
  26305. public function getChangeDate($identifier)
  26306. {
  26307. if ($this->gitDriver) {
  26308. return $this->gitDriver->getChangeDate($identifier);
  26309. }
  26310. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  26311. $commit = $this->getContents($resource)->decodeJson();
  26312. return new \DateTime($commit['commit']['committer']['date']);
  26313. }
  26314. public function getTags()
  26315. {
  26316. if ($this->gitDriver) {
  26317. return $this->gitDriver->getTags();
  26318. }
  26319. if (null === $this->tags) {
  26320. $this->tags = array();
  26321. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  26322. do {
  26323. $response = $this->getContents($resource);
  26324. $tagsData = $response->decodeJson();
  26325. foreach ($tagsData as $tag) {
  26326. $this->tags[$tag['name']] = $tag['commit']['sha'];
  26327. }
  26328. $resource = $this->getNextPage($response);
  26329. } while ($resource);
  26330. }
  26331. return $this->tags;
  26332. }
  26333. public function getBranches()
  26334. {
  26335. if ($this->gitDriver) {
  26336. return $this->gitDriver->getBranches();
  26337. }
  26338. if (null === $this->branches) {
  26339. $this->branches = array();
  26340. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  26341. do {
  26342. $response = $this->getContents($resource);
  26343. $branchData = $response->decodeJson();
  26344. foreach ($branchData as $branch) {
  26345. $name = substr($branch['ref'], 11);
  26346. if ($name !== 'gh-pages') {
  26347. $this->branches[$name] = $branch['object']['sha'];
  26348. }
  26349. }
  26350. $resource = $this->getNextPage($response);
  26351. } while ($resource);
  26352. }
  26353. return $this->branches;
  26354. }
  26355. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26356. {
  26357. if (!preg_match('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  26358. return false;
  26359. }
  26360. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  26361. if (!in_array(strtolower(preg_replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  26362. return false;
  26363. }
  26364. if (!extension_loaded('openssl')) {
  26365. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26366. return false;
  26367. }
  26368. return true;
  26369. }
  26370. public function getRepoData()
  26371. {
  26372. $this->fetchRootIdentifier();
  26373. return $this->repoData;
  26374. }
  26375. protected function generateSshUrl()
  26376. {
  26377. if (false !== strpos($this->originUrl, ':')) {
  26378. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26379. }
  26380. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  26381. }
  26382. protected function getContents($url, $fetchingRepoData = false)
  26383. {
  26384. try {
  26385. return parent::getContents($url);
  26386. } catch (TransportException $e) {
  26387. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  26388. switch ($e->getCode()) {
  26389. case 401:
  26390. case 404:
  26391. if (!$fetchingRepoData) {
  26392. throw $e;
  26393. }
  26394. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  26395. return parent::getContents($url);
  26396. }
  26397. if (!$this->io->isInteractive()) {
  26398. if ($this->attemptCloneFallback()) {
  26399. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26400. }
  26401. }
  26402. $scopesIssued = array();
  26403. $scopesNeeded = array();
  26404. if ($headers = $e->getHeaders()) {
  26405. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  26406. $scopesIssued = explode(' ', $scopes);
  26407. }
  26408. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  26409. $scopesNeeded = explode(' ', $scopes);
  26410. }
  26411. }
  26412. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  26413. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  26414. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26415. }
  26416. return parent::getContents($url);
  26417. case 403:
  26418. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  26419. return parent::getContents($url);
  26420. }
  26421. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26422. if ($this->attemptCloneFallback()) {
  26423. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26424. }
  26425. }
  26426. $rateLimited = $gitHubUtil->isRateLimited($e->getHeaders());
  26427. if (!$this->io->hasAuthentication($this->originUrl)) {
  26428. if (!$this->io->isInteractive()) {
  26429. $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>');
  26430. throw $e;
  26431. }
  26432. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  26433. return parent::getContents($url);
  26434. }
  26435. if ($rateLimited) {
  26436. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  26437. $this->io->writeError(sprintf(
  26438. '<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>',
  26439. $rateLimit['limit'],
  26440. $rateLimit['reset']
  26441. ));
  26442. }
  26443. throw $e;
  26444. default:
  26445. throw $e;
  26446. }
  26447. }
  26448. }
  26449. protected function fetchRootIdentifier()
  26450. {
  26451. if ($this->repoData) {
  26452. return;
  26453. }
  26454. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  26455. try {
  26456. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  26457. } catch (TransportException $e) {
  26458. if ($e->getCode() === 499) {
  26459. $this->attemptCloneFallback();
  26460. } else {
  26461. throw $e;
  26462. }
  26463. }
  26464. if (null === $this->repoData && null !== $this->gitDriver) {
  26465. return;
  26466. }
  26467. $this->owner = $this->repoData['owner']['login'];
  26468. $this->repository = $this->repoData['name'];
  26469. $this->isPrivate = !empty($this->repoData['private']);
  26470. if (isset($this->repoData['default_branch'])) {
  26471. $this->rootIdentifier = $this->repoData['default_branch'];
  26472. } elseif (isset($this->repoData['master_branch'])) {
  26473. $this->rootIdentifier = $this->repoData['master_branch'];
  26474. } else {
  26475. $this->rootIdentifier = 'master';
  26476. }
  26477. $this->hasIssues = !empty($this->repoData['has_issues']);
  26478. $this->isArchived = !empty($this->repoData['archived']);
  26479. }
  26480. protected function attemptCloneFallback()
  26481. {
  26482. $this->isPrivate = true;
  26483. try {
  26484. $this->setupGitDriver($this->generateSshUrl());
  26485. return true;
  26486. } catch (\RuntimeException $e) {
  26487. $this->gitDriver = null;
  26488. $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>');
  26489. throw $e;
  26490. }
  26491. }
  26492. protected function setupGitDriver($url)
  26493. {
  26494. $this->gitDriver = new GitDriver(
  26495. array('url' => $url),
  26496. $this->io,
  26497. $this->config,
  26498. $this->httpDownloader,
  26499. $this->process
  26500. );
  26501. $this->gitDriver->initialize();
  26502. }
  26503. protected function getNextPage(Response $response)
  26504. {
  26505. $header = $response->getHeader('link');
  26506. $links = explode(',', $header);
  26507. foreach ($links as $link) {
  26508. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26509. return $match[1];
  26510. }
  26511. }
  26512. }
  26513. }
  26514. <?php
  26515. namespace Composer\Repository\Vcs;
  26516. use Composer\Config;
  26517. use Composer\Cache;
  26518. use Composer\IO\IOInterface;
  26519. use Composer\Json\JsonFile;
  26520. use Composer\Downloader\TransportException;
  26521. use Composer\Util\HttpDownloader;
  26522. use Composer\Util\GitLab;
  26523. use Composer\Util\Http\Response;
  26524. class GitLabDriver extends VcsDriver
  26525. {
  26526. private $scheme;
  26527. private $namespace;
  26528. private $repository;
  26529. private $project;
  26530. private $commits = array();
  26531. private $tags;
  26532. private $branches;
  26533. protected $gitDriver;
  26534. private $isPrivate = true;
  26535. private $hasNonstandardOrigin = false;
  26536. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  26537. public function initialize()
  26538. {
  26539. if (!preg_match(self::URL_REGEX, $this->url, $match)) {
  26540. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  26541. }
  26542. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26543. $configuredDomains = $this->config->get('gitlab-domains');
  26544. $urlParts = explode('/', $match['parts']);
  26545. $this->scheme = !empty($match['scheme'])
  26546. ? $match['scheme']
  26547. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  26548. ;
  26549. $this->originUrl = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  26550. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  26551. $this->hasNonstandardOrigin = true;
  26552. }
  26553. $this->namespace = implode('/', $urlParts);
  26554. $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
  26555. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  26556. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26557. $this->fetchProject();
  26558. }
  26559. public function setHttpDownloader(HttpDownloader $httpDownloader)
  26560. {
  26561. $this->httpDownloader = $httpDownloader;
  26562. }
  26563. public function getComposerInformation($identifier)
  26564. {
  26565. if ($this->gitDriver) {
  26566. return $this->gitDriver->getComposerInformation($identifier);
  26567. }
  26568. if (!isset($this->infoCache[$identifier])) {
  26569. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26570. $composer = JsonFile::parseJson($res);
  26571. } else {
  26572. $composer = $this->getBaseComposerInformation($identifier);
  26573. if ($this->shouldCache($identifier)) {
  26574. $this->cache->write($identifier, json_encode($composer));
  26575. }
  26576. }
  26577. if ($composer) {
  26578. if (!isset($composer['support']['issues']) && isset($this->project['_links']['issues'])) {
  26579. $composer['support']['issues'] = $this->project['_links']['issues'];
  26580. }
  26581. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  26582. $composer['abandoned'] = true;
  26583. }
  26584. }
  26585. $this->infoCache[$identifier] = $composer;
  26586. }
  26587. return $this->infoCache[$identifier];
  26588. }
  26589. public function getFileContent($file, $identifier)
  26590. {
  26591. if ($this->gitDriver) {
  26592. return $this->gitDriver->getFileContent($file, $identifier);
  26593. }
  26594. if (!preg_match('{[a-f0-9]{40}}i', $identifier)) {
  26595. $branches = $this->getBranches();
  26596. if (isset($branches[$identifier])) {
  26597. $identifier = $branches[$identifier];
  26598. }
  26599. }
  26600. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  26601. try {
  26602. $content = $this->getContents($resource)->getBody();
  26603. } catch (TransportException $e) {
  26604. if ($e->getCode() !== 404) {
  26605. throw $e;
  26606. }
  26607. return null;
  26608. }
  26609. return $content;
  26610. }
  26611. public function getChangeDate($identifier)
  26612. {
  26613. if ($this->gitDriver) {
  26614. return $this->gitDriver->getChangeDate($identifier);
  26615. }
  26616. if (isset($this->commits[$identifier])) {
  26617. return new \DateTime($this->commits[$identifier]['committed_date']);
  26618. }
  26619. return new \DateTime();
  26620. }
  26621. public function getRepositoryUrl()
  26622. {
  26623. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  26624. }
  26625. public function getUrl()
  26626. {
  26627. if ($this->gitDriver) {
  26628. return $this->gitDriver->getUrl();
  26629. }
  26630. return $this->project['web_url'];
  26631. }
  26632. public function getDist($identifier)
  26633. {
  26634. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  26635. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26636. }
  26637. public function getSource($identifier)
  26638. {
  26639. if ($this->gitDriver) {
  26640. return $this->gitDriver->getSource($identifier);
  26641. }
  26642. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  26643. }
  26644. public function getRootIdentifier()
  26645. {
  26646. if ($this->gitDriver) {
  26647. return $this->gitDriver->getRootIdentifier();
  26648. }
  26649. return $this->project['default_branch'];
  26650. }
  26651. public function getBranches()
  26652. {
  26653. if ($this->gitDriver) {
  26654. return $this->gitDriver->getBranches();
  26655. }
  26656. if (!$this->branches) {
  26657. $this->branches = $this->getReferences('branches');
  26658. }
  26659. return $this->branches;
  26660. }
  26661. public function getTags()
  26662. {
  26663. if ($this->gitDriver) {
  26664. return $this->gitDriver->getTags();
  26665. }
  26666. if (!$this->tags) {
  26667. $this->tags = $this->getReferences('tags');
  26668. }
  26669. return $this->tags;
  26670. }
  26671. public function getApiUrl()
  26672. {
  26673. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  26674. }
  26675. private function urlEncodeAll($string)
  26676. {
  26677. $encoded = '';
  26678. for ($i = 0; isset($string[$i]); $i++) {
  26679. $character = $string[$i];
  26680. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  26681. $character = '%' . sprintf('%02X', ord($character));
  26682. }
  26683. $encoded .= $character;
  26684. }
  26685. return $encoded;
  26686. }
  26687. protected function getReferences($type)
  26688. {
  26689. $perPage = 100;
  26690. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  26691. $references = array();
  26692. do {
  26693. $response = $this->getContents($resource);
  26694. $data = $response->decodeJson();
  26695. foreach ($data as $datum) {
  26696. $references[$datum['name']] = $datum['commit']['id'];
  26697. $this->commits[$datum['commit']['id']] = $datum['commit'];
  26698. }
  26699. if (count($data) >= $perPage) {
  26700. $resource = $this->getNextPage($response);
  26701. } else {
  26702. $resource = false;
  26703. }
  26704. } while ($resource);
  26705. return $references;
  26706. }
  26707. protected function fetchProject()
  26708. {
  26709. $resource = $this->getApiUrl();
  26710. $this->project = $this->getContents($resource, true)->decodeJson();
  26711. if (isset($this->project['visibility'])) {
  26712. $this->isPrivate = $this->project['visibility'] !== 'public';
  26713. } else {
  26714. $this->isPrivate = false;
  26715. }
  26716. }
  26717. protected function attemptCloneFallback()
  26718. {
  26719. if ($this->isPrivate === false) {
  26720. $url = $this->generatePublicUrl();
  26721. } else {
  26722. $url = $this->generateSshUrl();
  26723. }
  26724. try {
  26725. $this->setupGitDriver($url);
  26726. return true;
  26727. } catch (\RuntimeException $e) {
  26728. $this->gitDriver = null;
  26729. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  26730. throw $e;
  26731. }
  26732. }
  26733. protected function generateSshUrl()
  26734. {
  26735. if ($this->hasNonstandardOrigin) {
  26736. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  26737. }
  26738. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  26739. }
  26740. protected function generatePublicUrl()
  26741. {
  26742. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  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 getContents($url, $fetchingRepoData = false)
  26756. {
  26757. try {
  26758. $response = parent::getContents($url);
  26759. if ($fetchingRepoData) {
  26760. $json = $response->decodeJson();
  26761. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  26762. $this->isPrivate = $json['visibility'] !== 'public';
  26763. $moreThanGuestAccess = false;
  26764. foreach ($json['permissions'] as $permission) {
  26765. if ($permission && $permission['access_level'] > 10) {
  26766. $moreThanGuestAccess = true;
  26767. }
  26768. }
  26769. if (!$moreThanGuestAccess) {
  26770. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  26771. return $this->attemptCloneFallback();
  26772. }
  26773. }
  26774. if (!isset($json['default_branch'])) {
  26775. if (!empty($json['id'])) {
  26776. $this->isPrivate = false;
  26777. }
  26778. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  26779. }
  26780. }
  26781. return $response;
  26782. } catch (TransportException $e) {
  26783. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  26784. switch ($e->getCode()) {
  26785. case 401:
  26786. case 404:
  26787. if (!$fetchingRepoData) {
  26788. throw $e;
  26789. }
  26790. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  26791. return parent::getContents($url);
  26792. }
  26793. if (!$this->io->isInteractive()) {
  26794. if ($this->attemptCloneFallback()) {
  26795. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26796. }
  26797. }
  26798. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  26799. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26800. return parent::getContents($url);
  26801. case 403:
  26802. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  26803. return parent::getContents($url);
  26804. }
  26805. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26806. if ($this->attemptCloneFallback()) {
  26807. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26808. }
  26809. }
  26810. throw $e;
  26811. default:
  26812. throw $e;
  26813. }
  26814. }
  26815. }
  26816. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26817. {
  26818. if (!preg_match(self::URL_REGEX, $url, $match)) {
  26819. return false;
  26820. }
  26821. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  26822. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26823. $urlParts = explode('/', $match['parts']);
  26824. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  26825. return false;
  26826. }
  26827. if ('https' === $scheme && !extension_loaded('openssl')) {
  26828. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26829. return false;
  26830. }
  26831. return true;
  26832. }
  26833. protected function getNextPage(Response $response)
  26834. {
  26835. $header = $response->getHeader('link');
  26836. $links = explode(',', $header);
  26837. foreach ($links as $link) {
  26838. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26839. return $match[1];
  26840. }
  26841. }
  26842. }
  26843. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
  26844. {
  26845. $guessedDomain = strtolower($guessedDomain);
  26846. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  26847. if ($portNumber) {
  26848. return $guessedDomain.':'.$portNumber;
  26849. }
  26850. return $guessedDomain;
  26851. }
  26852. if ($portNumber) {
  26853. $guessedDomain .= ':'.$portNumber;
  26854. }
  26855. while (null !== ($part = array_shift($urlParts))) {
  26856. $guessedDomain .= '/' . $part;
  26857. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array(preg_replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  26858. return $guessedDomain;
  26859. }
  26860. }
  26861. return false;
  26862. }
  26863. }
  26864. <?php
  26865. namespace Composer\Repository\Vcs;
  26866. use Composer\Config;
  26867. use Composer\IO\IOInterface;
  26868. class HgBitbucketDriver extends BitbucketDriver
  26869. {
  26870. public function getRootIdentifier()
  26871. {
  26872. if ($this->fallbackDriver) {
  26873. return $this->fallbackDriver->getRootIdentifier();
  26874. }
  26875. if (null === $this->rootIdentifier) {
  26876. if (! $this->getRepoData()) {
  26877. return $this->fallbackDriver->getRootIdentifier();
  26878. }
  26879. if ($this->vcsType !== 'hg') {
  26880. throw new \RuntimeException(
  26881. $this->url.' does not appear to be a mercurial repository, use '.
  26882. $this->cloneHttpsUrl.' if this is a git bitbucket repository'
  26883. );
  26884. }
  26885. $mainBranchData = $this->getMainBranchData();
  26886. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default';
  26887. }
  26888. return $this->rootIdentifier;
  26889. }
  26890. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26891. {
  26892. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#i', $url)) {
  26893. return false;
  26894. }
  26895. if (!extension_loaded('openssl')) {
  26896. $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26897. return false;
  26898. }
  26899. return true;
  26900. }
  26901. protected function setupFallbackDriver($url)
  26902. {
  26903. $this->fallbackDriver = new HgDriver(
  26904. array('url' => $url),
  26905. $this->io,
  26906. $this->config,
  26907. $this->httpDownloader,
  26908. $this->process
  26909. );
  26910. $this->fallbackDriver->initialize();
  26911. }
  26912. protected function generateSshUrl()
  26913. {
  26914. return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository;
  26915. }
  26916. }
  26917. <?php
  26918. namespace Composer\Repository\Vcs;
  26919. use Composer\Config;
  26920. use Composer\Cache;
  26921. use Composer\Util\Hg as HgUtils;
  26922. use Composer\Util\ProcessExecutor;
  26923. use Composer\Util\Filesystem;
  26924. use Composer\IO\IOInterface;
  26925. class HgDriver extends VcsDriver
  26926. {
  26927. protected $tags;
  26928. protected $branches;
  26929. protected $rootIdentifier;
  26930. protected $repoDir;
  26931. public function initialize()
  26932. {
  26933. if (Filesystem::isLocalPath($this->url)) {
  26934. $this->repoDir = $this->url;
  26935. } else {
  26936. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26937. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26938. }
  26939. $cacheDir = $this->config->get('cache-vcs-dir');
  26940. $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  26941. $fs = new Filesystem();
  26942. $fs->ensureDirectoryExists($cacheDir);
  26943. if (!is_writable(dirname($this->repoDir))) {
  26944. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  26945. }
  26946. $this->config->prohibitUrlByConfig($this->url, $this->io);
  26947. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  26948. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  26949. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  26950. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  26951. }
  26952. } else {
  26953. $fs->removeDirectory($this->repoDir);
  26954. $repoDir = $this->repoDir;
  26955. $command = function ($url) use ($repoDir) {
  26956. return sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  26957. };
  26958. $hgUtils->runCommand($command, $this->url, null);
  26959. }
  26960. }
  26961. $this->getTags();
  26962. $this->getBranches();
  26963. }
  26964. public function getRootIdentifier()
  26965. {
  26966. if (null === $this->rootIdentifier) {
  26967. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  26968. $output = $this->process->splitLines($output);
  26969. $this->rootIdentifier = $output[0];
  26970. }
  26971. return $this->rootIdentifier;
  26972. }
  26973. public function getUrl()
  26974. {
  26975. return $this->url;
  26976. }
  26977. public function getSource($identifier)
  26978. {
  26979. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  26980. }
  26981. public function getDist($identifier)
  26982. {
  26983. return null;
  26984. }
  26985. public function getFileContent($file, $identifier)
  26986. {
  26987. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26988. $this->process->execute($resource, $content, $this->repoDir);
  26989. if (!trim($content)) {
  26990. return;
  26991. }
  26992. return $content;
  26993. }
  26994. public function getChangeDate($identifier)
  26995. {
  26996. $this->process->execute(
  26997. sprintf(
  26998. 'hg log --template "{date|rfc3339date}" -r %s',
  26999. ProcessExecutor::escape($identifier)
  27000. ),
  27001. $output,
  27002. $this->repoDir
  27003. );
  27004. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  27005. }
  27006. public function getTags()
  27007. {
  27008. if (null === $this->tags) {
  27009. $tags = array();
  27010. $this->process->execute('hg tags', $output, $this->repoDir);
  27011. foreach ($this->process->splitLines($output) as $tag) {
  27012. if ($tag && preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  27013. $tags[$match[1]] = $match[2];
  27014. }
  27015. }
  27016. unset($tags['tip']);
  27017. $this->tags = $tags;
  27018. }
  27019. return $this->tags;
  27020. }
  27021. public function getBranches()
  27022. {
  27023. if (null === $this->branches) {
  27024. $branches = array();
  27025. $bookmarks = array();
  27026. $this->process->execute('hg branches', $output, $this->repoDir);
  27027. foreach ($this->process->splitLines($output) as $branch) {
  27028. if ($branch && preg_match('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  27029. $branches[$match[1]] = $match[2];
  27030. }
  27031. }
  27032. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  27033. foreach ($this->process->splitLines($output) as $branch) {
  27034. if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  27035. $bookmarks[$match[1]] = $match[2];
  27036. }
  27037. }
  27038. $this->branches = array_merge($bookmarks, $branches);
  27039. }
  27040. return $this->branches;
  27041. }
  27042. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27043. {
  27044. if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  27045. return true;
  27046. }
  27047. if (Filesystem::isLocalPath($url)) {
  27048. $url = Filesystem::getPlatformPath($url);
  27049. if (!is_dir($url)) {
  27050. return false;
  27051. }
  27052. $process = new ProcessExecutor($io);
  27053. if ($process->execute('hg summary', $output, $url) === 0) {
  27054. return true;
  27055. }
  27056. }
  27057. if (!$deep) {
  27058. return false;
  27059. }
  27060. $process = new ProcessExecutor($io);
  27061. $exit = $process->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored);
  27062. return $exit === 0;
  27063. }
  27064. }
  27065. <?php
  27066. namespace Composer\Repository\Vcs;
  27067. use Composer\Config;
  27068. use Composer\Cache;
  27069. use Composer\IO\IOInterface;
  27070. use Composer\Util\ProcessExecutor;
  27071. use Composer\Util\Perforce;
  27072. class PerforceDriver extends VcsDriver
  27073. {
  27074. protected $depot;
  27075. protected $branch;
  27076. protected $perforce;
  27077. public function initialize()
  27078. {
  27079. $this->depot = $this->repoConfig['depot'];
  27080. $this->branch = '';
  27081. if (!empty($this->repoConfig['branch'])) {
  27082. $this->branch = $this->repoConfig['branch'];
  27083. }
  27084. $this->initPerforce($this->repoConfig);
  27085. $this->perforce->p4Login();
  27086. $this->perforce->checkStream();
  27087. $this->perforce->writeP4ClientSpec();
  27088. $this->perforce->connectClient();
  27089. return true;
  27090. }
  27091. private function initPerforce($repoConfig)
  27092. {
  27093. if (!empty($this->perforce)) {
  27094. return;
  27095. }
  27096. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  27097. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27098. }
  27099. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  27100. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  27101. }
  27102. public function getFileContent($file, $identifier)
  27103. {
  27104. return $this->perforce->getFileContent($file, $identifier);
  27105. }
  27106. public function getChangeDate($identifier)
  27107. {
  27108. return null;
  27109. }
  27110. public function getRootIdentifier()
  27111. {
  27112. return $this->branch;
  27113. }
  27114. public function getBranches()
  27115. {
  27116. return $this->perforce->getBranches();
  27117. }
  27118. public function getTags()
  27119. {
  27120. return $this->perforce->getTags();
  27121. }
  27122. public function getDist($identifier)
  27123. {
  27124. return null;
  27125. }
  27126. public function getSource($identifier)
  27127. {
  27128. return array(
  27129. 'type' => 'perforce',
  27130. 'url' => $this->repoConfig['url'],
  27131. 'reference' => $identifier,
  27132. 'p4user' => $this->perforce->getUser(),
  27133. );
  27134. }
  27135. public function getUrl()
  27136. {
  27137. return $this->url;
  27138. }
  27139. public function hasComposerFile($identifier)
  27140. {
  27141. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  27142. return !empty($composerInfo);
  27143. }
  27144. public function getContents($url)
  27145. {
  27146. return false;
  27147. }
  27148. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27149. {
  27150. if ($deep || preg_match('#\b(perforce|p4)\b#i', $url)) {
  27151. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  27152. }
  27153. return false;
  27154. }
  27155. public function cleanup()
  27156. {
  27157. $this->perforce->cleanupClientSpec();
  27158. $this->perforce = null;
  27159. }
  27160. public function getDepot()
  27161. {
  27162. return $this->depot;
  27163. }
  27164. public function getBranch()
  27165. {
  27166. return $this->branch;
  27167. }
  27168. }
  27169. <?php
  27170. namespace Composer\Repository\Vcs;
  27171. use Composer\Cache;
  27172. use Composer\Config;
  27173. use Composer\Json\JsonFile;
  27174. use Composer\Util\ProcessExecutor;
  27175. use Composer\Util\Filesystem;
  27176. use Composer\Util\Url;
  27177. use Composer\Util\Svn as SvnUtil;
  27178. use Composer\IO\IOInterface;
  27179. use Composer\Downloader\TransportException;
  27180. class SvnDriver extends VcsDriver
  27181. {
  27182. protected $baseUrl;
  27183. protected $tags;
  27184. protected $branches;
  27185. protected $rootIdentifier;
  27186. protected $trunkPath = 'trunk';
  27187. protected $branchesPath = 'branches';
  27188. protected $tagsPath = 'tags';
  27189. protected $packagePath = '';
  27190. protected $cacheCredentials = true;
  27191. private $util;
  27192. public function initialize()
  27193. {
  27194. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  27195. SvnUtil::cleanEnv();
  27196. if (isset($this->repoConfig['trunk-path'])) {
  27197. $this->trunkPath = $this->repoConfig['trunk-path'];
  27198. }
  27199. if (isset($this->repoConfig['branches-path'])) {
  27200. $this->branchesPath = $this->repoConfig['branches-path'];
  27201. }
  27202. if (isset($this->repoConfig['tags-path'])) {
  27203. $this->tagsPath = $this->repoConfig['tags-path'];
  27204. }
  27205. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  27206. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  27207. }
  27208. if (isset($this->repoConfig['package-path'])) {
  27209. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  27210. }
  27211. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  27212. $this->baseUrl = substr($this->url, 0, $pos);
  27213. }
  27214. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  27215. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27216. $this->getBranches();
  27217. $this->getTags();
  27218. }
  27219. public function getRootIdentifier()
  27220. {
  27221. return $this->rootIdentifier ?: $this->trunkPath;
  27222. }
  27223. public function getUrl()
  27224. {
  27225. return $this->url;
  27226. }
  27227. public function getSource($identifier)
  27228. {
  27229. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  27230. }
  27231. public function getDist($identifier)
  27232. {
  27233. return null;
  27234. }
  27235. protected function shouldCache($identifier)
  27236. {
  27237. return $this->cache && preg_match('{@\d+$}', $identifier);
  27238. }
  27239. public function getComposerInformation($identifier)
  27240. {
  27241. if (!isset($this->infoCache[$identifier])) {
  27242. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  27243. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27244. }
  27245. try {
  27246. $composer = $this->getBaseComposerInformation($identifier);
  27247. } catch (TransportException $e) {
  27248. $message = $e->getMessage();
  27249. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  27250. throw $e;
  27251. }
  27252. $composer = '';
  27253. }
  27254. if ($this->shouldCache($identifier)) {
  27255. $this->cache->write($identifier.'.json', json_encode($composer));
  27256. }
  27257. $this->infoCache[$identifier] = $composer;
  27258. }
  27259. return $this->infoCache[$identifier];
  27260. }
  27261. public function getFileContent($file, $identifier)
  27262. {
  27263. $identifier = '/' . trim($identifier, '/') . '/';
  27264. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27265. if (!empty($match[2])) {
  27266. $path = $match[1];
  27267. $rev = $match[2];
  27268. } else {
  27269. $path = $identifier;
  27270. $rev = '';
  27271. }
  27272. try {
  27273. $resource = $path.$file;
  27274. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  27275. if (!trim($output)) {
  27276. return null;
  27277. }
  27278. } catch (\RuntimeException $e) {
  27279. throw new TransportException($e->getMessage());
  27280. }
  27281. return $output;
  27282. }
  27283. public function getChangeDate($identifier)
  27284. {
  27285. $identifier = '/' . trim($identifier, '/') . '/';
  27286. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27287. if (!empty($match[2])) {
  27288. $path = $match[1];
  27289. $rev = $match[2];
  27290. } else {
  27291. $path = $identifier;
  27292. $rev = '';
  27293. }
  27294. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  27295. foreach ($this->process->splitLines($output) as $line) {
  27296. if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  27297. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  27298. }
  27299. }
  27300. return null;
  27301. }
  27302. public function getTags()
  27303. {
  27304. if (null === $this->tags) {
  27305. $this->tags = array();
  27306. if ($this->tagsPath !== false) {
  27307. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  27308. if ($output) {
  27309. foreach ($this->process->splitLines($output) as $line) {
  27310. $line = trim($line);
  27311. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27312. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27313. $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  27314. '/' . $this->tagsPath . '/' . $match[2],
  27315. $match[1]
  27316. );
  27317. }
  27318. }
  27319. }
  27320. }
  27321. }
  27322. }
  27323. return $this->tags;
  27324. }
  27325. public function getBranches()
  27326. {
  27327. if (null === $this->branches) {
  27328. $this->branches = array();
  27329. if (false === $this->trunkPath) {
  27330. $trunkParent = $this->baseUrl . '/';
  27331. } else {
  27332. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  27333. }
  27334. $output = $this->execute('svn ls --verbose', $trunkParent);
  27335. if ($output) {
  27336. foreach ($this->process->splitLines($output) as $line) {
  27337. $line = trim($line);
  27338. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27339. if (isset($match[1], $match[2]) && $match[2] === './') {
  27340. $this->branches['trunk'] = $this->buildIdentifier(
  27341. '/' . $this->trunkPath,
  27342. $match[1]
  27343. );
  27344. $this->rootIdentifier = $this->branches['trunk'];
  27345. break;
  27346. }
  27347. }
  27348. }
  27349. }
  27350. unset($output);
  27351. if ($this->branchesPath !== false) {
  27352. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  27353. if ($output) {
  27354. foreach ($this->process->splitLines(trim($output)) as $line) {
  27355. $line = trim($line);
  27356. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27357. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27358. $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  27359. '/' . $this->branchesPath . '/' . $match[2],
  27360. $match[1]
  27361. );
  27362. }
  27363. }
  27364. }
  27365. }
  27366. }
  27367. }
  27368. return $this->branches;
  27369. }
  27370. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27371. {
  27372. $url = self::normalizeUrl($url);
  27373. if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  27374. return true;
  27375. }
  27376. if (!$deep && !Filesystem::isLocalPath($url)) {
  27377. return false;
  27378. }
  27379. $process = new ProcessExecutor($io);
  27380. $exit = $process->execute(
  27381. "svn info --non-interactive ".ProcessExecutor::escape($url),
  27382. $ignoredOutput
  27383. );
  27384. if ($exit === 0) {
  27385. return true;
  27386. }
  27387. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  27388. return true;
  27389. }
  27390. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  27391. return true;
  27392. }
  27393. return false;
  27394. }
  27395. protected static function normalizeUrl($url)
  27396. {
  27397. $fs = new Filesystem();
  27398. if ($fs->isAbsolutePath($url)) {
  27399. return 'file://' . strtr($url, '\\', '/');
  27400. }
  27401. return $url;
  27402. }
  27403. protected function execute($command, $url)
  27404. {
  27405. if (null === $this->util) {
  27406. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  27407. $this->util->setCacheCredentials($this->cacheCredentials);
  27408. }
  27409. try {
  27410. return $this->util->execute($command, $url);
  27411. } catch (\RuntimeException $e) {
  27412. if (null === $this->util->binaryVersion()) {
  27413. 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());
  27414. }
  27415. throw new \RuntimeException(
  27416. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  27417. );
  27418. }
  27419. }
  27420. protected function buildIdentifier($baseDir, $revision)
  27421. {
  27422. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  27423. }
  27424. }
  27425. <?php
  27426. namespace Composer\Repository\Vcs;
  27427. use Composer\Cache;
  27428. use Composer\Downloader\TransportException;
  27429. use Composer\Config;
  27430. use Composer\Factory;
  27431. use Composer\IO\IOInterface;
  27432. use Composer\Json\JsonFile;
  27433. use Composer\Util\ProcessExecutor;
  27434. use Composer\Util\HttpDownloader;
  27435. use Composer\Util\Filesystem;
  27436. use Composer\Util\Http\Response;
  27437. abstract class VcsDriver implements VcsDriverInterface
  27438. {
  27439. protected $url;
  27440. protected $originUrl;
  27441. protected $repoConfig;
  27442. protected $io;
  27443. protected $config;
  27444. protected $process;
  27445. protected $httpDownloader;
  27446. protected $infoCache = array();
  27447. protected $cache;
  27448. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  27449. {
  27450. if (Filesystem::isLocalPath($repoConfig['url'])) {
  27451. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  27452. }
  27453. $this->url = $repoConfig['url'];
  27454. $this->originUrl = $repoConfig['url'];
  27455. $this->repoConfig = $repoConfig;
  27456. $this->io = $io;
  27457. $this->config = $config;
  27458. $this->httpDownloader = $httpDownloader;
  27459. $this->process = $process;
  27460. }
  27461. protected function shouldCache($identifier)
  27462. {
  27463. return $this->cache && preg_match('{^[a-f0-9]{40}$}iD', $identifier);
  27464. }
  27465. public function getComposerInformation($identifier)
  27466. {
  27467. if (!isset($this->infoCache[$identifier])) {
  27468. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  27469. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27470. }
  27471. $composer = $this->getBaseComposerInformation($identifier);
  27472. if ($this->shouldCache($identifier)) {
  27473. $this->cache->write($identifier, json_encode($composer));
  27474. }
  27475. $this->infoCache[$identifier] = $composer;
  27476. }
  27477. return $this->infoCache[$identifier];
  27478. }
  27479. protected function getBaseComposerInformation($identifier)
  27480. {
  27481. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  27482. if (!$composerFileContent) {
  27483. return null;
  27484. }
  27485. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  27486. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  27487. $composer['time'] = $changeDate->format(DATE_RFC3339);
  27488. }
  27489. return $composer;
  27490. }
  27491. public function hasComposerFile($identifier)
  27492. {
  27493. try {
  27494. return (bool) $this->getComposerInformation($identifier);
  27495. } catch (TransportException $e) {
  27496. }
  27497. return false;
  27498. }
  27499. protected function getScheme()
  27500. {
  27501. if (extension_loaded('openssl')) {
  27502. return 'https';
  27503. }
  27504. return 'http';
  27505. }
  27506. protected function getContents($url)
  27507. {
  27508. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  27509. return $this->httpDownloader->get($url, $options);
  27510. }
  27511. public function cleanup()
  27512. {
  27513. return;
  27514. }
  27515. }
  27516. <?php
  27517. namespace Composer\Repository\Vcs;
  27518. use Composer\Config;
  27519. use Composer\IO\IOInterface;
  27520. interface VcsDriverInterface
  27521. {
  27522. public function initialize();
  27523. public function getComposerInformation($identifier);
  27524. public function getFileContent($file, $identifier);
  27525. public function getChangeDate($identifier);
  27526. public function getRootIdentifier();
  27527. public function getBranches();
  27528. public function getTags();
  27529. public function getDist($identifier);
  27530. public function getSource($identifier);
  27531. public function getUrl();
  27532. public function hasComposerFile($identifier);
  27533. public function cleanup();
  27534. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  27535. }
  27536. <?php
  27537. namespace Composer\Repository;
  27538. use Composer\Downloader\TransportException;
  27539. use Composer\Repository\Vcs\VcsDriverInterface;
  27540. use Composer\Package\Version\VersionParser;
  27541. use Composer\Package\Loader\ArrayLoader;
  27542. use Composer\Package\Loader\ValidatingArrayLoader;
  27543. use Composer\Package\Loader\InvalidPackageException;
  27544. use Composer\Package\Loader\LoaderInterface;
  27545. use Composer\EventDispatcher\EventDispatcher;
  27546. use Composer\Util\ProcessExecutor;
  27547. use Composer\Util\HttpDownloader;
  27548. use Composer\Util\Url;
  27549. use Composer\Semver\Constraint\Constraint;
  27550. use Composer\IO\IOInterface;
  27551. use Composer\Config;
  27552. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27553. {
  27554. protected $url;
  27555. protected $packageName;
  27556. protected $isVerbose;
  27557. protected $isVeryVerbose;
  27558. protected $io;
  27559. protected $config;
  27560. protected $versionParser;
  27561. protected $type;
  27562. protected $loader;
  27563. protected $repoConfig;
  27564. protected $httpDownloader;
  27565. protected $processExecutor;
  27566. protected $branchErrorOccurred = false;
  27567. private $drivers;
  27568. private $driver;
  27569. private $versionCache;
  27570. private $emptyReferences = array();
  27571. private $versionTransportExceptions = array();
  27572. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  27573. {
  27574. parent::__construct();
  27575. $this->drivers = $drivers ?: array(
  27576. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  27577. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  27578. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  27579. 'git' => 'Composer\Repository\Vcs\GitDriver',
  27580. 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
  27581. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  27582. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  27583. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  27584. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  27585. );
  27586. $this->url = $repoConfig['url'];
  27587. $this->io = $io;
  27588. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  27589. $this->isVerbose = $io->isVerbose();
  27590. $this->isVeryVerbose = $io->isVeryVerbose();
  27591. $this->config = $config;
  27592. $this->repoConfig = $repoConfig;
  27593. $this->versionCache = $versionCache;
  27594. $this->httpDownloader = $httpDownloader;
  27595. $this->processExecutor = $process ?: new ProcessExecutor($io);
  27596. }
  27597. public function getRepoName()
  27598. {
  27599. $driverClass = get_class($this->getDriver());
  27600. $driverType = array_search($driverClass, $this->drivers);
  27601. if (!$driverType) {
  27602. $driverType = $driverClass;
  27603. }
  27604. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  27605. }
  27606. public function getRepoConfig()
  27607. {
  27608. return $this->repoConfig;
  27609. }
  27610. public function setLoader(LoaderInterface $loader)
  27611. {
  27612. $this->loader = $loader;
  27613. }
  27614. public function getDriver()
  27615. {
  27616. if ($this->driver) {
  27617. return $this->driver;
  27618. }
  27619. if (isset($this->drivers[$this->type])) {
  27620. $class = $this->drivers[$this->type];
  27621. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27622. $this->driver->initialize();
  27623. return $this->driver;
  27624. }
  27625. foreach ($this->drivers as $driver) {
  27626. if ($driver::supports($this->io, $this->config, $this->url)) {
  27627. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27628. $this->driver->initialize();
  27629. return $this->driver;
  27630. }
  27631. }
  27632. foreach ($this->drivers as $driver) {
  27633. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  27634. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27635. $this->driver->initialize();
  27636. return $this->driver;
  27637. }
  27638. }
  27639. }
  27640. public function hadInvalidBranches()
  27641. {
  27642. return $this->branchErrorOccurred;
  27643. }
  27644. public function getEmptyReferences()
  27645. {
  27646. return $this->emptyReferences;
  27647. }
  27648. public function getVersionTransportExceptions()
  27649. {
  27650. return $this->versionTransportExceptions;
  27651. }
  27652. protected function initialize()
  27653. {
  27654. parent::initialize();
  27655. $isVerbose = $this->isVerbose;
  27656. $isVeryVerbose = $this->isVeryVerbose;
  27657. $driver = $this->getDriver();
  27658. if (!$driver) {
  27659. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  27660. }
  27661. $this->versionParser = new VersionParser;
  27662. if (!$this->loader) {
  27663. $this->loader = new ArrayLoader($this->versionParser);
  27664. }
  27665. $hasRootIdentifierComposerJson = false;
  27666. try {
  27667. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  27668. if ($hasRootIdentifierComposerJson) {
  27669. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  27670. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  27671. }
  27672. } catch (\Exception $e) {
  27673. if ($isVeryVerbose) {
  27674. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  27675. }
  27676. }
  27677. foreach ($driver->getTags() as $tag => $identifier) {
  27678. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  27679. if ($isVeryVerbose) {
  27680. $this->io->writeError($msg);
  27681. } elseif ($isVerbose) {
  27682. $this->io->overwriteError($msg, false);
  27683. }
  27684. $tag = str_replace('release-', '', $tag);
  27685. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  27686. if ($cachedPackage) {
  27687. $this->addPackage($cachedPackage);
  27688. continue;
  27689. }
  27690. if ($cachedPackage === false) {
  27691. $this->emptyReferences[] = $identifier;
  27692. continue;
  27693. }
  27694. if (!$parsedTag = $this->validateTag($tag)) {
  27695. if ($isVeryVerbose) {
  27696. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  27697. }
  27698. continue;
  27699. }
  27700. try {
  27701. if (!$data = $driver->getComposerInformation($identifier)) {
  27702. if ($isVeryVerbose) {
  27703. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  27704. }
  27705. $this->emptyReferences[] = $identifier;
  27706. continue;
  27707. }
  27708. if (isset($data['version'])) {
  27709. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  27710. } else {
  27711. $data['version'] = $tag;
  27712. $data['version_normalized'] = $parsedTag;
  27713. }
  27714. $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
  27715. $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  27716. unset($data['default-branch']);
  27717. if ($data['version_normalized'] !== $parsedTag) {
  27718. if ($isVeryVerbose) {
  27719. if (preg_match('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  27720. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  27721. } else {
  27722. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  27723. }
  27724. }
  27725. continue;
  27726. }
  27727. $tagPackageName = isset($data['name']) ? $data['name'] : $this->packageName;
  27728. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  27729. if ($isVeryVerbose) {
  27730. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  27731. }
  27732. continue;
  27733. }
  27734. if ($isVeryVerbose) {
  27735. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  27736. }
  27737. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  27738. } catch (\Exception $e) {
  27739. if ($e instanceof TransportException) {
  27740. $this->versionTransportExceptions['tags'][$tag] = $e;
  27741. if ($e->getCode() === 404) {
  27742. $this->emptyReferences[] = $identifier;
  27743. }
  27744. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27745. throw $e;
  27746. }
  27747. }
  27748. if ($isVeryVerbose) {
  27749. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  27750. }
  27751. continue;
  27752. }
  27753. }
  27754. if (!$isVeryVerbose) {
  27755. $this->io->overwriteError('', false);
  27756. }
  27757. $branches = $driver->getBranches();
  27758. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  27759. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  27760. }
  27761. foreach ($branches as $branch => $identifier) {
  27762. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  27763. if ($isVeryVerbose) {
  27764. $this->io->writeError($msg);
  27765. } elseif ($isVerbose) {
  27766. $this->io->overwriteError($msg, false);
  27767. }
  27768. if (!$parsedBranch = $this->validateBranch($branch)) {
  27769. if ($isVeryVerbose) {
  27770. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  27771. }
  27772. continue;
  27773. }
  27774. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  27775. $version = 'dev-' . $branch;
  27776. } else {
  27777. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  27778. $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
  27779. }
  27780. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  27781. if ($cachedPackage) {
  27782. $this->addPackage($cachedPackage);
  27783. continue;
  27784. }
  27785. if ($cachedPackage === false) {
  27786. $this->emptyReferences[] = $identifier;
  27787. continue;
  27788. }
  27789. try {
  27790. if (!$data = $driver->getComposerInformation($identifier)) {
  27791. if ($isVeryVerbose) {
  27792. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  27793. }
  27794. $this->emptyReferences[] = $identifier;
  27795. continue;
  27796. }
  27797. $data['version'] = $version;
  27798. $data['version_normalized'] = $parsedBranch;
  27799. unset($data['default-branch']);
  27800. if ($driver->getRootIdentifier() === $branch) {
  27801. $data['default-branch'] = true;
  27802. }
  27803. if ($isVeryVerbose) {
  27804. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  27805. }
  27806. $packageData = $this->preProcess($driver, $data, $identifier);
  27807. $package = $this->loader->load($packageData);
  27808. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  27809. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  27810. }
  27811. $this->addPackage($package);
  27812. } catch (TransportException $e) {
  27813. $this->versionTransportExceptions['branches'][$branch] = $e;
  27814. if ($e->getCode() === 404) {
  27815. $this->emptyReferences[] = $identifier;
  27816. }
  27817. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27818. throw $e;
  27819. }
  27820. if ($isVeryVerbose) {
  27821. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  27822. }
  27823. continue;
  27824. } catch (\Exception $e) {
  27825. if (!$isVeryVerbose) {
  27826. $this->io->writeError('');
  27827. }
  27828. $this->branchErrorOccurred = true;
  27829. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  27830. $this->io->writeError('');
  27831. continue;
  27832. }
  27833. }
  27834. $driver->cleanup();
  27835. if (!$isVeryVerbose) {
  27836. $this->io->overwriteError('', false);
  27837. }
  27838. if (!$this->getPackages()) {
  27839. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  27840. }
  27841. }
  27842. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  27843. {
  27844. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  27845. $data['name'] = $this->packageName ?: $dataPackageName;
  27846. if (!isset($data['dist'])) {
  27847. $data['dist'] = $driver->getDist($identifier);
  27848. }
  27849. if (!isset($data['source'])) {
  27850. $data['source'] = $driver->getSource($identifier);
  27851. }
  27852. return $data;
  27853. }
  27854. private function validateBranch($branch)
  27855. {
  27856. try {
  27857. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  27858. $this->versionParser->parseConstraints($normalizedBranch);
  27859. return $normalizedBranch;
  27860. } catch (\Exception $e) {
  27861. }
  27862. return false;
  27863. }
  27864. private function validateTag($version)
  27865. {
  27866. try {
  27867. return $this->versionParser->normalize($version);
  27868. } catch (\Exception $e) {
  27869. }
  27870. return false;
  27871. }
  27872. private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
  27873. {
  27874. if (!$this->versionCache) {
  27875. return;
  27876. }
  27877. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  27878. if ($cachedPackage === false) {
  27879. if ($isVeryVerbose) {
  27880. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  27881. }
  27882. return false;
  27883. }
  27884. if ($cachedPackage) {
  27885. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  27886. if ($isVeryVerbose) {
  27887. $this->io->writeError($msg);
  27888. } elseif ($isVerbose) {
  27889. $this->io->overwriteError($msg, false);
  27890. }
  27891. unset($cachedPackage['default-branch']);
  27892. if ($isDefaultBranch) {
  27893. $cachedPackage['default-branch'] = true;
  27894. }
  27895. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  27896. if ($isVeryVerbose) {
  27897. $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>');
  27898. }
  27899. $cachedPackage = null;
  27900. }
  27901. }
  27902. if ($cachedPackage) {
  27903. return $this->loader->load($cachedPackage);
  27904. }
  27905. return null;
  27906. }
  27907. }
  27908. <?php
  27909. namespace Composer\Repository;
  27910. interface VersionCacheInterface
  27911. {
  27912. public function getVersionPackage($version, $identifier);
  27913. }
  27914. <?php
  27915. namespace Composer\Repository;
  27916. use Composer\Package\AliasPackage;
  27917. use Composer\Installer\InstallationManager;
  27918. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  27919. {
  27920. protected $devPackageNames = array();
  27921. public function setDevPackageNames(array $devPackageNames)
  27922. {
  27923. $this->devPackageNames = $devPackageNames;
  27924. }
  27925. public function getDevPackageNames()
  27926. {
  27927. return $this->devPackageNames;
  27928. }
  27929. public function write($devMode, InstallationManager $installationManager)
  27930. {
  27931. }
  27932. public function reload()
  27933. {
  27934. }
  27935. public function getCanonicalPackages()
  27936. {
  27937. $packages = $this->getPackages();
  27938. $packagesByName = array();
  27939. foreach ($packages as $package) {
  27940. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  27941. $packagesByName[$package->getName()] = $package;
  27942. }
  27943. }
  27944. $canonicalPackages = array();
  27945. foreach ($packagesByName as $package) {
  27946. while ($package instanceof AliasPackage) {
  27947. $package = $package->getAliasOf();
  27948. }
  27949. $canonicalPackages[] = $package;
  27950. }
  27951. return $canonicalPackages;
  27952. }
  27953. }
  27954. <?php
  27955. namespace Composer\Repository;
  27956. use Composer\Package\PackageInterface;
  27957. use Composer\Installer\InstallationManager;
  27958. interface WritableRepositoryInterface extends RepositoryInterface
  27959. {
  27960. public function write($devMode, InstallationManager $installationManager);
  27961. public function addPackage(PackageInterface $package);
  27962. public function removePackage(PackageInterface $package);
  27963. public function getCanonicalPackages();
  27964. public function reload();
  27965. public function setDevPackageNames(array $devPackageNames);
  27966. public function getDevPackageNames();
  27967. }
  27968. <?php
  27969. namespace Composer\Script;
  27970. use Composer\Composer;
  27971. use Composer\IO\IOInterface;
  27972. use Composer\EventDispatcher\Event as BaseEvent;
  27973. class Event extends BaseEvent
  27974. {
  27975. private $composer;
  27976. private $io;
  27977. private $devMode;
  27978. private $originatingEvent;
  27979. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  27980. {
  27981. parent::__construct($name, $args, $flags);
  27982. $this->composer = $composer;
  27983. $this->io = $io;
  27984. $this->devMode = $devMode;
  27985. }
  27986. public function getComposer()
  27987. {
  27988. return $this->composer;
  27989. }
  27990. public function getIO()
  27991. {
  27992. return $this->io;
  27993. }
  27994. public function isDevMode()
  27995. {
  27996. return $this->devMode;
  27997. }
  27998. public function getOriginatingEvent()
  27999. {
  28000. return $this->originatingEvent;
  28001. }
  28002. public function setOriginatingEvent(BaseEvent $event)
  28003. {
  28004. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  28005. return $this;
  28006. }
  28007. private function calculateOriginatingEvent(BaseEvent $event)
  28008. {
  28009. if ($event instanceof Event && $event->getOriginatingEvent()) {
  28010. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  28011. }
  28012. return $event;
  28013. }
  28014. }
  28015. <?php
  28016. namespace Composer\Script;
  28017. class ScriptEvents
  28018. {
  28019. const PRE_INSTALL_CMD = 'pre-install-cmd';
  28020. const POST_INSTALL_CMD = 'post-install-cmd';
  28021. const PRE_UPDATE_CMD = 'pre-update-cmd';
  28022. const POST_UPDATE_CMD = 'post-update-cmd';
  28023. const PRE_STATUS_CMD = 'pre-status-cmd';
  28024. const POST_STATUS_CMD = 'post-status-cmd';
  28025. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  28026. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  28027. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  28028. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  28029. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  28030. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  28031. }
  28032. <?php
  28033. namespace Composer\SelfUpdate;
  28034. class Keys
  28035. {
  28036. public static function fingerprint($path)
  28037. {
  28038. $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path))));
  28039. return implode(' ', array(
  28040. substr($hash, 0, 8),
  28041. substr($hash, 8, 8),
  28042. substr($hash, 16, 8),
  28043. substr($hash, 24, 8),
  28044. '',
  28045. substr($hash, 32, 8),
  28046. substr($hash, 40, 8),
  28047. substr($hash, 48, 8),
  28048. substr($hash, 56, 8),
  28049. ));
  28050. }
  28051. }
  28052. <?php
  28053. namespace Composer\SelfUpdate;
  28054. use Composer\Util\HttpDownloader;
  28055. use Composer\Config;
  28056. use Composer\Json\JsonFile;
  28057. class Versions
  28058. {
  28059. public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
  28060. private $httpDownloader;
  28061. private $config;
  28062. private $channel;
  28063. private $versionsData;
  28064. public function __construct(Config $config, HttpDownloader $httpDownloader)
  28065. {
  28066. $this->httpDownloader = $httpDownloader;
  28067. $this->config = $config;
  28068. }
  28069. public function getChannel()
  28070. {
  28071. if ($this->channel) {
  28072. return $this->channel;
  28073. }
  28074. $channelFile = $this->config->get('home').'/update-channel';
  28075. if (file_exists($channelFile)) {
  28076. $channel = trim(file_get_contents($channelFile));
  28077. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  28078. return $this->channel = $channel;
  28079. }
  28080. }
  28081. return $this->channel = 'stable';
  28082. }
  28083. public function setChannel($channel)
  28084. {
  28085. if (!in_array($channel, self::$channels, true)) {
  28086. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  28087. }
  28088. $channelFile = $this->config->get('home').'/update-channel';
  28089. $this->channel = $channel;
  28090. file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
  28091. }
  28092. public function getLatest($channel = null)
  28093. {
  28094. $versions = $this->getVersionsData();
  28095. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  28096. if ($version['min-php'] <= PHP_VERSION_ID) {
  28097. return $version;
  28098. }
  28099. }
  28100. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  28101. }
  28102. private function getVersionsData()
  28103. {
  28104. if (!$this->versionsData) {
  28105. if ($this->config->get('disable-tls') === true) {
  28106. $protocol = 'http';
  28107. } else {
  28108. $protocol = 'https';
  28109. }
  28110. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  28111. }
  28112. return $this->versionsData;
  28113. }
  28114. }
  28115. <?php
  28116. namespace Composer\Util;
  28117. use Composer\Config;
  28118. use Composer\IO\IOInterface;
  28119. use Composer\Downloader\TransportException;
  28120. class AuthHelper
  28121. {
  28122. protected $io;
  28123. protected $config;
  28124. private $displayedOriginAuthentications = array();
  28125. public function __construct(IOInterface $io, Config $config)
  28126. {
  28127. $this->io = $io;
  28128. $this->config = $config;
  28129. }
  28130. public function storeAuth($origin, $storeAuth)
  28131. {
  28132. $store = false;
  28133. $configSource = $this->config->getAuthConfigSource();
  28134. if ($storeAuth === true) {
  28135. $store = $configSource;
  28136. } elseif ($storeAuth === 'prompt') {
  28137. $answer = $this->io->askAndValidate(
  28138. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  28139. function ($value) {
  28140. $input = strtolower(substr(trim($value), 0, 1));
  28141. if (in_array($input, array('y','n'))) {
  28142. return $input;
  28143. }
  28144. throw new \RuntimeException('Please answer (y)es or (n)o');
  28145. },
  28146. null,
  28147. 'y'
  28148. );
  28149. if ($answer === 'y') {
  28150. $store = $configSource;
  28151. }
  28152. }
  28153. if ($store) {
  28154. $store->addConfigSetting(
  28155. 'http-basic.'.$origin,
  28156. $this->io->getAuthentication($origin)
  28157. );
  28158. }
  28159. }
  28160. public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
  28161. {
  28162. $storeAuth = false;
  28163. if (in_array($origin, $this->config->get('github-domains'), true)) {
  28164. $gitHubUtil = new GitHub($this->io, $this->config, null);
  28165. $message = "\n";
  28166. $rateLimited = $gitHubUtil->isRateLimited($headers);
  28167. if ($rateLimited) {
  28168. $rateLimit = $gitHubUtil->getRateLimit($headers);
  28169. if ($this->io->hasAuthentication($origin)) {
  28170. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  28171. } else {
  28172. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  28173. }
  28174. $message = sprintf(
  28175. '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.',
  28176. $rateLimit['limit'],
  28177. $rateLimit['reset']
  28178. )."\n";
  28179. } else {
  28180. $message .= 'Could not fetch '.$url.', please ';
  28181. if ($this->io->hasAuthentication($origin)) {
  28182. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  28183. } else {
  28184. $message .= 'create a GitHub OAuth token to access private repos';
  28185. }
  28186. }
  28187. if (!$gitHubUtil->authorizeOAuth($origin)
  28188. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  28189. ) {
  28190. throw new TransportException('Could not authenticate against '.$origin, 401);
  28191. }
  28192. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  28193. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  28194. $gitLabUtil = new GitLab($this->io, $this->config, null);
  28195. if ($this->io->hasAuthentication($origin) && ($auth = $this->io->getAuthentication($origin)) && in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  28196. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28197. }
  28198. if (!$gitLabUtil->authorizeOAuth($origin)
  28199. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  28200. ) {
  28201. throw new TransportException('Could not authenticate against '.$origin, 401);
  28202. }
  28203. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  28204. $askForOAuthToken = true;
  28205. $origin = 'bitbucket.org';
  28206. if ($this->io->hasAuthentication($origin)) {
  28207. $auth = $this->io->getAuthentication($origin);
  28208. if ($auth['username'] !== 'x-token-auth') {
  28209. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  28210. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  28211. if (!empty($accessToken)) {
  28212. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  28213. $askForOAuthToken = false;
  28214. }
  28215. } else {
  28216. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28217. }
  28218. }
  28219. if ($askForOAuthToken) {
  28220. $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');
  28221. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  28222. if (! $bitBucketUtil->authorizeOAuth($origin)
  28223. && (! $this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  28224. ) {
  28225. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28226. }
  28227. }
  28228. } else {
  28229. if ($statusCode === 404) {
  28230. return;
  28231. }
  28232. if (!$this->io->isInteractive()) {
  28233. if ($statusCode === 401) {
  28234. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  28235. } elseif ($statusCode === 403) {
  28236. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  28237. } else {
  28238. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  28239. }
  28240. throw new TransportException($message, $statusCode);
  28241. }
  28242. if ($this->io->hasAuthentication($origin)) {
  28243. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28244. }
  28245. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  28246. $username = $this->io->ask(' Username: ');
  28247. $password = $this->io->askAndHideAnswer(' Password: ');
  28248. $this->io->setAuthentication($origin, $username, $password);
  28249. $storeAuth = $this->config->get('store-auths');
  28250. }
  28251. return array('retry' => true, 'storeAuth' => $storeAuth);
  28252. }
  28253. public function addAuthenticationHeader(array $headers, $origin, $url)
  28254. {
  28255. if ($this->io->hasAuthentication($origin)) {
  28256. $authenticationDisplayMessage = null;
  28257. $auth = $this->io->getAuthentication($origin);
  28258. if ($auth['password'] === 'bearer') {
  28259. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28260. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  28261. if (preg_match('{^https?://api\.github\.com/}', $url)) {
  28262. $headers[] = 'Authorization: token '.$auth['username'];
  28263. $authenticationDisplayMessage = 'Using GitHub token authentication';
  28264. }
  28265. } elseif (
  28266. in_array($origin, $this->config->get('gitlab-domains'), true)
  28267. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  28268. ) {
  28269. if ($auth['password'] === 'oauth2') {
  28270. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28271. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  28272. } elseif ($auth['password'] === 'private-token' || $auth['password'] === 'gitlab-ci-token') {
  28273. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  28274. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  28275. }
  28276. } elseif (
  28277. 'bitbucket.org' === $origin
  28278. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  28279. && 'x-token-auth' === $auth['username']
  28280. ) {
  28281. if (!$this->isPublicBitBucketDownload($url)) {
  28282. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  28283. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  28284. }
  28285. } else {
  28286. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  28287. $headers[] = 'Authorization: Basic '.$authStr;
  28288. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  28289. }
  28290. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  28291. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  28292. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  28293. }
  28294. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  28295. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  28296. }
  28297. return $headers;
  28298. }
  28299. public function isPublicBitBucketDownload($urlToBitBucketFile)
  28300. {
  28301. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  28302. if (strpos($domain, 'bitbucket.org') === false) {
  28303. return true;
  28304. }
  28305. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  28306. $pathParts = explode('/', $path);
  28307. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  28308. }
  28309. }
  28310. <?php
  28311. namespace Composer\Util;
  28312. use Composer\Factory;
  28313. use Composer\IO\IOInterface;
  28314. use Composer\Config;
  28315. use Composer\Downloader\TransportException;
  28316. class Bitbucket
  28317. {
  28318. private $io;
  28319. private $config;
  28320. private $process;
  28321. private $httpDownloader;
  28322. private $token = array();
  28323. private $time;
  28324. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  28325. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null)
  28326. {
  28327. $this->io = $io;
  28328. $this->config = $config;
  28329. $this->process = $process ?: new ProcessExecutor($io);
  28330. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  28331. $this->time = $time;
  28332. }
  28333. public function getToken()
  28334. {
  28335. if (!isset($this->token['access_token'])) {
  28336. return '';
  28337. }
  28338. return $this->token['access_token'];
  28339. }
  28340. public function authorizeOAuth($originUrl)
  28341. {
  28342. if ($originUrl !== 'bitbucket.org') {
  28343. return false;
  28344. }
  28345. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  28346. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  28347. return true;
  28348. }
  28349. return false;
  28350. }
  28351. private function requestAccessToken()
  28352. {
  28353. try {
  28354. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  28355. 'retry-auth-failure' => false,
  28356. 'http' => array(
  28357. 'method' => 'POST',
  28358. 'content' => 'grant_type=client_credentials',
  28359. ),
  28360. ));
  28361. $this->token = $response->decodeJson();
  28362. } catch (TransportException $e) {
  28363. if ($e->getCode() === 400) {
  28364. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28365. $this->io->writeError('This can have two reasons:');
  28366. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  28367. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  28368. return false;
  28369. }
  28370. if (in_array($e->getCode(), array(403, 401))) {
  28371. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28372. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28373. return false;
  28374. }
  28375. throw $e;
  28376. }
  28377. return true;
  28378. }
  28379. public function authorizeOAuthInteractively($originUrl, $message = null)
  28380. {
  28381. if ($message) {
  28382. $this->io->writeError($message);
  28383. }
  28384. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  28385. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  28386. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  28387. $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)');
  28388. $consumerKey = trim($this->io->askAndHideAnswer('Consumer Key (hidden): '));
  28389. if (!$consumerKey) {
  28390. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  28391. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28392. return false;
  28393. }
  28394. $consumerSecret = trim($this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  28395. if (!$consumerSecret) {
  28396. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  28397. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28398. return false;
  28399. }
  28400. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28401. if (!$this->requestAccessToken()) {
  28402. return false;
  28403. }
  28404. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28405. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  28406. $this->io->writeError('<info>Consumer stored successfully.</info>');
  28407. return true;
  28408. }
  28409. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  28410. {
  28411. if (!empty($this->token) || $this->getTokenFromConfig($originUrl)) {
  28412. return $this->token['access_token'];
  28413. }
  28414. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28415. if (!$this->requestAccessToken()) {
  28416. return '';
  28417. }
  28418. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28419. return $this->token['access_token'];
  28420. }
  28421. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  28422. {
  28423. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  28424. $time = null === $this->time ? time() : $this->time;
  28425. $consumer = array(
  28426. "consumer-key" => $consumerKey,
  28427. "consumer-secret" => $consumerSecret,
  28428. "access-token" => $this->token['access_token'],
  28429. "access-token-expiration" => $time + $this->token['expires_in'],
  28430. );
  28431. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  28432. }
  28433. private function getTokenFromConfig($originUrl)
  28434. {
  28435. $authConfig = $this->config->get('bitbucket-oauth');
  28436. if (
  28437. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  28438. || time() > $authConfig[$originUrl]['access-token-expiration']
  28439. ) {
  28440. return false;
  28441. }
  28442. $this->token = array(
  28443. 'access_token' => $authConfig[$originUrl]['access-token'],
  28444. );
  28445. return true;
  28446. }
  28447. }
  28448. <?php
  28449. namespace Composer\Util;
  28450. class ComposerMirror
  28451. {
  28452. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)
  28453. {
  28454. if ($reference) {
  28455. $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  28456. }
  28457. $version = strpos($version, '/') === false ? $version : md5($version);
  28458. return str_replace(
  28459. array('%package%', '%version%', '%reference%', '%type%'),
  28460. array($packageName, $version, $reference, $type),
  28461. $mirrorUrl
  28462. );
  28463. }
  28464. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  28465. {
  28466. if (preg_match('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  28467. $url = 'gh-'.$match[1].'/'.$match[2];
  28468. } elseif (preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  28469. $url = 'bb-'.$match[1].'/'.$match[2];
  28470. } else {
  28471. $url = preg_replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  28472. }
  28473. return str_replace(
  28474. array('%package%', '%normalizedUrl%', '%type%'),
  28475. array($packageName, $url, $type),
  28476. $mirrorUrl
  28477. );
  28478. }
  28479. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  28480. {
  28481. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  28482. }
  28483. }
  28484. <?php
  28485. namespace Composer\Util;
  28486. use Composer\Package\Loader\ArrayLoader;
  28487. use Composer\Package\Loader\ValidatingArrayLoader;
  28488. use Composer\Package\Loader\InvalidPackageException;
  28489. use Composer\Json\JsonValidationException;
  28490. use Composer\IO\IOInterface;
  28491. use Composer\Json\JsonFile;
  28492. use Composer\Spdx\SpdxLicenses;
  28493. class ConfigValidator
  28494. {
  28495. const CHECK_VERSION = 1;
  28496. private $io;
  28497. public function __construct(IOInterface $io)
  28498. {
  28499. $this->io = $io;
  28500. }
  28501. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
  28502. {
  28503. $errors = array();
  28504. $publishErrors = array();
  28505. $warnings = array();
  28506. $laxValid = false;
  28507. try {
  28508. $json = new JsonFile($file, null, $this->io);
  28509. $manifest = $json->read();
  28510. $json->validateSchema(JsonFile::LAX_SCHEMA);
  28511. $laxValid = true;
  28512. $json->validateSchema();
  28513. } catch (JsonValidationException $e) {
  28514. foreach ($e->getErrors() as $message) {
  28515. if ($laxValid) {
  28516. $publishErrors[] = $message;
  28517. } else {
  28518. $errors[] = $message;
  28519. }
  28520. }
  28521. } catch (\Exception $e) {
  28522. $errors[] = $e->getMessage();
  28523. return array($errors, $publishErrors, $warnings);
  28524. }
  28525. if (empty($manifest['license'])) {
  28526. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  28527. } else {
  28528. $licenses = (array) $manifest['license'];
  28529. foreach ($licenses as $key => $license) {
  28530. if ('proprietary' === $license) {
  28531. unset($licenses[$key]);
  28532. }
  28533. }
  28534. $licenseValidator = new SpdxLicenses();
  28535. foreach ($licenses as $license) {
  28536. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  28537. if ($spdxLicense && $spdxLicense[3]) {
  28538. if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  28539. $warnings[] = sprintf(
  28540. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  28541. $license
  28542. );
  28543. } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  28544. $warnings[] = sprintf(
  28545. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  28546. $license
  28547. );
  28548. } else {
  28549. $warnings[] = sprintf(
  28550. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  28551. $license
  28552. );
  28553. }
  28554. }
  28555. }
  28556. }
  28557. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  28558. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  28559. }
  28560. if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {
  28561. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  28562. $suggestName = strtolower($suggestName);
  28563. $publishErrors[] = sprintf(
  28564. '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.',
  28565. $manifest['name'],
  28566. $suggestName
  28567. );
  28568. }
  28569. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  28570. $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.";
  28571. }
  28572. if (isset($manifest['require'], $manifest['require-dev'])) {
  28573. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  28574. if (!empty($requireOverrides)) {
  28575. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  28576. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  28577. }
  28578. }
  28579. foreach (array('provide', 'replace') as $linkType) {
  28580. if (isset($manifest[$linkType])) {
  28581. foreach (array('require', 'require-dev') as $requireType) {
  28582. if (isset($manifest[$requireType])) {
  28583. foreach ($manifest[$linkType] as $provide => $constraint) {
  28584. if (isset($manifest[$requireType][$provide])) {
  28585. $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.';
  28586. }
  28587. }
  28588. }
  28589. }
  28590. }
  28591. }
  28592. $require = isset($manifest['require']) ? $manifest['require'] : array();
  28593. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  28594. $packages = array_merge($require, $requireDev);
  28595. foreach ($packages as $package => $version) {
  28596. if (preg_match('/#/', $version) === 1) {
  28597. $warnings[] = sprintf(
  28598. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  28599. $package
  28600. );
  28601. }
  28602. }
  28603. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  28604. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  28605. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  28606. if (!array_key_exists($scriptName, $scripts)) {
  28607. $warnings[] = sprintf(
  28608. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  28609. $scriptName
  28610. );
  28611. }
  28612. }
  28613. if (isset($manifest['autoload']['psr-0'][''])) {
  28614. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  28615. }
  28616. if (isset($manifest['autoload']['psr-4'][''])) {
  28617. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  28618. }
  28619. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  28620. try {
  28621. if (!isset($manifest['version'])) {
  28622. $manifest['version'] = '1.0.0';
  28623. }
  28624. if (!isset($manifest['name'])) {
  28625. $manifest['name'] = 'dummy/dummy';
  28626. }
  28627. $loader->load($manifest);
  28628. } catch (InvalidPackageException $e) {
  28629. $errors = array_merge($errors, $e->getErrors());
  28630. }
  28631. $warnings = array_merge($warnings, $loader->getWarnings());
  28632. return array($errors, $publishErrors, $warnings);
  28633. }
  28634. }
  28635. <?php
  28636. namespace Composer\Util;
  28637. use Composer\IO\IOInterface;
  28638. class ErrorHandler
  28639. {
  28640. private static $io;
  28641. public static function handle($level, $message, $file, $line)
  28642. {
  28643. if (!(error_reporting() & $level)) {
  28644. return;
  28645. }
  28646. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  28647. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  28648. "\na legitimately suppressed error that you were not supposed to see.";
  28649. }
  28650. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  28651. throw new \ErrorException($message, 0, $level, $file, $line);
  28652. }
  28653. if (self::$io) {
  28654. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  28655. if (self::$io->isVerbose()) {
  28656. self::$io->writeError('<warning>Stack trace:</warning>');
  28657. self::$io->writeError(array_filter(array_map(function ($a) {
  28658. if (isset($a['line'], $a['file'])) {
  28659. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  28660. }
  28661. return null;
  28662. }, array_slice(debug_backtrace(), 2))));
  28663. }
  28664. }
  28665. return true;
  28666. }
  28667. public static function register(IOInterface $io = null)
  28668. {
  28669. set_error_handler(array(__CLASS__, 'handle'));
  28670. error_reporting(E_ALL | E_STRICT);
  28671. self::$io = $io;
  28672. }
  28673. }
  28674. <?php
  28675. namespace Composer\Util;
  28676. use RecursiveDirectoryIterator;
  28677. use RecursiveIteratorIterator;
  28678. use Symfony\Component\Filesystem\Exception\IOException;
  28679. use Symfony\Component\Finder\Finder;
  28680. class Filesystem
  28681. {
  28682. private $processExecutor;
  28683. public function __construct(ProcessExecutor $executor = null)
  28684. {
  28685. $this->processExecutor = $executor;
  28686. }
  28687. public function remove($file)
  28688. {
  28689. if (is_dir($file)) {
  28690. return $this->removeDirectory($file);
  28691. }
  28692. if (file_exists($file)) {
  28693. return $this->unlink($file);
  28694. }
  28695. return false;
  28696. }
  28697. public function isDirEmpty($dir)
  28698. {
  28699. $finder = Finder::create()
  28700. ->ignoreVCS(false)
  28701. ->ignoreDotFiles(false)
  28702. ->depth(0)
  28703. ->in($dir);
  28704. return \count($finder) === 0;
  28705. }
  28706. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  28707. {
  28708. if (file_exists($dir) && is_link($dir)) {
  28709. $this->unlink($dir);
  28710. }
  28711. if ($ensureDirectoryExists) {
  28712. $this->ensureDirectoryExists($dir);
  28713. }
  28714. if (is_dir($dir)) {
  28715. $finder = Finder::create()
  28716. ->ignoreVCS(false)
  28717. ->ignoreDotFiles(false)
  28718. ->depth(0)
  28719. ->in($dir);
  28720. foreach ($finder as $path) {
  28721. $this->remove((string) $path);
  28722. }
  28723. }
  28724. }
  28725. public function removeDirectory($directory)
  28726. {
  28727. if ($this->isSymlinkedDirectory($directory)) {
  28728. return $this->unlinkSymlinkedDirectory($directory);
  28729. }
  28730. if ($this->isJunction($directory)) {
  28731. return $this->removeJunction($directory);
  28732. }
  28733. if (is_link($directory)) {
  28734. return unlink($directory);
  28735. }
  28736. if (!file_exists($directory) || !is_dir($directory)) {
  28737. return true;
  28738. }
  28739. if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  28740. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  28741. }
  28742. if (!\function_exists('proc_open')) {
  28743. return $this->removeDirectoryPhp($directory);
  28744. }
  28745. if (Platform::isWindows()) {
  28746. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  28747. } else {
  28748. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  28749. }
  28750. $result = $this->getProcess()->execute($cmd, $output) === 0;
  28751. clearstatcache();
  28752. if ($result && !file_exists($directory)) {
  28753. return true;
  28754. }
  28755. return $this->removeDirectoryPhp($directory);
  28756. }
  28757. public function removeDirectoryPhp($directory)
  28758. {
  28759. try {
  28760. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  28761. } catch (\UnexpectedValueException $e) {
  28762. clearstatcache();
  28763. usleep(100000);
  28764. if (!is_dir($directory)) {
  28765. return true;
  28766. }
  28767. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  28768. }
  28769. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  28770. foreach ($ri as $file) {
  28771. if ($file->isDir()) {
  28772. $this->rmdir($file->getPathname());
  28773. } else {
  28774. $this->unlink($file->getPathname());
  28775. }
  28776. }
  28777. return $this->rmdir($directory);
  28778. }
  28779. public function ensureDirectoryExists($directory)
  28780. {
  28781. if (!is_dir($directory)) {
  28782. if (file_exists($directory)) {
  28783. throw new \RuntimeException(
  28784. $directory.' exists and is not a directory.'
  28785. );
  28786. }
  28787. if (!@mkdir($directory, 0777, true)) {
  28788. throw new \RuntimeException(
  28789. $directory.' does not exist and could not be created.'
  28790. );
  28791. }
  28792. }
  28793. }
  28794. public function unlink($path)
  28795. {
  28796. $unlinked = @$this->unlinkImplementation($path);
  28797. if (!$unlinked) {
  28798. if (Platform::isWindows()) {
  28799. usleep(350000);
  28800. $unlinked = @$this->unlinkImplementation($path);
  28801. }
  28802. if (!$unlinked) {
  28803. $error = error_get_last();
  28804. $message = 'Could not delete '.$path.': ' . @$error['message'];
  28805. if (Platform::isWindows()) {
  28806. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  28807. }
  28808. throw new \RuntimeException($message);
  28809. }
  28810. }
  28811. return true;
  28812. }
  28813. public function rmdir($path)
  28814. {
  28815. $deleted = @rmdir($path);
  28816. if (!$deleted) {
  28817. if (Platform::isWindows()) {
  28818. usleep(350000);
  28819. $deleted = @rmdir($path);
  28820. }
  28821. if (!$deleted) {
  28822. $error = error_get_last();
  28823. $message = 'Could not delete '.$path.': ' . @$error['message'];
  28824. if (Platform::isWindows()) {
  28825. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  28826. }
  28827. throw new \RuntimeException($message);
  28828. }
  28829. }
  28830. return true;
  28831. }
  28832. public function copyThenRemove($source, $target)
  28833. {
  28834. $this->copy($source, $target);
  28835. if (!is_dir($source)) {
  28836. $this->unlink($source);
  28837. return;
  28838. }
  28839. $this->removeDirectoryPhp($source);
  28840. }
  28841. public function copy($source, $target)
  28842. {
  28843. if (!is_dir($source)) {
  28844. return copy($source, $target);
  28845. }
  28846. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  28847. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  28848. $this->ensureDirectoryExists($target);
  28849. $result = true;
  28850. foreach ($ri as $file) {
  28851. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  28852. if ($file->isDir()) {
  28853. $this->ensureDirectoryExists($targetPath);
  28854. } else {
  28855. $result = $result && copy($file->getPathname(), $targetPath);
  28856. }
  28857. }
  28858. return $result;
  28859. }
  28860. public function rename($source, $target)
  28861. {
  28862. if (true === @rename($source, $target)) {
  28863. return;
  28864. }
  28865. if (!\function_exists('proc_open')) {
  28866. $this->copyThenRemove($source, $target);
  28867. return;
  28868. }
  28869. if (Platform::isWindows()) {
  28870. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  28871. $result = $this->getProcess()->execute($command, $output);
  28872. clearstatcache();
  28873. if (0 === $result) {
  28874. $this->remove($source);
  28875. return;
  28876. }
  28877. } else {
  28878. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  28879. $result = $this->getProcess()->execute($command, $output);
  28880. clearstatcache();
  28881. if (0 === $result) {
  28882. return;
  28883. }
  28884. }
  28885. $this->copyThenRemove($source, $target);
  28886. }
  28887. public function findShortestPath($from, $to, $directories = false)
  28888. {
  28889. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  28890. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  28891. }
  28892. $from = lcfirst($this->normalizePath($from));
  28893. $to = lcfirst($this->normalizePath($to));
  28894. if ($directories) {
  28895. $from = rtrim($from, '/') . '/dummy_file';
  28896. }
  28897. if (\dirname($from) === \dirname($to)) {
  28898. return './'.basename($to);
  28899. }
  28900. $commonPath = $to;
  28901. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
  28902. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  28903. }
  28904. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  28905. return $to;
  28906. }
  28907. $commonPath = rtrim($commonPath, '/') . '/';
  28908. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
  28909. $commonPathCode = str_repeat('../', $sourcePathDepth);
  28910. return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
  28911. }
  28912. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  28913. {
  28914. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  28915. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  28916. }
  28917. $from = lcfirst($this->normalizePath($from));
  28918. $to = lcfirst($this->normalizePath($to));
  28919. if ($from === $to) {
  28920. return $directories ? '__DIR__' : '__FILE__';
  28921. }
  28922. $commonPath = $to;
  28923. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  28924. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  28925. }
  28926. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  28927. return var_export($to, true);
  28928. }
  28929. $commonPath = rtrim($commonPath, '/') . '/';
  28930. if (strpos($to, $from.'/') === 0) {
  28931. return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
  28932. }
  28933. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
  28934. if ($staticCode) {
  28935. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  28936. } else {
  28937. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  28938. }
  28939. $relTarget = substr($to, \strlen($commonPath));
  28940. return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  28941. }
  28942. public function isAbsolutePath($path)
  28943. {
  28944. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  28945. }
  28946. public function size($path)
  28947. {
  28948. if (!file_exists($path)) {
  28949. throw new \RuntimeException("$path does not exist.");
  28950. }
  28951. if (is_dir($path)) {
  28952. return $this->directorySize($path);
  28953. }
  28954. return filesize($path);
  28955. }
  28956. public function normalizePath($path)
  28957. {
  28958. $parts = array();
  28959. $path = strtr($path, '\\', '/');
  28960. $prefix = '';
  28961. $absolute = false;
  28962. if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  28963. $prefix = $match[1];
  28964. $path = substr($path, \strlen($prefix));
  28965. }
  28966. if (strpos($path, '/') === 0) {
  28967. $absolute = true;
  28968. $path = substr($path, 1);
  28969. }
  28970. $up = false;
  28971. foreach (explode('/', $path) as $chunk) {
  28972. if ('..' === $chunk && ($absolute || $up)) {
  28973. array_pop($parts);
  28974. $up = !(empty($parts) || '..' === end($parts));
  28975. } elseif ('.' !== $chunk && '' !== $chunk) {
  28976. $parts[] = $chunk;
  28977. $up = '..' !== $chunk;
  28978. }
  28979. }
  28980. return $prefix.($absolute ? '/' : '').implode('/', $parts);
  28981. }
  28982. public static function trimTrailingSlash($path)
  28983. {
  28984. if (!preg_match('{^[/\\\\]+$}', $path)) {
  28985. $path = rtrim($path, '/\\');
  28986. }
  28987. return $path;
  28988. }
  28989. public static function isLocalPath($path)
  28990. {
  28991. return (bool) preg_match('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  28992. }
  28993. public static function getPlatformPath($path)
  28994. {
  28995. if (Platform::isWindows()) {
  28996. $path = preg_replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  28997. }
  28998. return preg_replace('{^file://}i', '', $path);
  28999. }
  29000. protected function directorySize($directory)
  29001. {
  29002. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29003. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  29004. $size = 0;
  29005. foreach ($ri as $file) {
  29006. if ($file->isFile()) {
  29007. $size += $file->getSize();
  29008. }
  29009. }
  29010. return $size;
  29011. }
  29012. protected function getProcess()
  29013. {
  29014. if (!$this->processExecutor) {
  29015. $this->processExecutor = new ProcessExecutor();
  29016. }
  29017. return $this->processExecutor;
  29018. }
  29019. private function unlinkImplementation($path)
  29020. {
  29021. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  29022. return rmdir($path);
  29023. }
  29024. return unlink($path);
  29025. }
  29026. public function relativeSymlink($target, $link)
  29027. {
  29028. $cwd = getcwd();
  29029. $relativePath = $this->findShortestPath($link, $target);
  29030. chdir(\dirname($link));
  29031. $result = @symlink($relativePath, $link);
  29032. chdir($cwd);
  29033. return $result;
  29034. }
  29035. public function isSymlinkedDirectory($directory)
  29036. {
  29037. if (!is_dir($directory)) {
  29038. return false;
  29039. }
  29040. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29041. return is_link($resolved);
  29042. }
  29043. private function unlinkSymlinkedDirectory($directory)
  29044. {
  29045. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29046. return $this->unlink($resolved);
  29047. }
  29048. private function resolveSymlinkedDirectorySymlink($pathname)
  29049. {
  29050. if (!is_dir($pathname)) {
  29051. return $pathname;
  29052. }
  29053. $resolved = rtrim($pathname, '/');
  29054. if (!\strlen($resolved)) {
  29055. return $pathname;
  29056. }
  29057. return $resolved;
  29058. }
  29059. public function junction($target, $junction)
  29060. {
  29061. if (!Platform::isWindows()) {
  29062. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  29063. }
  29064. if (!is_dir($target)) {
  29065. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  29066. }
  29067. $cmd = sprintf(
  29068. 'mklink /J %s %s',
  29069. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  29070. ProcessExecutor::escape(realpath($target))
  29071. );
  29072. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  29073. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  29074. }
  29075. clearstatcache(true, $junction);
  29076. }
  29077. public function isJunction($junction)
  29078. {
  29079. if (!Platform::isWindows()) {
  29080. return false;
  29081. }
  29082. clearstatcache(true, $junction);
  29083. if (!is_dir($junction) || is_link($junction)) {
  29084. return false;
  29085. }
  29086. $stat = lstat($junction);
  29087. return $stat ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  29088. }
  29089. public function removeJunction($junction)
  29090. {
  29091. if (!Platform::isWindows()) {
  29092. return false;
  29093. }
  29094. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  29095. if (!$this->isJunction($junction)) {
  29096. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  29097. }
  29098. return $this->rmdir($junction);
  29099. }
  29100. public function filePutContentsIfModified($path, $content)
  29101. {
  29102. $currentContent = @file_get_contents($path);
  29103. if (!$currentContent || ($currentContent != $content)) {
  29104. return file_put_contents($path, $content);
  29105. }
  29106. return 0;
  29107. }
  29108. public function safeCopy($source, $target)
  29109. {
  29110. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  29111. $source = fopen($source, 'r');
  29112. $target = fopen($target, 'w+');
  29113. stream_copy_to_stream($source, $target);
  29114. fclose($source);
  29115. fclose($target);
  29116. }
  29117. }
  29118. private function filesAreEqual($a, $b)
  29119. {
  29120. if (filesize($a) !== filesize($b)) {
  29121. return false;
  29122. }
  29123. $ah = fopen($a, 'rb');
  29124. $bh = fopen($b, 'rb');
  29125. $result = true;
  29126. while (!feof($ah)) {
  29127. if (fread($ah, 8192) != fread($bh, 8192)) {
  29128. $result = false;
  29129. break;
  29130. }
  29131. }
  29132. fclose($ah);
  29133. fclose($bh);
  29134. return $result;
  29135. }
  29136. }
  29137. <?php
  29138. namespace Composer\Util;
  29139. use Composer\Config;
  29140. use Composer\IO\IOInterface;
  29141. class Git
  29142. {
  29143. private static $version = false;
  29144. protected $io;
  29145. protected $config;
  29146. protected $process;
  29147. protected $filesystem;
  29148. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  29149. {
  29150. $this->io = $io;
  29151. $this->config = $config;
  29152. $this->process = $process;
  29153. $this->filesystem = $fs;
  29154. }
  29155. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  29156. {
  29157. $this->config->prohibitUrlByConfig($url, $this->io);
  29158. if ($initialClone) {
  29159. $origCwd = $cwd;
  29160. $cwd = null;
  29161. }
  29162. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  29163. 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.');
  29164. }
  29165. if (!$initialClone) {
  29166. $this->process->execute('git remote -v', $output, $cwd);
  29167. if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  29168. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  29169. }
  29170. }
  29171. $protocols = $this->config->get('github-protocols');
  29172. if (!is_array($protocols)) {
  29173. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  29174. }
  29175. if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  29176. $messages = array();
  29177. foreach ($protocols as $protocol) {
  29178. if ('ssh' === $protocol) {
  29179. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  29180. } else {
  29181. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  29182. }
  29183. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  29184. return;
  29185. }
  29186. $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
  29187. if ($initialClone && isset($origCwd)) {
  29188. $this->filesystem->removeDirectory($origCwd);
  29189. }
  29190. }
  29191. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  29192. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  29193. }
  29194. }
  29195. $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  29196. $command = call_user_func($commandCallable, $url);
  29197. $auth = null;
  29198. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  29199. $errorMsg = $this->process->getErrorOutput();
  29200. if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  29201. || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)
  29202. ) {
  29203. if (!$this->io->hasAuthentication($match[1])) {
  29204. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  29205. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  29206. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29207. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  29208. }
  29209. }
  29210. if ($this->io->hasAuthentication($match[1])) {
  29211. $auth = $this->io->getAuthentication($match[1]);
  29212. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29213. $command = call_user_func($commandCallable, $authUrl);
  29214. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29215. return;
  29216. }
  29217. $errorMsg = $this->process->getErrorOutput();
  29218. }
  29219. } elseif (preg_match('{^https://(bitbucket\.org)/(.*)(\.git)?$}U', $url, $match)) {
  29220. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  29221. if (!$this->io->hasAuthentication($match[1])) {
  29222. $message = 'Enter your Bitbucket credentials to access private repos';
  29223. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29224. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  29225. $accessToken = $bitbucketUtil->getToken();
  29226. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29227. }
  29228. } else {
  29229. $auth = $this->io->getAuthentication($match[1]);
  29230. if ($auth['username'] !== 'x-token-auth') {
  29231. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  29232. if (! empty($accessToken)) {
  29233. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29234. }
  29235. }
  29236. }
  29237. if ($this->io->hasAuthentication($match[1])) {
  29238. $auth = $this->io->getAuthentication($match[1]);
  29239. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29240. $command = call_user_func($commandCallable, $authUrl);
  29241. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29242. return;
  29243. }
  29244. $errorMsg = $this->process->getErrorOutput();
  29245. } else {
  29246. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  29247. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  29248. $command = call_user_func($commandCallable, $sshUrl);
  29249. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29250. return;
  29251. }
  29252. $errorMsg = $this->process->getErrorOutput();
  29253. }
  29254. } elseif (
  29255. preg_match('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  29256. || preg_match('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}', $url, $match)
  29257. ) {
  29258. if ($match[1] === 'git') {
  29259. $match[1] = 'https';
  29260. }
  29261. if (!$this->io->hasAuthentication($match[2])) {
  29262. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  29263. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  29264. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  29265. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  29266. }
  29267. }
  29268. if ($this->io->hasAuthentication($match[2])) {
  29269. $auth = $this->io->getAuthentication($match[2]);
  29270. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  29271. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  29272. } else {
  29273. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  29274. }
  29275. $command = call_user_func($commandCallable, $authUrl);
  29276. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29277. return;
  29278. }
  29279. $errorMsg = $this->process->getErrorOutput();
  29280. }
  29281. } elseif ($this->isAuthenticationFailure($url, $match)) {
  29282. if (strpos($match[2], '@')) {
  29283. list($authParts, $match[2]) = explode('@', $match[2], 2);
  29284. }
  29285. $storeAuth = false;
  29286. if ($this->io->hasAuthentication($match[2])) {
  29287. $auth = $this->io->getAuthentication($match[2]);
  29288. } elseif ($this->io->isInteractive()) {
  29289. $defaultUsername = null;
  29290. if (isset($authParts) && $authParts) {
  29291. if (false !== strpos($authParts, ':')) {
  29292. list($defaultUsername, ) = explode(':', $authParts, 2);
  29293. } else {
  29294. $defaultUsername = $authParts;
  29295. }
  29296. }
  29297. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  29298. $auth = array(
  29299. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  29300. 'password' => $this->io->askAndHideAnswer(' Password: '),
  29301. );
  29302. $storeAuth = $this->config->get('store-auths');
  29303. }
  29304. if ($auth) {
  29305. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  29306. $command = call_user_func($commandCallable, $authUrl);
  29307. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29308. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  29309. $authHelper = new AuthHelper($this->io, $this->config);
  29310. $authHelper->storeAuth($match[2], $storeAuth);
  29311. return;
  29312. }
  29313. $errorMsg = $this->process->getErrorOutput();
  29314. }
  29315. }
  29316. if ($initialClone && isset($origCwd)) {
  29317. $this->filesystem->removeDirectory($origCwd);
  29318. }
  29319. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  29320. }
  29321. }
  29322. public function syncMirror($url, $dir)
  29323. {
  29324. if (getenv('COMPOSER_DISABLE_NETWORK') && getenv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  29325. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  29326. return false;
  29327. }
  29328. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29329. try {
  29330. $commandCallable = function ($url) {
  29331. $sanitizedUrl = preg_replace('{://([^@]+?):(.+?)@}', '://', $url);
  29332. return sprintf('git remote set-url origin %s && git remote update --prune origin && git remote set-url origin %s', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  29333. };
  29334. $this->runCommand($commandCallable, $url, $dir);
  29335. } catch (\Exception $e) {
  29336. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  29337. return false;
  29338. }
  29339. return true;
  29340. }
  29341. $this->filesystem->removeDirectory($dir);
  29342. $commandCallable = function ($url) use ($dir) {
  29343. return sprintf('git clone --mirror %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  29344. };
  29345. $this->runCommand($commandCallable, $url, $dir, true);
  29346. return true;
  29347. }
  29348. public function fetchRefOrSyncMirror($url, $dir, $ref)
  29349. {
  29350. if ($this->checkRefIsInMirror($dir, $ref)) {
  29351. return true;
  29352. }
  29353. if ($this->syncMirror($url, $dir)) {
  29354. return $this->checkRefIsInMirror($dir, $ref);
  29355. }
  29356. return false;
  29357. }
  29358. public static function getNoShowSignatureFlag(ProcessExecutor $process)
  29359. {
  29360. $gitVersion = self::getVersion($process);
  29361. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  29362. return ' --no-show-signature';
  29363. }
  29364. return '';
  29365. }
  29366. private function checkRefIsInMirror($dir, $ref)
  29367. {
  29368. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29369. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  29370. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  29371. if ($exitCode === 0) {
  29372. return true;
  29373. }
  29374. }
  29375. return false;
  29376. }
  29377. private function isAuthenticationFailure($url, &$match)
  29378. {
  29379. if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  29380. return false;
  29381. }
  29382. $authFailures = array(
  29383. 'fatal: Authentication failed',
  29384. 'remote error: Invalid username or password.',
  29385. 'error: 401 Unauthorized',
  29386. 'fatal: unable to access',
  29387. 'fatal: could not read Username',
  29388. );
  29389. $errorOutput = $this->process->getErrorOutput();
  29390. foreach ($authFailures as $authFailure) {
  29391. if (strpos($errorOutput, $authFailure) !== false) {
  29392. return true;
  29393. }
  29394. }
  29395. return false;
  29396. }
  29397. public static function cleanEnv()
  29398. {
  29399. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  29400. 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');
  29401. }
  29402. if (getenv('GIT_ASKPASS') !== 'echo') {
  29403. putenv('GIT_ASKPASS=echo');
  29404. unset($_SERVER['GIT_ASKPASS']);
  29405. }
  29406. if (getenv('GIT_DIR')) {
  29407. putenv('GIT_DIR');
  29408. unset($_SERVER['GIT_DIR']);
  29409. }
  29410. if (getenv('GIT_WORK_TREE')) {
  29411. putenv('GIT_WORK_TREE');
  29412. unset($_SERVER['GIT_WORK_TREE']);
  29413. }
  29414. if (getenv('LANGUAGE') !== 'C') {
  29415. putenv('LANGUAGE=C');
  29416. }
  29417. putenv("DYLD_LIBRARY_PATH");
  29418. unset($_SERVER['DYLD_LIBRARY_PATH']);
  29419. }
  29420. public static function getGitHubDomainsRegex(Config $config)
  29421. {
  29422. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  29423. }
  29424. public static function getGitLabDomainsRegex(Config $config)
  29425. {
  29426. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  29427. }
  29428. private function throwException($message, $url)
  29429. {
  29430. clearstatcache();
  29431. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  29432. 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()));
  29433. }
  29434. throw new \RuntimeException(Url::sanitize($message));
  29435. }
  29436. public static function getVersion(ProcessExecutor $process)
  29437. {
  29438. if (false === self::$version) {
  29439. self::$version = null;
  29440. if (!$process) {
  29441. $process = new ProcessExecutor;
  29442. }
  29443. if (0 === $process->execute('git --version', $output) && preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  29444. self::$version = $matches[1];
  29445. }
  29446. }
  29447. return self::$version;
  29448. }
  29449. }
  29450. <?php
  29451. namespace Composer\Util;
  29452. use Composer\Factory;
  29453. use Composer\IO\IOInterface;
  29454. use Composer\Config;
  29455. use Composer\Downloader\TransportException;
  29456. class GitHub
  29457. {
  29458. protected $io;
  29459. protected $config;
  29460. protected $process;
  29461. protected $httpDownloader;
  29462. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29463. {
  29464. $this->io = $io;
  29465. $this->config = $config;
  29466. $this->process = $process ?: new ProcessExecutor($io);
  29467. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29468. }
  29469. public function authorizeOAuth($originUrl)
  29470. {
  29471. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  29472. return false;
  29473. }
  29474. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  29475. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  29476. return true;
  29477. }
  29478. return false;
  29479. }
  29480. public function authorizeOAuthInteractively($originUrl, $message = null)
  29481. {
  29482. if ($message) {
  29483. $this->io->writeError($message);
  29484. }
  29485. $note = 'Composer';
  29486. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  29487. $note .= ' on ' . trim($output);
  29488. }
  29489. $note .= ' ' . date('Y-m-d Hi');
  29490. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  29491. $this->io->writeError(sprintf('Head to %s', $url));
  29492. $this->io->writeError(sprintf('to retrieve a token. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  29493. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  29494. if (!$token) {
  29495. $this->io->writeError('<warning>No token given, aborting.</warning>');
  29496. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29497. return false;
  29498. }
  29499. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  29500. try {
  29501. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  29502. $this->httpDownloader->get('https://'. $apiUrl, array(
  29503. 'retry-auth-failure' => false,
  29504. ));
  29505. } catch (TransportException $e) {
  29506. if (in_array($e->getCode(), array(403, 401))) {
  29507. $this->io->writeError('<error>Invalid token provided.</error>');
  29508. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29509. return false;
  29510. }
  29511. throw $e;
  29512. }
  29513. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  29514. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  29515. $this->io->writeError('<info>Token stored successfully.</info>');
  29516. return true;
  29517. }
  29518. public function getRateLimit(array $headers)
  29519. {
  29520. $rateLimit = array(
  29521. 'limit' => '?',
  29522. 'reset' => '?',
  29523. );
  29524. foreach ($headers as $header) {
  29525. $header = trim($header);
  29526. if (false === strpos($header, 'X-RateLimit-')) {
  29527. continue;
  29528. }
  29529. list($type, $value) = explode(':', $header, 2);
  29530. switch ($type) {
  29531. case 'X-RateLimit-Limit':
  29532. $rateLimit['limit'] = (int) trim($value);
  29533. break;
  29534. case 'X-RateLimit-Reset':
  29535. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  29536. break;
  29537. }
  29538. }
  29539. return $rateLimit;
  29540. }
  29541. public function isRateLimited(array $headers)
  29542. {
  29543. foreach ($headers as $header) {
  29544. if (preg_match('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  29545. return true;
  29546. }
  29547. }
  29548. return false;
  29549. }
  29550. }
  29551. <?php
  29552. namespace Composer\Util;
  29553. use Composer\IO\IOInterface;
  29554. use Composer\Config;
  29555. use Composer\Factory;
  29556. use Composer\Downloader\TransportException;
  29557. use Composer\Json\JsonFile;
  29558. class GitLab
  29559. {
  29560. protected $io;
  29561. protected $config;
  29562. protected $process;
  29563. protected $httpDownloader;
  29564. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29565. {
  29566. $this->io = $io;
  29567. $this->config = $config;
  29568. $this->process = $process ?: new ProcessExecutor($io);
  29569. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29570. }
  29571. public function authorizeOAuth($originUrl)
  29572. {
  29573. $bcOriginUrl = preg_replace('{:\d+}', '', $originUrl);
  29574. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  29575. return false;
  29576. }
  29577. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  29578. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  29579. return true;
  29580. }
  29581. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  29582. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  29583. return true;
  29584. }
  29585. $authTokens = $this->config->get('gitlab-token');
  29586. if (isset($authTokens[$originUrl])) {
  29587. $token = $authTokens[$originUrl];
  29588. }
  29589. if (isset($authTokens[$bcOriginUrl])) {
  29590. $token = $authTokens[$bcOriginUrl];
  29591. }
  29592. if(isset($token)){
  29593. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  29594. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  29595. $this->io->setAuthentication($originUrl, $username, $password);
  29596. return true;
  29597. }
  29598. return false;
  29599. }
  29600. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  29601. {
  29602. if ($message) {
  29603. $this->io->writeError($message);
  29604. }
  29605. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  29606. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/profile/applications');
  29607. $attemptCounter = 0;
  29608. while ($attemptCounter++ < 5) {
  29609. try {
  29610. $response = $this->createToken($scheme, $originUrl);
  29611. } catch (TransportException $e) {
  29612. if (in_array($e->getCode(), array(403, 401))) {
  29613. if (401 === $e->getCode()) {
  29614. $response = json_decode($e->getResponse(), true);
  29615. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  29616. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  29617. } else {
  29618. $this->io->writeError('Bad credentials.');
  29619. }
  29620. } else {
  29621. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  29622. }
  29623. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  29624. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  29625. continue;
  29626. }
  29627. throw $e;
  29628. }
  29629. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  29630. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  29631. return true;
  29632. }
  29633. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  29634. }
  29635. private function createToken($scheme, $originUrl)
  29636. {
  29637. $username = $this->io->ask('Username: ');
  29638. $password = $this->io->askAndHideAnswer('Password: ');
  29639. $headers = array('Content-Type: application/x-www-form-urlencoded');
  29640. $apiUrl = $originUrl;
  29641. $data = http_build_query(array(
  29642. 'username' => $username,
  29643. 'password' => $password,
  29644. 'grant_type' => 'password',
  29645. ), null, '&');
  29646. $options = array(
  29647. 'retry-auth-failure' => false,
  29648. 'http' => array(
  29649. 'method' => 'POST',
  29650. 'header' => $headers,
  29651. 'content' => $data,
  29652. ),
  29653. );
  29654. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  29655. $this->io->writeError('Token successfully created');
  29656. return $token;
  29657. }
  29658. }
  29659. <?php
  29660. namespace Composer\Util;
  29661. use Composer\Config;
  29662. use Composer\IO\IOInterface;
  29663. class Hg
  29664. {
  29665. private $io;
  29666. private $config;
  29667. private $process;
  29668. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  29669. {
  29670. $this->io = $io;
  29671. $this->config = $config;
  29672. $this->process = $process;
  29673. }
  29674. public function runCommand($commandCallable, $url, $cwd)
  29675. {
  29676. $this->config->prohibitUrlByConfig($url, $this->io);
  29677. $command = call_user_func($commandCallable, $url);
  29678. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29679. return;
  29680. }
  29681. if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  29682. $auth = $this->io->getAuthentication($match[5]);
  29683. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  29684. $command = call_user_func($commandCallable, $authenticatedUrl);
  29685. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29686. return;
  29687. }
  29688. $error = $this->process->getErrorOutput();
  29689. } else {
  29690. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  29691. }
  29692. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  29693. }
  29694. private function throwException($message, $url)
  29695. {
  29696. if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
  29697. 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()));
  29698. }
  29699. throw new \RuntimeException(Url::sanitize($message));
  29700. }
  29701. }
  29702. <?php
  29703. namespace Composer\Util\Http;
  29704. use Composer\Config;
  29705. use Composer\Downloader\MaxFileSizeExceededException;
  29706. use Composer\IO\IOInterface;
  29707. use Composer\Downloader\TransportException;
  29708. use Composer\CaBundle\CaBundle;
  29709. use Composer\Util\StreamContextFactory;
  29710. use Composer\Util\AuthHelper;
  29711. use Composer\Util\Url;
  29712. use Composer\Util\HttpDownloader;
  29713. use React\Promise\Promise;
  29714. class CurlDownloader
  29715. {
  29716. private $multiHandle;
  29717. private $shareHandle;
  29718. private $jobs = array();
  29719. private $io;
  29720. private $config;
  29721. private $authHelper;
  29722. private $selectTimeout = 5.0;
  29723. private $maxRedirects = 20;
  29724. private $proxyManager;
  29725. private $supportsSecureProxy;
  29726. protected $multiErrors = array(
  29727. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  29728. 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."),
  29729. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  29730. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!')
  29731. );
  29732. private static $options = array(
  29733. 'http' => array(
  29734. 'method' => CURLOPT_CUSTOMREQUEST,
  29735. 'content' => CURLOPT_POSTFIELDS,
  29736. 'header' => CURLOPT_HTTPHEADER,
  29737. 'timeout' => CURLOPT_TIMEOUT,
  29738. ),
  29739. 'ssl' => array(
  29740. 'cafile' => CURLOPT_CAINFO,
  29741. 'capath' => CURLOPT_CAPATH,
  29742. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  29743. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  29744. 'local_cert' => CURLOPT_SSLCERT,
  29745. 'local_pk' => CURLOPT_SSLKEY,
  29746. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  29747. ),
  29748. );
  29749. private static $timeInfo = array(
  29750. 'total_time' => true,
  29751. 'namelookup_time' => true,
  29752. 'connect_time' => true,
  29753. 'pretransfer_time' => true,
  29754. 'starttransfer_time' => true,
  29755. 'redirect_time' => true,
  29756. );
  29757. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  29758. {
  29759. $this->io = $io;
  29760. $this->config = $config;
  29761. $this->multiHandle = $mh = curl_multi_init();
  29762. if (function_exists('curl_multi_setopt')) {
  29763. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  29764. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  29765. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  29766. }
  29767. }
  29768. if (function_exists('curl_share_init')) {
  29769. $this->shareHandle = $sh = curl_share_init();
  29770. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  29771. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  29772. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  29773. }
  29774. $this->authHelper = new AuthHelper($io, $config);
  29775. $this->proxyManager = ProxyManager::getInstance();
  29776. $version = curl_version();
  29777. $features = $version['features'];
  29778. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  29779. }
  29780. public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
  29781. {
  29782. $attributes = array();
  29783. if (isset($options['retry-auth-failure'])) {
  29784. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  29785. unset($options['retry-auth-failure']);
  29786. }
  29787. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  29788. }
  29789. private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
  29790. {
  29791. $attributes = array_merge(array(
  29792. 'retryAuthFailure' => true,
  29793. 'redirects' => 0,
  29794. 'storeAuth' => false,
  29795. ), $attributes);
  29796. $originalOptions = $options;
  29797. if (!preg_match('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  29798. $this->config->prohibitUrlByConfig($url, $this->io);
  29799. }
  29800. $curlHandle = curl_init();
  29801. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  29802. if ($copyTo) {
  29803. $errorMessage = '';
  29804. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  29805. if ($errorMessage) {
  29806. $errorMessage .= "\n";
  29807. }
  29808. $errorMessage .= preg_replace('{^fopen\(.*?\): }', '', $msg);
  29809. });
  29810. $bodyHandle = fopen($copyTo.'~', 'w+b');
  29811. restore_error_handler();
  29812. if (!$bodyHandle) {
  29813. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  29814. }
  29815. } else {
  29816. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  29817. }
  29818. curl_setopt($curlHandle, CURLOPT_URL, $url);
  29819. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  29820. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  29821. curl_setopt($curlHandle, CURLOPT_TIMEOUT, 300);
  29822. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  29823. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  29824. curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip");
  29825. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS);
  29826. if (function_exists('curl_share_init')) {
  29827. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  29828. }
  29829. if (!isset($options['http']['header'])) {
  29830. $options['http']['header'] = array();
  29831. }
  29832. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  29833. $options['http']['header'][] = 'Connection: keep-alive';
  29834. $version = curl_version();
  29835. $features = $version['features'];
  29836. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  29837. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  29838. }
  29839. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  29840. $options = StreamContextFactory::initOptions($url, $options, true);
  29841. foreach (self::$options as $type => $curlOptions) {
  29842. foreach ($curlOptions as $name => $curlOption) {
  29843. if (isset($options[$type][$name])) {
  29844. if ($type === 'ssl' && $name === 'verify_peer_name') {
  29845. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  29846. } else {
  29847. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  29848. }
  29849. }
  29850. }
  29851. }
  29852. $proxy = $this->proxyManager->getProxyForRequest($url);
  29853. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  29854. if ($proxy->isSecure()) {
  29855. if (!$this->supportsSecureProxy) {
  29856. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  29857. }
  29858. if (!empty($options['ssl']['cafile'])) {
  29859. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  29860. }
  29861. if (!empty($options['ssl']['capath'])) {
  29862. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  29863. }
  29864. }
  29865. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  29866. $this->jobs[(int) $curlHandle] = array(
  29867. 'url' => $url,
  29868. 'origin' => $origin,
  29869. 'attributes' => $attributes,
  29870. 'options' => $originalOptions,
  29871. 'progress' => $progress,
  29872. 'curlHandle' => $curlHandle,
  29873. 'filename' => $copyTo,
  29874. 'headerHandle' => $headerHandle,
  29875. 'bodyHandle' => $bodyHandle,
  29876. 'resolve' => $resolve,
  29877. 'reject' => $reject,
  29878. );
  29879. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  29880. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  29881. if ($attributes['redirects'] === 0) {
  29882. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  29883. }
  29884. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  29885. return (int) $curlHandle;
  29886. }
  29887. public function abortRequest($id)
  29888. {
  29889. if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) {
  29890. $job = $this->jobs[$id];
  29891. curl_multi_remove_handle($this->multiHandle, $job['handle']);
  29892. curl_close($job['handle']);
  29893. if (is_resource($job['headerHandle'])) {
  29894. fclose($job['headerHandle']);
  29895. }
  29896. if (is_resource($job['bodyHandle'])) {
  29897. fclose($job['bodyHandle']);
  29898. }
  29899. if ($job['filename']) {
  29900. @unlink($job['filename'].'~');
  29901. }
  29902. unset($this->jobs[$id]);
  29903. }
  29904. }
  29905. public function tick()
  29906. {
  29907. if (!$this->jobs) {
  29908. return;
  29909. }
  29910. $active = true;
  29911. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  29912. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  29913. usleep(150);
  29914. }
  29915. while ($progress = curl_multi_info_read($this->multiHandle)) {
  29916. $curlHandle = $progress['handle'];
  29917. $i = (int) $curlHandle;
  29918. if (!isset($this->jobs[$i])) {
  29919. continue;
  29920. }
  29921. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  29922. $job = $this->jobs[$i];
  29923. unset($this->jobs[$i]);
  29924. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  29925. $error = curl_error($curlHandle);
  29926. $errno = curl_errno($curlHandle);
  29927. curl_close($curlHandle);
  29928. $headers = null;
  29929. $statusCode = null;
  29930. $response = null;
  29931. try {
  29932. if (CURLE_OK !== $errno || $error) {
  29933. throw new TransportException($error);
  29934. }
  29935. $statusCode = $progress['http_code'];
  29936. rewind($job['headerHandle']);
  29937. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  29938. fclose($job['headerHandle']);
  29939. if ($job['filename']) {
  29940. $contents = $job['filename'].'~';
  29941. if ($statusCode >= 300) {
  29942. rewind($job['bodyHandle']);
  29943. $contents = stream_get_contents($job['bodyHandle']);
  29944. }
  29945. $response = new Response(array('url' => $progress['url']), $statusCode, $headers, $contents);
  29946. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  29947. } else {
  29948. rewind($job['bodyHandle']);
  29949. $contents = stream_get_contents($job['bodyHandle']);
  29950. $response = new Response(array('url' => $progress['url']), $statusCode, $headers, $contents);
  29951. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  29952. }
  29953. fclose($job['bodyHandle']);
  29954. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  29955. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  29956. }
  29957. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  29958. if ($result['retry']) {
  29959. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  29960. continue;
  29961. }
  29962. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  29963. $location = $this->handleRedirect($job, $response);
  29964. if ($location) {
  29965. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  29966. continue;
  29967. }
  29968. }
  29969. if ($statusCode >= 400 && $statusCode <= 599) {
  29970. throw $this->failResponse($job, $response, $response->getStatusMessage());
  29971. }
  29972. if ($job['attributes']['storeAuth']) {
  29973. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  29974. }
  29975. if ($job['filename']) {
  29976. rename($job['filename'].'~', $job['filename']);
  29977. call_user_func($job['resolve'], $response);
  29978. } else {
  29979. call_user_func($job['resolve'], $response);
  29980. }
  29981. } catch (\Exception $e) {
  29982. if ($e instanceof TransportException && $headers) {
  29983. $e->setHeaders($headers);
  29984. $e->setStatusCode($statusCode);
  29985. }
  29986. if ($e instanceof TransportException && $response) {
  29987. $e->setResponse($response->getBody());
  29988. }
  29989. if (is_resource($job['headerHandle'])) {
  29990. fclose($job['headerHandle']);
  29991. }
  29992. if (is_resource($job['bodyHandle'])) {
  29993. fclose($job['bodyHandle']);
  29994. }
  29995. if ($job['filename']) {
  29996. @unlink($job['filename'].'~');
  29997. }
  29998. call_user_func($job['reject'], $e);
  29999. }
  30000. }
  30001. foreach ($this->jobs as $i => $curlHandle) {
  30002. if (!isset($this->jobs[$i])) {
  30003. continue;
  30004. }
  30005. $curlHandle = $this->jobs[$i]['curlHandle'];
  30006. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  30007. if ($this->jobs[$i]['progress'] !== $progress) {
  30008. $this->jobs[$i]['progress'] = $progress;
  30009. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  30010. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  30011. throw 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');
  30012. }
  30013. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  30014. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes');
  30015. }
  30016. }
  30017. }
  30018. }
  30019. }
  30020. private function handleRedirect(array $job, Response $response)
  30021. {
  30022. if ($locationHeader = $response->getHeader('location')) {
  30023. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  30024. $targetUrl = $locationHeader;
  30025. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  30026. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  30027. } elseif ('/' === $locationHeader[0]) {
  30028. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  30029. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  30030. } else {
  30031. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  30032. }
  30033. }
  30034. if (!empty($targetUrl)) {
  30035. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  30036. return $targetUrl;
  30037. }
  30038. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  30039. }
  30040. private function isAuthenticatedRetryNeeded(array $job, Response $response)
  30041. {
  30042. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  30043. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  30044. if ($result['retry']) {
  30045. return $result;
  30046. }
  30047. }
  30048. $locationHeader = $response->getHeader('location');
  30049. $needsAuthRetry = false;
  30050. if (
  30051. $job['origin'] === 'bitbucket.org'
  30052. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  30053. && substr($job['url'], -4) === '.zip'
  30054. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  30055. && preg_match('{^text/html\b}i', $response->getHeader('content-type'))
  30056. ) {
  30057. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  30058. }
  30059. if (
  30060. $response->getStatusCode() === 404
  30061. && $this->config && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  30062. && false !== strpos($job['url'], 'archive.zip')
  30063. ) {
  30064. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  30065. }
  30066. if ($needsAuthRetry) {
  30067. if ($job['attributes']['retryAuthFailure']) {
  30068. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  30069. if ($result['retry']) {
  30070. return $result;
  30071. }
  30072. }
  30073. throw $this->failResponse($job, $response, $needsAuthRetry);
  30074. }
  30075. return array('retry' => false, 'storeAuth' => false);
  30076. }
  30077. private function restartJob(array $job, $url, array $attributes = array())
  30078. {
  30079. if ($job['filename']) {
  30080. @unlink($job['filename'].'~');
  30081. }
  30082. $attributes = array_merge($job['attributes'], $attributes);
  30083. $origin = Url::getOrigin($this->config, $url);
  30084. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  30085. }
  30086. private function failResponse(array $job, Response $response, $errorMessage)
  30087. {
  30088. if ($job['filename']) {
  30089. @unlink($job['filename'].'~');
  30090. }
  30091. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')', $response->getStatusCode());
  30092. }
  30093. private function checkCurlResult($code)
  30094. {
  30095. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  30096. throw new \RuntimeException(isset($this->multiErrors[$code])
  30097. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  30098. : 'Unexpected cURL error: ' . $code
  30099. );
  30100. }
  30101. }
  30102. }
  30103. <?php
  30104. namespace Composer\Util\Http;
  30105. class ProxyHelper
  30106. {
  30107. public static function getProxyData()
  30108. {
  30109. $httpProxy = null;
  30110. $httpsProxy = null;
  30111. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  30112. if ($env = self::getProxyEnv(array('http_proxy', 'HTTP_PROXY'), $name)) {
  30113. $httpProxy = self::checkProxy($env, $name);
  30114. }
  30115. }
  30116. if ($env = self::getProxyEnv(array('CGI_HTTP_PROXY'), $name)) {
  30117. $httpProxy = self::checkProxy($env, $name);
  30118. }
  30119. if ($env = self::getProxyEnv(array('https_proxy', 'HTTPS_PROXY'), $name)) {
  30120. $httpsProxy = self::checkProxy($env, $name);
  30121. } else {
  30122. $httpsProxy = $httpProxy;
  30123. }
  30124. $noProxy = self::getProxyEnv(array('no_proxy', 'NO_PROXY'), $name);
  30125. return array($httpProxy, $httpsProxy, $noProxy);
  30126. }
  30127. public static function getContextOptions($proxyUrl)
  30128. {
  30129. $proxy = parse_url($proxyUrl);
  30130. $proxyUrl = self::formatParsedUrl($proxy, false);
  30131. $proxyUrl = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyUrl);
  30132. $options['http']['proxy'] = $proxyUrl;
  30133. if (isset($proxy['user'])) {
  30134. $auth = rawurldecode($proxy['user']);
  30135. if (isset($proxy['pass'])) {
  30136. $auth .= ':' . rawurldecode($proxy['pass']);
  30137. }
  30138. $auth = base64_encode($auth);
  30139. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  30140. }
  30141. return $options;
  30142. }
  30143. public static function setRequestFullUri($requestUrl, array &$options)
  30144. {
  30145. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  30146. $options['http']['request_fulluri'] = true;
  30147. } else {
  30148. unset($options['http']['request_fulluri']);
  30149. }
  30150. }
  30151. private static function getProxyEnv(array $names, &$name)
  30152. {
  30153. foreach ($names as $name) {
  30154. if (!empty($_SERVER[$name])) {
  30155. return $_SERVER[$name];
  30156. }
  30157. }
  30158. }
  30159. private static function checkProxy($proxyUrl, $envName)
  30160. {
  30161. $error = sprintf('malformed %s url', $envName);
  30162. $proxy = parse_url($proxyUrl);
  30163. if (!isset($proxy['host'])) {
  30164. throw new \RuntimeException($error);
  30165. }
  30166. $proxyUrl = self::formatParsedUrl($proxy, true);
  30167. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  30168. throw new \RuntimeException($error);
  30169. }
  30170. return $proxyUrl;
  30171. }
  30172. private static function formatParsedUrl(array $proxy, $includeAuth)
  30173. {
  30174. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  30175. if ($includeAuth && isset($proxy['user'])) {
  30176. $proxyUrl .= $proxy['user'];
  30177. if (isset($proxy['pass'])) {
  30178. $proxyUrl .= ':' . $proxy['pass'];
  30179. }
  30180. $proxyUrl .= '@';
  30181. }
  30182. $proxyUrl .= $proxy['host'];
  30183. if (isset($proxy['port'])) {
  30184. $proxyUrl .= ':' . $proxy['port'];
  30185. } elseif (strpos($proxyUrl, 'http://') === 0) {
  30186. $proxyUrl .= ':80';
  30187. } elseif (strpos($proxyUrl, 'https://') === 0) {
  30188. $proxyUrl .= ':443';
  30189. }
  30190. return $proxyUrl;
  30191. }
  30192. }
  30193. <?php
  30194. namespace Composer\Util\Http;
  30195. use Composer\Downloader\TransportException;
  30196. use Composer\Util\NoProxyPattern;
  30197. use Composer\Util\Url;
  30198. class ProxyManager
  30199. {
  30200. private $error;
  30201. private $fullProxy;
  30202. private $safeProxy;
  30203. private $streams;
  30204. private $hasProxy;
  30205. private $info;
  30206. private $lastProxy;
  30207. private $noProxyHandler;
  30208. private static $instance;
  30209. private function __construct()
  30210. {
  30211. $this->fullProxy = $this->safeProxy = array(
  30212. 'http' => null,
  30213. 'https' => null,
  30214. );
  30215. $this->streams['http'] = $this->streams['https'] = array(
  30216. 'options' => null,
  30217. );
  30218. $this->hasProxy = false;
  30219. $this->initProxyData();
  30220. }
  30221. public static function getInstance()
  30222. {
  30223. if (!self::$instance) {
  30224. self::$instance = new self();
  30225. }
  30226. return self::$instance;
  30227. }
  30228. public static function reset()
  30229. {
  30230. self::$instance = null;
  30231. }
  30232. public function getProxyForRequest($requestUrl)
  30233. {
  30234. if ($this->error) {
  30235. throw new TransportException('Unable to use a proxy: '.$this->error);
  30236. }
  30237. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  30238. $proxyUrl = '';
  30239. $options = array();
  30240. $formattedProxyUrl = '';
  30241. if ($this->hasProxy && $this->fullProxy[$scheme]) {
  30242. if ($this->noProxy($requestUrl)) {
  30243. $formattedProxyUrl = 'excluded by no_proxy';
  30244. } else {
  30245. $proxyUrl = $this->fullProxy[$scheme];
  30246. $options = $this->streams[$scheme]['options'];
  30247. ProxyHelper::setRequestFullUri($requestUrl, $options);
  30248. $formattedProxyUrl = $this->safeProxy[$scheme];
  30249. }
  30250. }
  30251. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  30252. }
  30253. public function isProxying()
  30254. {
  30255. return $this->hasProxy;
  30256. }
  30257. public function getFormattedProxy()
  30258. {
  30259. return $this->hasProxy ? $this->info : $this->error;
  30260. }
  30261. private function initProxyData()
  30262. {
  30263. try {
  30264. list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
  30265. } catch (\RuntimeException $e) {
  30266. $this->error = $e->getMessage();
  30267. return;
  30268. }
  30269. $info = array();
  30270. if ($httpProxy) {
  30271. $info[] = $this->setData($httpProxy, 'http');
  30272. }
  30273. if ($httpsProxy) {
  30274. $info[] = $this->setData($httpsProxy, 'https');
  30275. }
  30276. if ($this->hasProxy) {
  30277. $this->info = implode(', ', $info);
  30278. if ($noProxy) {
  30279. $this->noProxyHandler = array(new NoProxyPattern($noProxy), 'test');
  30280. }
  30281. }
  30282. }
  30283. private function setData($url, $scheme)
  30284. {
  30285. $safeProxy = Url::sanitize($url);
  30286. $this->fullProxy[$scheme] = $url;
  30287. $this->safeProxy[$scheme] = $safeProxy;
  30288. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  30289. $this->hasProxy = true;
  30290. return sprintf('%s=%s', $scheme, $safeProxy);
  30291. }
  30292. private function noProxy($requestUrl)
  30293. {
  30294. if ($this->noProxyHandler) {
  30295. if (call_user_func($this->noProxyHandler, $requestUrl)) {
  30296. $this->lastProxy = 'excluded by no_proxy';
  30297. return true;
  30298. }
  30299. }
  30300. return false;
  30301. }
  30302. }
  30303. <?php
  30304. namespace Composer\Util\Http;
  30305. use Composer\Util\Url;
  30306. class RequestProxy
  30307. {
  30308. private $contextOptions;
  30309. private $isSecure;
  30310. private $formattedUrl;
  30311. private $url;
  30312. public function __construct($url, array $contextOptions, $formattedUrl)
  30313. {
  30314. $this->url = $url;
  30315. $this->contextOptions = $contextOptions;
  30316. $this->formattedUrl = $formattedUrl;
  30317. $this->isSecure = 0 === strpos($url, 'https://');
  30318. }
  30319. public function getContextOptions()
  30320. {
  30321. return $this->contextOptions;
  30322. }
  30323. public function getFormattedUrl($format = '')
  30324. {
  30325. $result = '';
  30326. if ($this->formattedUrl) {
  30327. $format = $format ?: '%s';
  30328. $result = sprintf($format, $this->formattedUrl);
  30329. }
  30330. return $result;
  30331. }
  30332. public function getUrl()
  30333. {
  30334. return $this->url;
  30335. }
  30336. public function isSecure()
  30337. {
  30338. return $this->isSecure;
  30339. }
  30340. }
  30341. <?php
  30342. namespace Composer\Util\Http;
  30343. use Composer\Json\JsonFile;
  30344. class Response
  30345. {
  30346. private $request;
  30347. private $code;
  30348. private $headers;
  30349. private $body;
  30350. public function __construct(array $request, $code, array $headers, $body)
  30351. {
  30352. if (!isset($request['url'])) {
  30353. throw new \LogicException('url key missing from request array');
  30354. }
  30355. $this->request = $request;
  30356. $this->code = (int) $code;
  30357. $this->headers = $headers;
  30358. $this->body = $body;
  30359. }
  30360. public function getStatusCode()
  30361. {
  30362. return $this->code;
  30363. }
  30364. public function getStatusMessage()
  30365. {
  30366. $value = null;
  30367. foreach ($this->headers as $header) {
  30368. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  30369. $value = $header;
  30370. }
  30371. }
  30372. return $value;
  30373. }
  30374. public function getHeaders()
  30375. {
  30376. return $this->headers;
  30377. }
  30378. public function getHeader($name)
  30379. {
  30380. return self::findHeaderValue($this->headers, $name);
  30381. }
  30382. public function getBody()
  30383. {
  30384. return $this->body;
  30385. }
  30386. public function decodeJson()
  30387. {
  30388. return JsonFile::parseJson($this->body, $this->request['url']);
  30389. }
  30390. public function collect()
  30391. {
  30392. $this->request = $this->code = $this->headers = $this->body = null;
  30393. }
  30394. public static function findHeaderValue(array $headers, $name)
  30395. {
  30396. $value = null;
  30397. foreach ($headers as $header) {
  30398. if (preg_match('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  30399. $value = $match[1];
  30400. }
  30401. }
  30402. return $value;
  30403. }
  30404. }
  30405. <?php
  30406. namespace Composer\Util;
  30407. use Composer\Config;
  30408. use Composer\IO\IOInterface;
  30409. use Composer\Downloader\TransportException;
  30410. use Composer\CaBundle\CaBundle;
  30411. use Composer\Util\Http\Response;
  30412. use Composer\Composer;
  30413. use Composer\Package\Version\VersionParser;
  30414. use Composer\Semver\Constraint\Constraint;
  30415. use React\Promise\Promise;
  30416. class HttpDownloader
  30417. {
  30418. const STATUS_QUEUED = 1;
  30419. const STATUS_STARTED = 2;
  30420. const STATUS_COMPLETED = 3;
  30421. const STATUS_FAILED = 4;
  30422. const STATUS_ABORTED = 5;
  30423. private $io;
  30424. private $config;
  30425. private $jobs = array();
  30426. private $options = array();
  30427. private $runningJobs = 0;
  30428. private $maxJobs = 10;
  30429. private $curl;
  30430. private $rfs;
  30431. private $idGen = 0;
  30432. private $disabled;
  30433. private $allowAsync = false;
  30434. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  30435. {
  30436. $this->io = $io;
  30437. $this->disabled = (bool) getenv('COMPOSER_DISABLE_NETWORK');
  30438. if ($disableTls === false) {
  30439. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  30440. }
  30441. $this->options = array_replace_recursive($this->options, $options);
  30442. $this->config = $config;
  30443. if (self::isCurlEnabled()) {
  30444. $this->curl = new Http\CurlDownloader($io, $config, $options, $disableTls);
  30445. }
  30446. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  30447. }
  30448. public function get($url, $options = array())
  30449. {
  30450. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30451. $this->wait($job['id']);
  30452. $response = $this->getResponse($job['id']);
  30453. if (
  30454. $this->curl
  30455. && PHP_VERSION_ID < 70000
  30456. && $response->getBody() === null
  30457. && $response->getStatusCode() === 200
  30458. && $response->getHeader('content-length') !== '0'
  30459. ) {
  30460. $this->io->writeError('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
  30461. $this->curl = null;
  30462. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30463. $this->wait($job['id']);
  30464. $response = $this->getResponse($job['id']);
  30465. }
  30466. return $response;
  30467. }
  30468. public function add($url, $options = array())
  30469. {
  30470. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false));
  30471. return $promise;
  30472. }
  30473. public function copy($url, $to, $options = array())
  30474. {
  30475. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  30476. $this->wait($job['id']);
  30477. return $this->getResponse($job['id']);
  30478. }
  30479. public function addCopy($url, $to, $options = array())
  30480. {
  30481. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  30482. return $promise;
  30483. }
  30484. public function getOptions()
  30485. {
  30486. return $this->options;
  30487. }
  30488. public function setOptions(array $options)
  30489. {
  30490. $this->options = array_replace_recursive($this->options, $options);
  30491. }
  30492. private function addJob($request, $sync = false)
  30493. {
  30494. $request['options'] = array_replace_recursive($this->options, $request['options']);
  30495. $job = array(
  30496. 'id' => $this->idGen++,
  30497. 'status' => self::STATUS_QUEUED,
  30498. 'request' => $request,
  30499. 'sync' => $sync,
  30500. 'origin' => Url::getOrigin($this->config, $request['url']),
  30501. );
  30502. if (!$sync && !$this->allowAsync) {
  30503. 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');
  30504. }
  30505. if (preg_match('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  30506. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  30507. }
  30508. $rfs = $this->rfs;
  30509. if ($this->canUseCurl($job)) {
  30510. $resolver = function ($resolve, $reject) use (&$job) {
  30511. $job['status'] = HttpDownloader::STATUS_QUEUED;
  30512. $job['resolve'] = $resolve;
  30513. $job['reject'] = $reject;
  30514. };
  30515. } else {
  30516. $resolver = function ($resolve, $reject) use (&$job, $rfs) {
  30517. $url = $job['request']['url'];
  30518. $options = $job['request']['options'];
  30519. $job['status'] = HttpDownloader::STATUS_STARTED;
  30520. if ($job['request']['copyTo']) {
  30521. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  30522. $headers = $rfs->getLastHeaders();
  30523. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  30524. $resolve($response);
  30525. } else {
  30526. $body = $rfs->getContents($job['origin'], $url, false , $options);
  30527. $headers = $rfs->getLastHeaders();
  30528. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  30529. $resolve($response);
  30530. }
  30531. };
  30532. }
  30533. $downloader = $this;
  30534. $curl = $this->curl;
  30535. $canceler = function () use (&$job, $curl) {
  30536. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  30537. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30538. }
  30539. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  30540. return;
  30541. }
  30542. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30543. if (isset($job['curl_id'])) {
  30544. $curl->abortRequest($job['curl_id']);
  30545. }
  30546. };
  30547. $promise = new Promise($resolver, $canceler);
  30548. $promise->then(function ($response) use (&$job, $downloader) {
  30549. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  30550. $job['response'] = $response;
  30551. $downloader->markJobDone();
  30552. return $response;
  30553. }, function ($e) use (&$job, $downloader) {
  30554. $job['status'] = HttpDownloader::STATUS_FAILED;
  30555. $job['exception'] = $e;
  30556. $downloader->markJobDone();
  30557. throw $e;
  30558. });
  30559. $this->jobs[$job['id']] =& $job;
  30560. if ($this->runningJobs < $this->maxJobs) {
  30561. $this->startJob($job['id']);
  30562. }
  30563. return array($job, $promise);
  30564. }
  30565. private function startJob($id)
  30566. {
  30567. $job =& $this->jobs[$id];
  30568. if ($job['status'] !== self::STATUS_QUEUED) {
  30569. return;
  30570. }
  30571. $job['status'] = self::STATUS_STARTED;
  30572. $this->runningJobs++;
  30573. $resolve = $job['resolve'];
  30574. $reject = $job['reject'];
  30575. $url = $job['request']['url'];
  30576. $options = $job['request']['options'];
  30577. $origin = $job['origin'];
  30578. if ($this->disabled) {
  30579. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  30580. $resolve(new Response(array('url' => $url), 304, array(), ''));
  30581. } else {
  30582. $e = new TransportException('Network disabled, request canceled: '.$url, 499);
  30583. $e->setStatusCode(499);
  30584. $reject($e);
  30585. }
  30586. return;
  30587. }
  30588. try {
  30589. if ($job['request']['copyTo']) {
  30590. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  30591. } else {
  30592. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  30593. }
  30594. } catch (\Exception $exception) {
  30595. $reject($exception);
  30596. }
  30597. }
  30598. public function markJobDone()
  30599. {
  30600. $this->runningJobs--;
  30601. }
  30602. public function wait($index = null)
  30603. {
  30604. while (true) {
  30605. if (!$this->countActiveJobs($index)) {
  30606. return;
  30607. }
  30608. usleep(1000);
  30609. }
  30610. }
  30611. public function enableAsync()
  30612. {
  30613. $this->allowAsync = true;
  30614. }
  30615. public function countActiveJobs($index = null)
  30616. {
  30617. if ($this->runningJobs < $this->maxJobs) {
  30618. foreach ($this->jobs as $job) {
  30619. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  30620. $this->startJob($job['id']);
  30621. }
  30622. }
  30623. }
  30624. if ($this->curl) {
  30625. $this->curl->tick();
  30626. }
  30627. if (null !== $index) {
  30628. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  30629. }
  30630. $active = 0;
  30631. foreach ($this->jobs as $job) {
  30632. if ($job['status'] < self::STATUS_COMPLETED) {
  30633. $active++;
  30634. } elseif (!$job['sync']) {
  30635. unset($this->jobs[$job['id']]);
  30636. }
  30637. }
  30638. return $active;
  30639. }
  30640. private function getResponse($index)
  30641. {
  30642. if (!isset($this->jobs[$index])) {
  30643. throw new \LogicException('Invalid request id');
  30644. }
  30645. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  30646. throw $this->jobs[$index]['exception'];
  30647. }
  30648. if (!isset($this->jobs[$index]['response'])) {
  30649. throw new \LogicException('Response not available yet, call wait() first');
  30650. }
  30651. $resp = $this->jobs[$index]['response'];
  30652. unset($this->jobs[$index]);
  30653. return $resp;
  30654. }
  30655. public static function outputWarnings(IOInterface $io, $url, $data)
  30656. {
  30657. foreach (array('warning', 'info') as $type) {
  30658. if (empty($data[$type])) {
  30659. continue;
  30660. }
  30661. if (!empty($data[$type . '-versions'])) {
  30662. $versionParser = new VersionParser();
  30663. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  30664. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  30665. if (!$constraint->matches($composer)) {
  30666. continue;
  30667. }
  30668. }
  30669. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.$url.': '.$data[$type].'</'.$type.'>');
  30670. }
  30671. }
  30672. public static function getExceptionHints(\Exception $e)
  30673. {
  30674. if (!$e instanceof TransportException) {
  30675. return;
  30676. }
  30677. if (
  30678. false !== strpos($e->getMessage(), 'Resolving timed out')
  30679. || false !== strpos($e->getMessage(), 'Could not resolve host')
  30680. ) {
  30681. Silencer::suppress();
  30682. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
  30683. 'ssl' => array('verify_peer' => false),
  30684. 'http' => array('follow_location' => false, 'ignore_errors' => true)
  30685. )));
  30686. Silencer::restore();
  30687. if (false !== $testConnectivity) {
  30688. return array(
  30689. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>'
  30690. );
  30691. }
  30692. return array(
  30693. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>'
  30694. );
  30695. }
  30696. }
  30697. private function canUseCurl(array $job)
  30698. {
  30699. if (!$this->curl) {
  30700. return false;
  30701. }
  30702. if (!preg_match('{^https?://}i', $job['request']['url'])) {
  30703. return false;
  30704. }
  30705. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  30706. return false;
  30707. }
  30708. return true;
  30709. }
  30710. public static function isCurlEnabled()
  30711. {
  30712. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  30713. }
  30714. }
  30715. <?php
  30716. namespace Composer\Util;
  30717. use Composer\XdebugHandler\XdebugHandler;
  30718. class IniHelper
  30719. {
  30720. public static function getAll()
  30721. {
  30722. return XdebugHandler::getAllIniFiles();
  30723. }
  30724. public static function getMessage()
  30725. {
  30726. $paths = self::getAll();
  30727. if (empty($paths[0])) {
  30728. array_shift($paths);
  30729. }
  30730. $ini = array_shift($paths);
  30731. if (empty($ini)) {
  30732. return 'A php.ini file does not exist. You will have to create one.';
  30733. }
  30734. if (!empty($paths)) {
  30735. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  30736. }
  30737. return 'The php.ini used by your command-line PHP is: '.$ini;
  30738. }
  30739. }
  30740. <?php
  30741. namespace Composer\Util;
  30742. use Composer\Util\HttpDownloader;
  30743. use React\Promise\Promise;
  30744. use Symfony\Component\Console\Helper\ProgressBar;
  30745. class Loop
  30746. {
  30747. private $httpDownloader;
  30748. private $processExecutor;
  30749. private $currentPromises = array();
  30750. private $waitIndex = 0;
  30751. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  30752. {
  30753. $this->httpDownloader = $httpDownloader;
  30754. $this->httpDownloader->enableAsync();
  30755. $this->processExecutor = $processExecutor;
  30756. if ($this->processExecutor) {
  30757. $this->processExecutor->enableAsync();
  30758. }
  30759. }
  30760. public function getHttpDownloader()
  30761. {
  30762. return $this->httpDownloader;
  30763. }
  30764. public function getProcessExecutor()
  30765. {
  30766. return $this->processExecutor;
  30767. }
  30768. public function wait(array $promises, ProgressBar $progress = null)
  30769. {
  30770. $uncaught = null;
  30771. \React\Promise\all($promises)->then(
  30772. function () { },
  30773. function ($e) use (&$uncaught) {
  30774. $uncaught = $e;
  30775. }
  30776. );
  30777. $waitIndex = $this->waitIndex++;
  30778. $this->currentPromises[$waitIndex] = $promises;
  30779. if ($progress) {
  30780. $totalJobs = 0;
  30781. if ($this->httpDownloader) {
  30782. $totalJobs += $this->httpDownloader->countActiveJobs();
  30783. }
  30784. if ($this->processExecutor) {
  30785. $totalJobs += $this->processExecutor->countActiveJobs();
  30786. }
  30787. $progress->start($totalJobs);
  30788. }
  30789. while (true) {
  30790. $activeJobs = 0;
  30791. if ($this->httpDownloader) {
  30792. $activeJobs += $this->httpDownloader->countActiveJobs();
  30793. }
  30794. if ($this->processExecutor) {
  30795. $activeJobs += $this->processExecutor->countActiveJobs();
  30796. }
  30797. if ($progress) {
  30798. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  30799. }
  30800. if (!$activeJobs) {
  30801. break;
  30802. }
  30803. usleep(5000);
  30804. }
  30805. unset($this->currentPromises[$waitIndex]);
  30806. if ($uncaught) {
  30807. throw $uncaught;
  30808. }
  30809. }
  30810. public function abortJobs()
  30811. {
  30812. foreach ($this->currentPromises as $promiseGroup) {
  30813. foreach ($promiseGroup as $promise) {
  30814. $promise->cancel();
  30815. }
  30816. }
  30817. }
  30818. }
  30819. <?php
  30820. namespace Composer\Util;
  30821. class MetadataMinifier
  30822. {
  30823. public static function expand(array $versions)
  30824. {
  30825. $expanded = array();
  30826. $expandedVersion = null;
  30827. foreach ($versions as $versionData) {
  30828. if (!$expandedVersion) {
  30829. $expandedVersion = $versionData;
  30830. $expanded[] = $expandedVersion;
  30831. continue;
  30832. }
  30833. foreach ($versionData as $key => $val) {
  30834. if ($val === '__unset') {
  30835. unset($expandedVersion[$key]);
  30836. } else {
  30837. $expandedVersion[$key] = $val;
  30838. }
  30839. }
  30840. $expanded[] = $expandedVersion;
  30841. }
  30842. return $expanded;
  30843. }
  30844. public static function minify(array $versions)
  30845. {
  30846. $minifiedVersions = array();
  30847. $lastKnownVersionData = null;
  30848. foreach ($versions as $version) {
  30849. if (!$lastKnownVersionData) {
  30850. $lastKnownVersionData = $version;
  30851. $minifiedVersions[] = $version;
  30852. continue;
  30853. }
  30854. $minifiedVersion = array();
  30855. foreach ($version as $key => $val) {
  30856. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  30857. $minifiedVersion[$key] = $val;
  30858. $lastKnownVersionData[$key] = $val;
  30859. }
  30860. }
  30861. foreach ($lastKnownVersionData as $key => $val) {
  30862. if (!isset($version[$key])) {
  30863. $minifiedVersion[$key] = "__unset";
  30864. unset($lastKnownVersionData[$key]);
  30865. }
  30866. }
  30867. $minifiedVersions[] = $minifiedVersion;
  30868. }
  30869. return $minifiedVersions;
  30870. }
  30871. }
  30872. <?php
  30873. namespace Composer\Util;
  30874. use stdClass;
  30875. class NoProxyPattern
  30876. {
  30877. protected $hostNames = array();
  30878. protected $rules = array();
  30879. protected $noproxy;
  30880. public function __construct($pattern)
  30881. {
  30882. $this->hostNames = preg_split('{[\s,]+}', $pattern, null, PREG_SPLIT_NO_EMPTY);
  30883. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  30884. }
  30885. public function test($url)
  30886. {
  30887. if ($this->noproxy) {
  30888. return true;
  30889. }
  30890. if (!$urlData = $this->getUrlData($url)) {
  30891. return false;
  30892. }
  30893. foreach ($this->hostNames as $index => $hostName) {
  30894. if ($this->match($index, $hostName, $urlData)) {
  30895. return true;
  30896. }
  30897. }
  30898. return false;
  30899. }
  30900. protected function getUrlData($url)
  30901. {
  30902. if (!$host = parse_url($url, PHP_URL_HOST)) {
  30903. return false;
  30904. }
  30905. $port = parse_url($url, PHP_URL_PORT);
  30906. if (empty($port)) {
  30907. switch (parse_url($url, PHP_URL_SCHEME)) {
  30908. case 'http':
  30909. $port = 80;
  30910. break;
  30911. case 'https':
  30912. $port = 443;
  30913. break;
  30914. }
  30915. }
  30916. $hostName = $host . ($port ? ':' . $port : '');
  30917. list($host, $port, $err) = $this->splitHostPort($hostName);
  30918. if ($err || !$this->ipCheckData($host, $ipdata)) {
  30919. return false;
  30920. }
  30921. return $this->makeData($host, $port, $ipdata);
  30922. }
  30923. protected function match($index, $hostName, $url)
  30924. {
  30925. if (!$rule = $this->getRule($index, $hostName)) {
  30926. return false;
  30927. }
  30928. if ($rule->ipdata) {
  30929. if (!$url->ipdata) {
  30930. return false;
  30931. }
  30932. if ($rule->ipdata->netmask) {
  30933. return $this->matchRange($rule->ipdata, $url->ipdata);
  30934. }
  30935. $match = $rule->ipdata->ip === $url->ipdata->ip;
  30936. } else {
  30937. $haystack = substr($url->name, - strlen($rule->name));
  30938. $match = stripos($haystack, $rule->name) === 0;
  30939. }
  30940. if ($match && $rule->port) {
  30941. $match = $rule->port === $url->port;
  30942. }
  30943. return $match;
  30944. }
  30945. protected function matchRange(stdClass $network, stdClass $target)
  30946. {
  30947. $net = unpack('C*', $network->ip);
  30948. $mask = unpack('C*', $network->netmask);
  30949. $ip = unpack('C*', $target->ip);
  30950. for ($i = 1; $i < 17; ++$i) {
  30951. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  30952. return false;
  30953. }
  30954. }
  30955. return true;
  30956. }
  30957. private function getRule($index, $hostName)
  30958. {
  30959. if (array_key_exists($index, $this->rules)) {
  30960. return $this->rules[$index];
  30961. }
  30962. $this->rules[$index] = null;
  30963. list($host, $port, $err) = $this->splitHostPort($hostName);
  30964. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  30965. return null;
  30966. }
  30967. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  30968. return $this->rules[$index];
  30969. }
  30970. private function ipCheckData($host, &$ipdata, $allowPrefix = false)
  30971. {
  30972. $ipdata = null;
  30973. $netmask = null;
  30974. $prefix = null;
  30975. $modified = false;
  30976. if (strpos($host, '/') !== false) {
  30977. list($host, $prefix) = explode('/', $host);
  30978. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  30979. return false;
  30980. }
  30981. $prefix = (int) $prefix;
  30982. $modified = true;
  30983. }
  30984. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  30985. return !$modified;
  30986. }
  30987. list($ip, $size) = $this->ipGetAddr($host);
  30988. if ($prefix !== null) {
  30989. if ($prefix > $size * 8) {
  30990. return false;
  30991. }
  30992. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  30993. }
  30994. $ipdata = $this->makeIpData($ip, $size, $netmask);
  30995. return true;
  30996. }
  30997. private function ipGetAddr($host)
  30998. {
  30999. $ip = inet_pton($host);
  31000. $size = strlen($ip);
  31001. $mapped = $this->ipMapTo6($ip, $size);
  31002. return array($mapped, $size);
  31003. }
  31004. private function ipGetMask($prefix, $size)
  31005. {
  31006. $mask = '';
  31007. if ($ones = floor($prefix / 8)) {
  31008. $mask = str_repeat(chr(255), $ones);
  31009. }
  31010. if ($remainder = $prefix % 8) {
  31011. $mask .= chr(0xff ^ (0xff >> $remainder));
  31012. }
  31013. $mask = str_pad($mask, $size, chr(0));
  31014. return $this->ipMapTo6($mask, $size);
  31015. }
  31016. private function ipGetNetwork($rangeIp, $size, $prefix)
  31017. {
  31018. $netmask = $this->ipGetMask($prefix, $size);
  31019. $mask = unpack('C*', $netmask);
  31020. $ip = unpack('C*', $rangeIp);
  31021. $net = '';
  31022. for ($i = 1; $i < 17; ++$i) {
  31023. $net .= chr($ip[$i] & $mask[$i]);
  31024. }
  31025. return array($net, $netmask);
  31026. }
  31027. private function ipMapTo6($binary, $size)
  31028. {
  31029. if ($size === 4) {
  31030. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  31031. $binary = $prefix . $binary;
  31032. }
  31033. return $binary;
  31034. }
  31035. private function makeData($host, $port, $ipdata)
  31036. {
  31037. return (object) array(
  31038. 'host' => $host,
  31039. 'name' => '.' . ltrim($host, '.'),
  31040. 'port' => $port,
  31041. 'ipdata' => $ipdata,
  31042. );
  31043. }
  31044. private function makeIpData($ip, $size, $netmask)
  31045. {
  31046. return (object) array(
  31047. 'ip' => $ip,
  31048. 'size' => $size,
  31049. 'netmask' => $netmask,
  31050. );
  31051. }
  31052. private function splitHostPort($hostName)
  31053. {
  31054. $error = array('', '', true);
  31055. $port = 0;
  31056. $ip6 = '';
  31057. if ($hostName[0] === '[') {
  31058. $index = strpos($hostName, ']');
  31059. if (false === $index || $index < 3) {
  31060. return $error;
  31061. }
  31062. $ip6 = substr($hostName, 1, $index - 1);
  31063. $hostName = substr($hostName, $index + 1);
  31064. if (strpbrk($hostName, '[]') !== false
  31065. || substr_count($hostName, ':') > 1) {
  31066. return $error;
  31067. }
  31068. }
  31069. if (substr_count($hostName, ':') === 1) {
  31070. $index = strpos($hostName, ':');
  31071. $port = substr($hostName, $index + 1);
  31072. $hostName = substr($hostName, 0, $index);
  31073. if (!$this->validateInt($port, 1, 65535)) {
  31074. return $error;
  31075. }
  31076. $port = (int) $port;
  31077. }
  31078. $host = $ip6 . $hostName;
  31079. return array($host, $port, false);
  31080. }
  31081. private function validateInt($int, $min, $max)
  31082. {
  31083. $options = array(
  31084. 'options' => array(
  31085. 'min_range' => $min,
  31086. 'max_range' => $max)
  31087. );
  31088. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  31089. }
  31090. }
  31091. <?php
  31092. namespace Composer\Util;
  31093. use Composer\Package\Link;
  31094. use Composer\Package\PackageInterface;
  31095. class PackageSorter
  31096. {
  31097. public static function sortPackages(array $packages) {
  31098. $usageList = array();
  31099. foreach ($packages as $package) {
  31100. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  31101. $target = $link->getTarget();
  31102. $usageList[$target][] = $package->getName();
  31103. }
  31104. }
  31105. $computing = array();
  31106. $computed = array();
  31107. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  31108. if (isset($computed[$name])) {
  31109. return $computed[$name];
  31110. }
  31111. if (isset($computing[$name])) {
  31112. return 0;
  31113. }
  31114. $computing[$name] = true;
  31115. $weight = 0;
  31116. if (isset($usageList[$name])) {
  31117. foreach ($usageList[$name] as $user) {
  31118. $weight -= 1 - $computeImportance($user);
  31119. }
  31120. }
  31121. unset($computing[$name]);
  31122. $computed[$name] = $weight;
  31123. return $weight;
  31124. };
  31125. $weightList = array();
  31126. foreach ($packages as $index => $package) {
  31127. $weight = $computeImportance($package->getName());
  31128. $weightList[$index] = $weight;
  31129. }
  31130. $stable_sort = function (&$array) {
  31131. static $transform, $restore;
  31132. $i = 0;
  31133. if (!$transform) {
  31134. $transform = function (&$v, $k) use (&$i) {
  31135. $v = array($v, ++$i, $k, $v);
  31136. };
  31137. $restore = function (&$v) {
  31138. $v = $v[3];
  31139. };
  31140. }
  31141. array_walk($array, $transform);
  31142. asort($array);
  31143. array_walk($array, $restore);
  31144. };
  31145. $stable_sort($weightList);
  31146. $sortedPackages = array();
  31147. foreach (array_keys($weightList) as $index) {
  31148. $sortedPackages[] = $packages[$index];
  31149. }
  31150. return $sortedPackages;
  31151. }
  31152. }
  31153. <?php
  31154. namespace Composer\Util;
  31155. use Composer\IO\IOInterface;
  31156. use Symfony\Component\Process\Process;
  31157. class Perforce
  31158. {
  31159. protected $path;
  31160. protected $p4Depot;
  31161. protected $p4Client;
  31162. protected $p4User;
  31163. protected $p4Password;
  31164. protected $p4Port;
  31165. protected $p4Stream;
  31166. protected $p4ClientSpec;
  31167. protected $p4DepotType;
  31168. protected $p4Branch;
  31169. protected $process;
  31170. protected $uniquePerforceClientName;
  31171. protected $windowsFlag;
  31172. protected $commandResult;
  31173. protected $io;
  31174. protected $filesystem;
  31175. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  31176. {
  31177. $this->windowsFlag = $isWindows;
  31178. $this->p4Port = $port;
  31179. $this->initializePath($path);
  31180. $this->process = $process;
  31181. $this->initialize($repoConfig);
  31182. $this->io = $io;
  31183. }
  31184. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  31185. {
  31186. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  31187. }
  31188. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  31189. {
  31190. $output = null;
  31191. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  31192. }
  31193. public function initialize($repoConfig)
  31194. {
  31195. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  31196. if (!$repoConfig) {
  31197. return;
  31198. }
  31199. if (isset($repoConfig['unique_perforce_client_name'])) {
  31200. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  31201. }
  31202. if (isset($repoConfig['depot'])) {
  31203. $this->p4Depot = $repoConfig['depot'];
  31204. }
  31205. if (isset($repoConfig['branch'])) {
  31206. $this->p4Branch = $repoConfig['branch'];
  31207. }
  31208. if (isset($repoConfig['p4user'])) {
  31209. $this->p4User = $repoConfig['p4user'];
  31210. } else {
  31211. $this->p4User = $this->getP4variable('P4USER');
  31212. }
  31213. if (isset($repoConfig['p4password'])) {
  31214. $this->p4Password = $repoConfig['p4password'];
  31215. }
  31216. }
  31217. public function initializeDepotAndBranch($depot, $branch)
  31218. {
  31219. if (isset($depot)) {
  31220. $this->p4Depot = $depot;
  31221. }
  31222. if (isset($branch)) {
  31223. $this->p4Branch = $branch;
  31224. }
  31225. }
  31226. public function generateUniquePerforceClientName()
  31227. {
  31228. return gethostname() . "_" . time();
  31229. }
  31230. public function cleanupClientSpec()
  31231. {
  31232. $client = $this->getClient();
  31233. $task = 'client -d ' . ProcessExecutor::escape($client);
  31234. $useP4Client = false;
  31235. $command = $this->generateP4Command($task, $useP4Client);
  31236. $this->executeCommand($command);
  31237. $clientSpec = $this->getP4ClientSpec();
  31238. $fileSystem = $this->getFilesystem();
  31239. $fileSystem->remove($clientSpec);
  31240. }
  31241. protected function executeCommand($command)
  31242. {
  31243. $this->commandResult = '';
  31244. return $this->process->execute($command, $this->commandResult);
  31245. }
  31246. public function getClient()
  31247. {
  31248. if (!isset($this->p4Client)) {
  31249. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  31250. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  31251. }
  31252. return $this->p4Client;
  31253. }
  31254. protected function getPath()
  31255. {
  31256. return $this->path;
  31257. }
  31258. public function initializePath($path)
  31259. {
  31260. $this->path = $path;
  31261. $fs = $this->getFilesystem();
  31262. $fs->ensureDirectoryExists($path);
  31263. }
  31264. protected function getPort()
  31265. {
  31266. return $this->p4Port;
  31267. }
  31268. public function setStream($stream)
  31269. {
  31270. $this->p4Stream = $stream;
  31271. $index = strrpos($stream, '/');
  31272. if ($index > 2) {
  31273. $this->p4DepotType = 'stream';
  31274. }
  31275. }
  31276. public function isStream()
  31277. {
  31278. return (strcmp($this->p4DepotType, 'stream') === 0);
  31279. }
  31280. public function getStream()
  31281. {
  31282. if (!isset($this->p4Stream)) {
  31283. if ($this->isStream()) {
  31284. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  31285. } else {
  31286. $this->p4Stream = '//' . $this->p4Depot;
  31287. }
  31288. }
  31289. return $this->p4Stream;
  31290. }
  31291. public function getStreamWithoutLabel($stream)
  31292. {
  31293. $index = strpos($stream, '@');
  31294. if ($index === false) {
  31295. return $stream;
  31296. }
  31297. return substr($stream, 0, $index);
  31298. }
  31299. public function getP4ClientSpec()
  31300. {
  31301. return $this->path . '/' . $this->getClient() . '.p4.spec';
  31302. }
  31303. public function getUser()
  31304. {
  31305. return $this->p4User;
  31306. }
  31307. public function setUser($user)
  31308. {
  31309. $this->p4User = $user;
  31310. }
  31311. public function queryP4User()
  31312. {
  31313. $this->getUser();
  31314. if (strlen($this->p4User) > 0) {
  31315. return;
  31316. }
  31317. $this->p4User = $this->getP4variable('P4USER');
  31318. if (strlen($this->p4User) > 0) {
  31319. return;
  31320. }
  31321. $this->p4User = $this->io->ask('Enter P4 User:');
  31322. if ($this->windowsFlag) {
  31323. $command = 'p4 set P4USER=' . $this->p4User;
  31324. } else {
  31325. $command = 'export P4USER=' . $this->p4User;
  31326. }
  31327. $this->executeCommand($command);
  31328. }
  31329. protected function getP4variable($name)
  31330. {
  31331. if ($this->windowsFlag) {
  31332. $command = 'p4 set';
  31333. $this->executeCommand($command);
  31334. $result = trim($this->commandResult);
  31335. $resArray = explode(PHP_EOL, $result);
  31336. foreach ($resArray as $line) {
  31337. $fields = explode('=', $line);
  31338. if (strcmp($name, $fields[0]) == 0) {
  31339. $index = strpos($fields[1], ' ');
  31340. if ($index === false) {
  31341. $value = $fields[1];
  31342. } else {
  31343. $value = substr($fields[1], 0, $index);
  31344. }
  31345. $value = trim($value);
  31346. return $value;
  31347. }
  31348. }
  31349. return null;
  31350. }
  31351. $command = 'echo $' . $name;
  31352. $this->executeCommand($command);
  31353. $result = trim($this->commandResult);
  31354. return $result;
  31355. }
  31356. public function queryP4Password()
  31357. {
  31358. if (isset($this->p4Password)) {
  31359. return $this->p4Password;
  31360. }
  31361. $password = $this->getP4variable('P4PASSWD');
  31362. if (strlen($password) <= 0) {
  31363. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  31364. }
  31365. $this->p4Password = $password;
  31366. return $password;
  31367. }
  31368. public function generateP4Command($command, $useClient = true)
  31369. {
  31370. $p4Command = 'p4 ';
  31371. $p4Command .= '-u ' . $this->getUser() . ' ';
  31372. if ($useClient) {
  31373. $p4Command .= '-c ' . $this->getClient() . ' ';
  31374. }
  31375. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  31376. return $p4Command;
  31377. }
  31378. public function isLoggedIn()
  31379. {
  31380. $command = $this->generateP4Command('login -s', false);
  31381. $exitCode = $this->executeCommand($command);
  31382. if ($exitCode) {
  31383. $errorOutput = $this->process->getErrorOutput();
  31384. $index = strpos($errorOutput, $this->getUser());
  31385. if ($index === false) {
  31386. $index = strpos($errorOutput, 'p4');
  31387. if ($index === false) {
  31388. return false;
  31389. }
  31390. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  31391. }
  31392. throw new \Exception('Invalid user name: ' . $this->getUser());
  31393. }
  31394. return true;
  31395. }
  31396. public function connectClient()
  31397. {
  31398. $p4CreateClientCommand = $this->generateP4Command(
  31399. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  31400. );
  31401. $this->executeCommand($p4CreateClientCommand);
  31402. }
  31403. public function syncCodeBase($sourceReference)
  31404. {
  31405. $prevDir = getcwd();
  31406. chdir($this->path);
  31407. $p4SyncCommand = $this->generateP4Command('sync -f ');
  31408. if (null !== $sourceReference) {
  31409. $p4SyncCommand .= '@' . $sourceReference;
  31410. }
  31411. $this->executeCommand($p4SyncCommand);
  31412. chdir($prevDir);
  31413. }
  31414. public function writeClientSpecToFile($spec)
  31415. {
  31416. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  31417. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  31418. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  31419. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  31420. fwrite($spec, 'Description:' . PHP_EOL);
  31421. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  31422. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  31423. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  31424. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  31425. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  31426. if ($this->isStream()) {
  31427. fwrite($spec, 'Stream:' . PHP_EOL);
  31428. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  31429. } else {
  31430. fwrite(
  31431. $spec,
  31432. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  31433. );
  31434. }
  31435. }
  31436. public function writeP4ClientSpec()
  31437. {
  31438. $clientSpec = $this->getP4ClientSpec();
  31439. $spec = fopen($clientSpec, 'w');
  31440. try {
  31441. $this->writeClientSpecToFile($spec);
  31442. } catch (\Exception $e) {
  31443. fclose($spec);
  31444. throw $e;
  31445. }
  31446. fclose($spec);
  31447. }
  31448. protected function read($pipe, $name)
  31449. {
  31450. if (feof($pipe)) {
  31451. return;
  31452. }
  31453. $line = fgets($pipe);
  31454. while ($line !== false) {
  31455. $line = fgets($pipe);
  31456. }
  31457. }
  31458. public function windowsLogin($password)
  31459. {
  31460. $command = $this->generateP4Command(' login -a');
  31461. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31462. $process = Process::fromShellCommandline($command, null, null, $password);
  31463. } else {
  31464. $process = new Process($command, null, null, $password);
  31465. }
  31466. return $process->run();
  31467. }
  31468. public function p4Login()
  31469. {
  31470. $this->queryP4User();
  31471. if (!$this->isLoggedIn()) {
  31472. $password = $this->queryP4Password();
  31473. if ($this->windowsFlag) {
  31474. $this->windowsLogin($password);
  31475. } else {
  31476. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  31477. $exitCode = $this->executeCommand($command);
  31478. if ($exitCode) {
  31479. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  31480. }
  31481. }
  31482. }
  31483. }
  31484. public function getComposerInformation($identifier)
  31485. {
  31486. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  31487. if (!$composerFileContent) {
  31488. return;
  31489. }
  31490. return json_decode($composerFileContent, true);
  31491. }
  31492. public function getFileContent($file, $identifier)
  31493. {
  31494. $path = $this->getFilePath($file, $identifier);
  31495. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  31496. $this->executeCommand($command);
  31497. $result = $this->commandResult;
  31498. if (!trim($result)) {
  31499. return null;
  31500. }
  31501. return $result;
  31502. }
  31503. public function getFilePath($file, $identifier)
  31504. {
  31505. $index = strpos($identifier, '@');
  31506. if ($index === false) {
  31507. return $identifier. '/' . $file;
  31508. }
  31509. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  31510. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  31511. $this->executeCommand($command);
  31512. $result = $this->commandResult;
  31513. $index2 = strpos($result, 'no such file(s).');
  31514. if ($index2 === false) {
  31515. $index3 = strpos($result, 'change');
  31516. if ($index3 !== false) {
  31517. $phrase = trim(substr($result, $index3));
  31518. $fields = explode(' ', $phrase);
  31519. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  31520. }
  31521. }
  31522. return null;
  31523. }
  31524. public function getBranches()
  31525. {
  31526. $possibleBranches = array();
  31527. if (!$this->isStream()) {
  31528. $possibleBranches[$this->p4Branch] = $this->getStream();
  31529. } else {
  31530. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  31531. $this->executeCommand($command);
  31532. $result = $this->commandResult;
  31533. $resArray = explode(PHP_EOL, $result);
  31534. foreach ($resArray as $line) {
  31535. $resBits = explode(' ', $line);
  31536. if (count($resBits) > 4) {
  31537. $branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  31538. $possibleBranches[$branch] = $resBits[1];
  31539. }
  31540. }
  31541. }
  31542. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  31543. $this->executeCommand($command);
  31544. $result = $this->commandResult;
  31545. $resArray = explode(PHP_EOL, $result);
  31546. $lastCommit = $resArray[0];
  31547. $lastCommitArr = explode(' ', $lastCommit);
  31548. $lastCommitNum = $lastCommitArr[1];
  31549. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  31550. }
  31551. public function getTags()
  31552. {
  31553. $command = $this->generateP4Command('labels');
  31554. $this->executeCommand($command);
  31555. $result = $this->commandResult;
  31556. $resArray = explode(PHP_EOL, $result);
  31557. $tags = array();
  31558. foreach ($resArray as $line) {
  31559. if (strpos($line, 'Label') !== false) {
  31560. $fields = explode(' ', $line);
  31561. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  31562. }
  31563. }
  31564. return $tags;
  31565. }
  31566. public function checkStream()
  31567. {
  31568. $command = $this->generateP4Command('depots', false);
  31569. $this->executeCommand($command);
  31570. $result = $this->commandResult;
  31571. $resArray = explode(PHP_EOL, $result);
  31572. foreach ($resArray as $line) {
  31573. if (strpos($line, 'Depot') !== false) {
  31574. $fields = explode(' ', $line);
  31575. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  31576. $this->p4DepotType = $fields[3];
  31577. return $this->isStream();
  31578. }
  31579. }
  31580. }
  31581. return false;
  31582. }
  31583. protected function getChangeList($reference)
  31584. {
  31585. $index = strpos($reference, '@');
  31586. if ($index === false) {
  31587. return null;
  31588. }
  31589. $label = substr($reference, $index);
  31590. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  31591. $this->executeCommand($command);
  31592. $changes = $this->commandResult;
  31593. if (strpos($changes, 'Change') !== 0) {
  31594. return null;
  31595. }
  31596. $fields = explode(' ', $changes);
  31597. return $fields[1];
  31598. }
  31599. public function getCommitLogs($fromReference, $toReference)
  31600. {
  31601. $fromChangeList = $this->getChangeList($fromReference);
  31602. if ($fromChangeList === null) {
  31603. return null;
  31604. }
  31605. $toChangeList = $this->getChangeList($toReference);
  31606. if ($toChangeList === null) {
  31607. return null;
  31608. }
  31609. $index = strpos($fromReference, '@');
  31610. $main = substr($fromReference, 0, $index) . '/...';
  31611. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  31612. $this->executeCommand($command);
  31613. return $this->commandResult;
  31614. }
  31615. public function getFilesystem()
  31616. {
  31617. if (empty($this->filesystem)) {
  31618. $this->filesystem = new Filesystem($this->process);
  31619. }
  31620. return $this->filesystem;
  31621. }
  31622. public function setFilesystem(Filesystem $fs)
  31623. {
  31624. $this->filesystem = $fs;
  31625. }
  31626. }
  31627. <?php
  31628. namespace Composer\Util;
  31629. class Platform
  31630. {
  31631. public static function expandPath($path)
  31632. {
  31633. if (preg_match('#^~[\\/]#', $path)) {
  31634. return self::getUserDirectory() . substr($path, 1);
  31635. }
  31636. return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  31637. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  31638. return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
  31639. }
  31640. return getenv($matches['var']) . $matches['path'];
  31641. }, $path);
  31642. }
  31643. public static function getUserDirectory()
  31644. {
  31645. if (false !== ($home = getenv('HOME'))) {
  31646. return $home;
  31647. }
  31648. if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
  31649. return $home;
  31650. }
  31651. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  31652. $info = posix_getpwuid(posix_getuid());
  31653. return $info['dir'];
  31654. }
  31655. throw new \RuntimeException('Could not determine user directory');
  31656. }
  31657. public static function isWindows()
  31658. {
  31659. return \defined('PHP_WINDOWS_VERSION_BUILD');
  31660. }
  31661. public static function strlen($str)
  31662. {
  31663. static $useMbString = null;
  31664. if (null === $useMbString) {
  31665. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  31666. }
  31667. if ($useMbString) {
  31668. return mb_strlen($str, '8bit');
  31669. }
  31670. return \strlen($str);
  31671. }
  31672. public static function isTty($fd = null)
  31673. {
  31674. if ($fd === null) {
  31675. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  31676. }
  31677. if (function_exists('stream_isatty')) {
  31678. return stream_isatty($fd);
  31679. }
  31680. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  31681. return true;
  31682. }
  31683. $stat = @fstat($fd);
  31684. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  31685. }
  31686. }
  31687. <?php
  31688. namespace Composer\Util;
  31689. use Composer\IO\IOInterface;
  31690. use Symfony\Component\Process\Process;
  31691. use Symfony\Component\Process\ProcessUtils;
  31692. use Symfony\Component\Process\Exception\RuntimeException;
  31693. use React\Promise\Promise;
  31694. class ProcessExecutor
  31695. {
  31696. const STATUS_QUEUED = 1;
  31697. const STATUS_STARTED = 2;
  31698. const STATUS_COMPLETED = 3;
  31699. const STATUS_FAILED = 4;
  31700. const STATUS_ABORTED = 5;
  31701. protected static $timeout = 300;
  31702. protected $captureOutput;
  31703. protected $errorOutput;
  31704. protected $io;
  31705. private $jobs = array();
  31706. private $runningJobs = 0;
  31707. private $maxJobs = 10;
  31708. private $idGen = 0;
  31709. private $allowAsync = false;
  31710. public function __construct(IOInterface $io = null)
  31711. {
  31712. $this->io = $io;
  31713. }
  31714. public function execute($command, &$output = null, $cwd = null)
  31715. {
  31716. if (func_num_args() > 1) {
  31717. return $this->doExecute($command, $cwd, false, $output);
  31718. }
  31719. return $this->doExecute($command, $cwd, false);
  31720. }
  31721. public function executeTty($command, $cwd = null)
  31722. {
  31723. if (Platform::isTty()) {
  31724. return $this->doExecute($command, $cwd, true);
  31725. }
  31726. return $this->doExecute($command, $cwd, false);
  31727. }
  31728. private function doExecute($command, $cwd, $tty, &$output = null)
  31729. {
  31730. if ($this->io && $this->io->isDebug()) {
  31731. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  31732. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  31733. return '://***:***@';
  31734. }
  31735. return '://'.$m['user'].':***@';
  31736. }, $command);
  31737. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  31738. $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  31739. }
  31740. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  31741. $cwd = realpath(getcwd());
  31742. }
  31743. $this->captureOutput = func_num_args() > 3;
  31744. $this->errorOutput = null;
  31745. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31746. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  31747. } else {
  31748. $process = new Process($command, $cwd, null, null, static::getTimeout());
  31749. }
  31750. if (!Platform::isWindows() && $tty) {
  31751. try {
  31752. $process->setTty(true);
  31753. } catch (RuntimeException $e) {
  31754. }
  31755. }
  31756. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  31757. $process->run($callback);
  31758. if ($this->captureOutput && !is_callable($output)) {
  31759. $output = $process->getOutput();
  31760. }
  31761. $this->errorOutput = $process->getErrorOutput();
  31762. return $process->getExitCode();
  31763. }
  31764. public function executeAsync($command, $cwd = null)
  31765. {
  31766. if (!$this->allowAsync) {
  31767. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  31768. }
  31769. $job = array(
  31770. 'id' => $this->idGen++,
  31771. 'status' => self::STATUS_QUEUED,
  31772. 'command' => $command,
  31773. 'cwd' => $cwd,
  31774. );
  31775. $resolver = function ($resolve, $reject) use (&$job) {
  31776. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  31777. $job['resolve'] = $resolve;
  31778. $job['reject'] = $reject;
  31779. };
  31780. $self = $this;
  31781. $canceler = function () use (&$job) {
  31782. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  31783. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  31784. }
  31785. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  31786. return;
  31787. }
  31788. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  31789. try {
  31790. if (defined('SIGINT')) {
  31791. $job['process']->signal(SIGINT);
  31792. }
  31793. } catch (\Exception $e) {
  31794. }
  31795. $job['process']->stop(1);
  31796. };
  31797. $promise = new Promise($resolver, $canceler);
  31798. $promise = $promise->then(function () use (&$job, $self) {
  31799. if ($job['process']->isSuccessful()) {
  31800. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  31801. } else {
  31802. $job['status'] = ProcessExecutor::STATUS_FAILED;
  31803. }
  31804. $self->markJobDone();
  31805. return $job['process'];
  31806. }, function ($e) use (&$job, $self) {
  31807. $job['status'] = ProcessExecutor::STATUS_FAILED;
  31808. $self->markJobDone();
  31809. throw $e;
  31810. });
  31811. $this->jobs[$job['id']] =& $job;
  31812. if ($this->runningJobs < $this->maxJobs) {
  31813. $this->startJob($job['id']);
  31814. }
  31815. return $promise;
  31816. }
  31817. private function startJob($id)
  31818. {
  31819. $job =& $this->jobs[$id];
  31820. if ($job['status'] !== self::STATUS_QUEUED) {
  31821. return;
  31822. }
  31823. $job['status'] = self::STATUS_STARTED;
  31824. $this->runningJobs++;
  31825. $command = $job['command'];
  31826. $cwd = $job['cwd'];
  31827. if ($this->io && $this->io->isDebug()) {
  31828. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  31829. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  31830. return '://***:***@';
  31831. }
  31832. return '://'.$m['user'].':***@';
  31833. }, $command);
  31834. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  31835. $this->io->writeError('Executing async command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  31836. }
  31837. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  31838. $cwd = realpath(getcwd());
  31839. }
  31840. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31841. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  31842. } else {
  31843. $process = new Process($command, $cwd, null, null, static::getTimeout());
  31844. }
  31845. $job['process'] = $process;
  31846. $process->start();
  31847. }
  31848. public function wait($index = null)
  31849. {
  31850. while (true) {
  31851. if (!$this->countActiveJobs($index)) {
  31852. return;
  31853. }
  31854. usleep(1000);
  31855. }
  31856. }
  31857. public function enableAsync()
  31858. {
  31859. $this->allowAsync = true;
  31860. }
  31861. public function countActiveJobs($index = null)
  31862. {
  31863. foreach ($this->jobs as $job) {
  31864. if ($job['status'] === self::STATUS_STARTED) {
  31865. if (!$job['process']->isRunning()) {
  31866. call_user_func($job['resolve'], $job['process']);
  31867. }
  31868. }
  31869. if ($this->runningJobs < $this->maxJobs) {
  31870. if ($job['status'] === self::STATUS_QUEUED) {
  31871. $this->startJob($job['id']);
  31872. }
  31873. }
  31874. }
  31875. if (null !== $index) {
  31876. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  31877. }
  31878. $active = 0;
  31879. foreach ($this->jobs as $job) {
  31880. if ($job['status'] < self::STATUS_COMPLETED) {
  31881. $active++;
  31882. } else {
  31883. unset($this->jobs[$job['id']]);
  31884. }
  31885. }
  31886. return $active;
  31887. }
  31888. public function markJobDone()
  31889. {
  31890. $this->runningJobs--;
  31891. }
  31892. public function splitLines($output)
  31893. {
  31894. $output = trim($output);
  31895. return ((string) $output === '') ? array() : preg_split('{\r?\n}', $output);
  31896. }
  31897. public function getErrorOutput()
  31898. {
  31899. return $this->errorOutput;
  31900. }
  31901. public function outputHandler($type, $buffer)
  31902. {
  31903. if ($this->captureOutput) {
  31904. return;
  31905. }
  31906. if (null === $this->io) {
  31907. echo $buffer;
  31908. return;
  31909. }
  31910. if (Process::ERR === $type) {
  31911. $this->io->writeErrorRaw($buffer, false);
  31912. } else {
  31913. $this->io->writeRaw($buffer, false);
  31914. }
  31915. }
  31916. public static function getTimeout()
  31917. {
  31918. return static::$timeout;
  31919. }
  31920. public static function setTimeout($timeout)
  31921. {
  31922. static::$timeout = $timeout;
  31923. }
  31924. public static function escape($argument)
  31925. {
  31926. return self::escapeArgument($argument);
  31927. }
  31928. private static function escapeArgument($argument)
  31929. {
  31930. if ('\\' === DIRECTORY_SEPARATOR) {
  31931. if ((string) $argument === '') {
  31932. return escapeshellarg($argument);
  31933. }
  31934. $escapedArgument = '';
  31935. $quote = false;
  31936. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  31937. if ('"' === $part) {
  31938. $escapedArgument .= '\\"';
  31939. } elseif (self::isSurroundedBy($part, '%')) {
  31940. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  31941. } else {
  31942. if ('\\' === substr($part, -1)) {
  31943. $part .= '\\';
  31944. }
  31945. $quote = true;
  31946. $escapedArgument .= $part;
  31947. }
  31948. }
  31949. if ($quote) {
  31950. $escapedArgument = '"'.$escapedArgument.'"';
  31951. }
  31952. return $escapedArgument;
  31953. }
  31954. return "'".str_replace("'", "'\\''", $argument)."'";
  31955. }
  31956. private static function isSurroundedBy($arg, $char)
  31957. {
  31958. return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
  31959. }
  31960. }
  31961. <?php
  31962. namespace Composer\Util;
  31963. use Composer\Config;
  31964. use Composer\Downloader\MaxFileSizeExceededException;
  31965. use Composer\IO\IOInterface;
  31966. use Composer\Downloader\TransportException;
  31967. use Composer\CaBundle\CaBundle;
  31968. use Composer\Util\Http\Response;
  31969. use Composer\Util\Http\ProxyManager;
  31970. class RemoteFilesystem
  31971. {
  31972. private $io;
  31973. private $config;
  31974. private $scheme;
  31975. private $bytesMax;
  31976. private $originUrl;
  31977. private $fileUrl;
  31978. private $fileName;
  31979. private $retry;
  31980. private $progress;
  31981. private $lastProgress;
  31982. private $options = array();
  31983. private $peerCertificateMap = array();
  31984. private $disableTls = false;
  31985. private $lastHeaders;
  31986. private $storeAuth;
  31987. private $authHelper;
  31988. private $degradedMode = false;
  31989. private $redirects;
  31990. private $maxRedirects = 20;
  31991. private $proxyManager;
  31992. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false, AuthHelper $authHelper = null)
  31993. {
  31994. $this->io = $io;
  31995. if ($disableTls === false) {
  31996. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  31997. } else {
  31998. $this->disableTls = true;
  31999. }
  32000. $this->options = array_replace_recursive($this->options, $options);
  32001. $this->config = $config;
  32002. $this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
  32003. $this->proxyManager = ProxyManager::getInstance();
  32004. }
  32005. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  32006. {
  32007. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  32008. }
  32009. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  32010. {
  32011. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  32012. }
  32013. public function getOptions()
  32014. {
  32015. return $this->options;
  32016. }
  32017. public function setOptions(array $options)
  32018. {
  32019. $this->options = array_replace_recursive($this->options, $options);
  32020. }
  32021. public function isTlsDisabled()
  32022. {
  32023. return $this->disableTls === true;
  32024. }
  32025. public function getLastHeaders()
  32026. {
  32027. return $this->lastHeaders;
  32028. }
  32029. public static function findStatusCode(array $headers)
  32030. {
  32031. $value = null;
  32032. foreach ($headers as $header) {
  32033. if (preg_match('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  32034. $value = (int) $match[1];
  32035. }
  32036. }
  32037. return $value;
  32038. }
  32039. public function findStatusMessage(array $headers)
  32040. {
  32041. $value = null;
  32042. foreach ($headers as $header) {
  32043. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  32044. $value = $header;
  32045. }
  32046. }
  32047. return $value;
  32048. }
  32049. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  32050. {
  32051. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  32052. $this->bytesMax = 0;
  32053. $this->originUrl = $originUrl;
  32054. $this->fileUrl = $fileUrl;
  32055. $this->fileName = $fileName;
  32056. $this->progress = $progress;
  32057. $this->lastProgress = null;
  32058. $retryAuthFailure = true;
  32059. $this->lastHeaders = array();
  32060. $this->redirects = 1;
  32061. $tempAdditionalOptions = $additionalOptions;
  32062. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  32063. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  32064. unset($tempAdditionalOptions['retry-auth-failure']);
  32065. }
  32066. $isRedirect = false;
  32067. if (isset($tempAdditionalOptions['redirects'])) {
  32068. $this->redirects = $tempAdditionalOptions['redirects'];
  32069. $isRedirect = true;
  32070. unset($tempAdditionalOptions['redirects']);
  32071. }
  32072. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  32073. unset($tempAdditionalOptions);
  32074. $origFileUrl = $fileUrl;
  32075. if (isset($options['gitlab-token'])) {
  32076. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  32077. unset($options['gitlab-token']);
  32078. }
  32079. if (isset($options['http'])) {
  32080. $options['http']['ignore_errors'] = true;
  32081. }
  32082. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  32083. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  32084. $degradedPackagist = true;
  32085. }
  32086. $maxFileSize = null;
  32087. if (isset($options['max_file_size'])) {
  32088. $maxFileSize = $options['max_file_size'];
  32089. unset($options['max_file_size']);
  32090. }
  32091. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  32092. $proxy = ProxyManager::getInstance()->getProxyForRequest($fileUrl);
  32093. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  32094. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  32095. unset($origFileUrl, $proxy, $usingProxy);
  32096. if ((!preg_match('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
  32097. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  32098. }
  32099. if ($this->progress && !$isRedirect) {
  32100. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  32101. }
  32102. $errorMessage = '';
  32103. $errorCode = 0;
  32104. $result = false;
  32105. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32106. if ($errorMessage) {
  32107. $errorMessage .= "\n";
  32108. }
  32109. $errorMessage .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg);
  32110. return true;
  32111. });
  32112. $http_response_header = array();
  32113. try {
  32114. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  32115. if (!empty($http_response_header[0])) {
  32116. $statusCode = self::findStatusCode($http_response_header);
  32117. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  32118. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  32119. }
  32120. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  32121. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  32122. }
  32123. }
  32124. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  32125. if ($contentLength && Platform::strlen($result) < $contentLength) {
  32126. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  32127. $e->setHeaders($http_response_header);
  32128. $e->setStatusCode(self::findStatusCode($http_response_header));
  32129. try {
  32130. $e->setResponse($this->decodeResult($result, $http_response_header));
  32131. } catch (\Exception $e) {
  32132. $e->setResponse($result);
  32133. }
  32134. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  32135. throw $e;
  32136. }
  32137. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  32138. $params = stream_context_get_params($ctx);
  32139. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  32140. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  32141. if ($expectedPeerFingerprint !== $peerFingerprint) {
  32142. throw new TransportException('Peer fingerprint did not match');
  32143. }
  32144. }
  32145. } catch (\Exception $e) {
  32146. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  32147. $e->setHeaders($http_response_header);
  32148. $e->setStatusCode(self::findStatusCode($http_response_header));
  32149. }
  32150. if ($e instanceof TransportException && $result !== false) {
  32151. $e->setResponse($this->decodeResult($result, $http_response_header));
  32152. }
  32153. $result = false;
  32154. }
  32155. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  32156. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  32157. }
  32158. restore_error_handler();
  32159. if (isset($e) && !$this->retry) {
  32160. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32161. $this->degradedMode = true;
  32162. $this->io->writeError('');
  32163. $this->io->writeError(array(
  32164. '<error>'.$e->getMessage().'</error>',
  32165. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32166. ));
  32167. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32168. }
  32169. throw $e;
  32170. }
  32171. $statusCode = null;
  32172. $contentType = null;
  32173. $locationHeader = null;
  32174. if (!empty($http_response_header[0])) {
  32175. $statusCode = self::findStatusCode($http_response_header);
  32176. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  32177. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  32178. }
  32179. if ($originUrl === 'bitbucket.org'
  32180. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  32181. && substr($fileUrl, -4) === '.zip'
  32182. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  32183. && $contentType && preg_match('{^text/html\b}i', $contentType)
  32184. ) {
  32185. $result = false;
  32186. if ($retryAuthFailure) {
  32187. $this->promptAuthAndRetry(401);
  32188. }
  32189. }
  32190. if ($statusCode === 404
  32191. && $this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  32192. && false !== strpos($fileUrl, 'archive.zip')
  32193. ) {
  32194. $result = false;
  32195. if ($retryAuthFailure) {
  32196. $this->promptAuthAndRetry(401);
  32197. }
  32198. }
  32199. $hasFollowedRedirect = false;
  32200. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  32201. $hasFollowedRedirect = true;
  32202. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  32203. }
  32204. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  32205. if (!$this->retry) {
  32206. if ($this->progress && !$isRedirect) {
  32207. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  32208. }
  32209. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  32210. $e->setHeaders($http_response_header);
  32211. $e->setResponse($this->decodeResult($result, $http_response_header));
  32212. $e->setStatusCode($statusCode);
  32213. throw $e;
  32214. }
  32215. $result = false;
  32216. }
  32217. if ($this->progress && !$this->retry && !$isRedirect) {
  32218. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  32219. }
  32220. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  32221. try {
  32222. $result = $this->decodeResult($result, $http_response_header);
  32223. } catch (\Exception $e) {
  32224. if ($this->degradedMode) {
  32225. throw $e;
  32226. }
  32227. $this->degradedMode = true;
  32228. $this->io->writeError(array(
  32229. '',
  32230. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  32231. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32232. ));
  32233. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32234. }
  32235. }
  32236. if (false !== $result && null !== $fileName && !$isRedirect) {
  32237. if ('' === $result) {
  32238. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  32239. }
  32240. $errorMessage = '';
  32241. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32242. if ($errorMessage) {
  32243. $errorMessage .= "\n";
  32244. }
  32245. $errorMessage .= preg_replace('{^file_put_contents\(.*?\): }', '', $msg);
  32246. return true;
  32247. });
  32248. $result = (bool) file_put_contents($fileName, $result);
  32249. restore_error_handler();
  32250. if (false === $result) {
  32251. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  32252. }
  32253. }
  32254. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  32255. if (CaBundle::isOpensslParseSafe()) {
  32256. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  32257. if ($certDetails) {
  32258. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  32259. $this->retry = true;
  32260. }
  32261. } else {
  32262. $this->io->writeError('');
  32263. $this->io->writeError(sprintf(
  32264. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  32265. PHP_VERSION
  32266. ));
  32267. }
  32268. }
  32269. if ($this->retry) {
  32270. $this->retry = false;
  32271. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32272. if ($this->storeAuth && $this->config) {
  32273. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  32274. $this->storeAuth = false;
  32275. }
  32276. return $result;
  32277. }
  32278. if (false === $result) {
  32279. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  32280. if (!empty($http_response_header[0])) {
  32281. $e->setHeaders($http_response_header);
  32282. }
  32283. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32284. $this->degradedMode = true;
  32285. $this->io->writeError('');
  32286. $this->io->writeError(array(
  32287. '<error>'.$e->getMessage().'</error>',
  32288. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32289. ));
  32290. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32291. }
  32292. throw $e;
  32293. }
  32294. if (!empty($http_response_header[0])) {
  32295. $this->lastHeaders = $http_response_header;
  32296. }
  32297. return $result;
  32298. }
  32299. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null, $maxFileSize = null)
  32300. {
  32301. $result = false;
  32302. try {
  32303. $e = null;
  32304. if ($maxFileSize !== null) {
  32305. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  32306. } else {
  32307. $result = file_get_contents($fileUrl, false, $context);
  32308. }
  32309. } catch (\Throwable $e) {
  32310. } catch (\Exception $e) {
  32311. }
  32312. if ($maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  32313. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  32314. }
  32315. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  32316. if (null !== $e) {
  32317. throw $e;
  32318. }
  32319. return $result;
  32320. }
  32321. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  32322. {
  32323. switch ($notificationCode) {
  32324. case STREAM_NOTIFY_FAILURE:
  32325. if (400 === $messageCode) {
  32326. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  32327. }
  32328. break;
  32329. case STREAM_NOTIFY_FILE_SIZE_IS:
  32330. $this->bytesMax = $bytesMax;
  32331. break;
  32332. case STREAM_NOTIFY_PROGRESS:
  32333. if ($this->bytesMax > 0 && $this->progress) {
  32334. $progression = min(100, round($bytesTransferred / $this->bytesMax * 100));
  32335. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  32336. $this->lastProgress = $progression;
  32337. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  32338. }
  32339. }
  32340. break;
  32341. default:
  32342. break;
  32343. }
  32344. }
  32345. protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
  32346. {
  32347. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  32348. $this->storeAuth = $result['storeAuth'];
  32349. $this->retry = $result['retry'];
  32350. if ($this->retry) {
  32351. throw new TransportException('RETRY');
  32352. }
  32353. }
  32354. protected function getOptionsForUrl($originUrl, $additionalOptions)
  32355. {
  32356. $tlsOptions = array();
  32357. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  32358. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  32359. if (PHP_VERSION_ID < 50304) {
  32360. if ($host === 'github.com' || $host === 'api.github.com') {
  32361. $host = '*.github.com';
  32362. }
  32363. }
  32364. $tlsOptions['ssl']['CN_match'] = $host;
  32365. $tlsOptions['ssl']['SNI_server_name'] = $host;
  32366. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  32367. if (isset($this->peerCertificateMap[$urlAuthority])) {
  32368. $certMap = $this->peerCertificateMap[$urlAuthority];
  32369. $this->io->writeError('', true, IOInterface::DEBUG);
  32370. $this->io->writeError(sprintf(
  32371. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  32372. $certMap['cn'],
  32373. $urlAuthority
  32374. ), true, IOInterface::DEBUG);
  32375. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  32376. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  32377. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  32378. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  32379. }
  32380. }
  32381. $headers = array();
  32382. if (extension_loaded('zlib')) {
  32383. $headers[] = 'Accept-Encoding: gzip';
  32384. }
  32385. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  32386. if (!$this->degradedMode) {
  32387. $options['http']['protocol_version'] = 1.1;
  32388. $headers[] = 'Connection: close';
  32389. }
  32390. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  32391. $options['http']['follow_location'] = 0;
  32392. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  32393. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  32394. }
  32395. foreach ($headers as $header) {
  32396. $options['http']['header'][] = $header;
  32397. }
  32398. return $options;
  32399. }
  32400. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  32401. {
  32402. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  32403. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  32404. $targetUrl = $locationHeader;
  32405. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  32406. $targetUrl = $this->scheme.':'.$locationHeader;
  32407. } elseif ('/' === $locationHeader[0]) {
  32408. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  32409. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32410. } else {
  32411. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32412. }
  32413. }
  32414. if (!empty($targetUrl)) {
  32415. $this->redirects++;
  32416. $this->io->writeError('', true, IOInterface::DEBUG);
  32417. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  32418. $additionalOptions['redirects'] = $this->redirects;
  32419. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  32420. }
  32421. if (!$this->retry) {
  32422. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  32423. $e->setHeaders($http_response_header);
  32424. $e->setResponse($this->decodeResult($result, $http_response_header));
  32425. throw $e;
  32426. }
  32427. return false;
  32428. }
  32429. private function getCertificateCnAndFp($url, $options)
  32430. {
  32431. if (PHP_VERSION_ID >= 50600) {
  32432. throw new \BadMethodCallException(sprintf(
  32433. '%s must not be used on PHP >= 5.6',
  32434. __METHOD__
  32435. ));
  32436. }
  32437. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  32438. 'ssl' => array(
  32439. 'capture_peer_cert' => true,
  32440. 'verify_peer' => false,
  32441. ), ),
  32442. ));
  32443. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  32444. return;
  32445. }
  32446. fclose($handle);
  32447. $handle = null;
  32448. $params = stream_context_get_params($context);
  32449. if (!empty($params['options']['ssl']['peer_certificate'])) {
  32450. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  32451. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  32452. return array(
  32453. 'cn' => $commonName,
  32454. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  32455. );
  32456. }
  32457. }
  32458. }
  32459. private function getUrlAuthority($url)
  32460. {
  32461. $defaultPorts = array(
  32462. 'ftp' => 21,
  32463. 'http' => 80,
  32464. 'https' => 443,
  32465. 'ssh2.sftp' => 22,
  32466. 'ssh2.scp' => 22,
  32467. );
  32468. $scheme = parse_url($url, PHP_URL_SCHEME);
  32469. if (!isset($defaultPorts[$scheme])) {
  32470. throw new \InvalidArgumentException(sprintf(
  32471. 'Could not get default port for unknown scheme: %s',
  32472. $scheme
  32473. ));
  32474. }
  32475. $defaultPort = $defaultPorts[$scheme];
  32476. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  32477. return parse_url($url, PHP_URL_HOST).':'.$port;
  32478. }
  32479. private function decodeResult($result, $http_response_header)
  32480. {
  32481. if ($result && extension_loaded('zlib')) {
  32482. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  32483. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  32484. if ($decode) {
  32485. if (PHP_VERSION_ID >= 50400) {
  32486. $result = zlib_decode($result);
  32487. } else {
  32488. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  32489. }
  32490. if ($result === false) {
  32491. throw new TransportException('Failed to decode zlib stream');
  32492. }
  32493. }
  32494. }
  32495. return $result;
  32496. }
  32497. }
  32498. <?php
  32499. namespace Composer\Util;
  32500. class Silencer
  32501. {
  32502. private static $stack = array();
  32503. public static function suppress($mask = null)
  32504. {
  32505. if (!isset($mask)) {
  32506. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  32507. }
  32508. $old = error_reporting();
  32509. self::$stack[] = $old;
  32510. error_reporting($old & ~$mask);
  32511. return $old;
  32512. }
  32513. public static function restore()
  32514. {
  32515. if (!empty(self::$stack)) {
  32516. error_reporting(array_pop(self::$stack));
  32517. }
  32518. }
  32519. public static function call($callable )
  32520. {
  32521. try {
  32522. self::suppress();
  32523. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  32524. self::restore();
  32525. return $result;
  32526. } catch (\Exception $e) {
  32527. self::restore();
  32528. throw $e;
  32529. }
  32530. }
  32531. }
  32532. <?php
  32533. namespace Composer\Util;
  32534. use Composer\Composer;
  32535. use Composer\CaBundle\CaBundle;
  32536. use Composer\Downloader\TransportException;
  32537. use Composer\Util\Http\ProxyManager;
  32538. use Psr\Log\LoggerInterface;
  32539. final class StreamContextFactory
  32540. {
  32541. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  32542. {
  32543. $options = array('http' => array(
  32544. 'follow_location' => 1,
  32545. 'max_redirects' => 20,
  32546. ));
  32547. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  32548. unset($defaultOptions['http']['header']);
  32549. $options = array_replace_recursive($options, $defaultOptions);
  32550. if (isset($options['http']['header'])) {
  32551. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  32552. }
  32553. return stream_context_create($options, $defaultParams);
  32554. }
  32555. public static function initOptions($url, array $options, $forCurl = false)
  32556. {
  32557. if (!isset($options['http']['header'])) {
  32558. $options['http']['header'] = array();
  32559. }
  32560. if (is_string($options['http']['header'])) {
  32561. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  32562. }
  32563. if (!$forCurl) {
  32564. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  32565. if ($proxyOptions = $proxy->getContextOptions()) {
  32566. $isHttpsRequest = 0 === strpos($url, 'https://');
  32567. if ($proxy->isSecure()) {
  32568. if (!extension_loaded('openssl')) {
  32569. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  32570. }
  32571. if ($isHttpsRequest) {
  32572. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  32573. }
  32574. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  32575. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  32576. }
  32577. if (isset($proxyOptions['http']['header'])) {
  32578. $options['http']['header'][] = $proxyOptions['http']['header'];
  32579. unset($proxyOptions['http']['header']);
  32580. }
  32581. $options = array_replace_recursive($options, $proxyOptions);
  32582. }
  32583. }
  32584. if (defined('HHVM_VERSION')) {
  32585. $phpVersion = 'HHVM ' . HHVM_VERSION;
  32586. } else {
  32587. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  32588. }
  32589. if ($forCurl) {
  32590. $curl = curl_version();
  32591. $httpVersion = 'curl '.$curl['version'];
  32592. } else {
  32593. $httpVersion = 'streams';
  32594. }
  32595. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  32596. $options['http']['header'][] = sprintf(
  32597. 'User-Agent: Composer/%s (%s; %s; %s; %s%s)',
  32598. Composer::getVersion(),
  32599. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  32600. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  32601. $phpVersion,
  32602. $httpVersion,
  32603. getenv('CI') ? '; CI' : ''
  32604. );
  32605. }
  32606. return $options;
  32607. }
  32608. public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
  32609. {
  32610. $ciphers = implode(':', array(
  32611. 'ECDHE-RSA-AES128-GCM-SHA256',
  32612. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  32613. 'ECDHE-RSA-AES256-GCM-SHA384',
  32614. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  32615. 'DHE-RSA-AES128-GCM-SHA256',
  32616. 'DHE-DSS-AES128-GCM-SHA256',
  32617. 'kEDH+AESGCM',
  32618. 'ECDHE-RSA-AES128-SHA256',
  32619. 'ECDHE-ECDSA-AES128-SHA256',
  32620. 'ECDHE-RSA-AES128-SHA',
  32621. 'ECDHE-ECDSA-AES128-SHA',
  32622. 'ECDHE-RSA-AES256-SHA384',
  32623. 'ECDHE-ECDSA-AES256-SHA384',
  32624. 'ECDHE-RSA-AES256-SHA',
  32625. 'ECDHE-ECDSA-AES256-SHA',
  32626. 'DHE-RSA-AES128-SHA256',
  32627. 'DHE-RSA-AES128-SHA',
  32628. 'DHE-DSS-AES128-SHA256',
  32629. 'DHE-RSA-AES256-SHA256',
  32630. 'DHE-DSS-AES256-SHA',
  32631. 'DHE-RSA-AES256-SHA',
  32632. 'AES128-GCM-SHA256',
  32633. 'AES256-GCM-SHA384',
  32634. 'AES128-SHA256',
  32635. 'AES256-SHA256',
  32636. 'AES128-SHA',
  32637. 'AES256-SHA',
  32638. 'AES',
  32639. 'CAMELLIA',
  32640. 'DES-CBC3-SHA',
  32641. '!aNULL',
  32642. '!eNULL',
  32643. '!EXPORT',
  32644. '!DES',
  32645. '!RC4',
  32646. '!MD5',
  32647. '!PSK',
  32648. '!aECDH',
  32649. '!EDH-DSS-DES-CBC3-SHA',
  32650. '!EDH-RSA-DES-CBC3-SHA',
  32651. '!KRB5-DES-CBC3-SHA',
  32652. ));
  32653. $defaults = array(
  32654. 'ssl' => array(
  32655. 'ciphers' => $ciphers,
  32656. 'verify_peer' => true,
  32657. 'verify_depth' => 7,
  32658. 'SNI_enabled' => true,
  32659. 'capture_peer_cert' => true,
  32660. ),
  32661. );
  32662. if (isset($options['ssl'])) {
  32663. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  32664. }
  32665. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  32666. $result = CaBundle::getSystemCaRootBundlePath($logger);
  32667. if (is_dir($result)) {
  32668. $defaults['ssl']['capath'] = $result;
  32669. } else {
  32670. $defaults['ssl']['cafile'] = $result;
  32671. }
  32672. }
  32673. if (isset($defaults['ssl']['cafile']) && (!is_readable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  32674. throw new TransportException('The configured cafile was not valid or could not be read.');
  32675. }
  32676. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !is_readable($defaults['ssl']['capath']))) {
  32677. throw new TransportException('The configured capath was not valid or could not be read.');
  32678. }
  32679. if (PHP_VERSION_ID >= 50413) {
  32680. $defaults['ssl']['disable_compression'] = true;
  32681. }
  32682. return $defaults;
  32683. }
  32684. private static function fixHttpHeaderField($header)
  32685. {
  32686. if (!is_array($header)) {
  32687. $header = explode("\r\n", $header);
  32688. }
  32689. uasort($header, function ($el) {
  32690. return stripos($el, 'content-type') === 0 ? 1 : -1;
  32691. });
  32692. return $header;
  32693. }
  32694. }
  32695. <?php
  32696. namespace Composer\Util;
  32697. use Composer\Config;
  32698. use Composer\IO\IOInterface;
  32699. class Svn
  32700. {
  32701. const MAX_QTY_AUTH_TRIES = 5;
  32702. protected $credentials;
  32703. protected $hasAuth;
  32704. protected $io;
  32705. protected $url;
  32706. protected $cacheCredentials = true;
  32707. protected $process;
  32708. protected $qtyAuthTries = 0;
  32709. protected $config;
  32710. private static $version;
  32711. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  32712. {
  32713. $this->url = $url;
  32714. $this->io = $io;
  32715. $this->config = $config;
  32716. $this->process = $process ?: new ProcessExecutor($io);
  32717. }
  32718. public static function cleanEnv()
  32719. {
  32720. putenv("DYLD_LIBRARY_PATH");
  32721. unset($_SERVER['DYLD_LIBRARY_PATH']);
  32722. }
  32723. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  32724. {
  32725. $this->config->prohibitUrlByConfig($url, $this->io);
  32726. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  32727. }
  32728. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  32729. {
  32730. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  32731. }
  32732. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  32733. {
  32734. $command = $this->getCommand($svnCommand, $url, $path);
  32735. $output = null;
  32736. $io = $this->io;
  32737. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  32738. if ($type !== 'out') {
  32739. return;
  32740. }
  32741. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  32742. return;
  32743. }
  32744. $output .= $buffer;
  32745. if ($verbose) {
  32746. $io->writeError($buffer, false);
  32747. }
  32748. };
  32749. $status = $this->process->execute($command, $handler, $cwd);
  32750. if (0 === $status) {
  32751. return $output;
  32752. }
  32753. $errorOutput = $this->process->getErrorOutput();
  32754. $fullOutput = implode("\n", array($output, $errorOutput));
  32755. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  32756. && false === stripos($fullOutput, 'authorization failed')
  32757. && false === stripos($fullOutput, 'svn: E170001:')
  32758. && false === stripos($fullOutput, 'svn: E215004:')) {
  32759. throw new \RuntimeException($fullOutput);
  32760. }
  32761. if (!$this->hasAuth()) {
  32762. $this->doAuthDance();
  32763. }
  32764. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  32765. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  32766. }
  32767. throw new \RuntimeException(
  32768. 'wrong credentials provided ('.$fullOutput.')'
  32769. );
  32770. }
  32771. public function setCacheCredentials($cacheCredentials)
  32772. {
  32773. $this->cacheCredentials = $cacheCredentials;
  32774. }
  32775. protected function doAuthDance()
  32776. {
  32777. if (!$this->io->isInteractive()) {
  32778. throw new \RuntimeException(
  32779. 'can not ask for authentication in non interactive mode'
  32780. );
  32781. }
  32782. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  32783. $this->hasAuth = true;
  32784. $this->credentials['username'] = $this->io->ask("Username: ");
  32785. $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
  32786. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  32787. return $this;
  32788. }
  32789. protected function getCommand($cmd, $url, $path = null)
  32790. {
  32791. $cmd = sprintf(
  32792. '%s %s%s %s',
  32793. $cmd,
  32794. '--non-interactive ',
  32795. $this->getCredentialString(),
  32796. ProcessExecutor::escape($url)
  32797. );
  32798. if ($path) {
  32799. $cmd .= ' ' . ProcessExecutor::escape($path);
  32800. }
  32801. return $cmd;
  32802. }
  32803. protected function getCredentialString()
  32804. {
  32805. if (!$this->hasAuth()) {
  32806. return '';
  32807. }
  32808. return sprintf(
  32809. ' %s--username %s --password %s ',
  32810. $this->getAuthCache(),
  32811. ProcessExecutor::escape($this->getUsername()),
  32812. ProcessExecutor::escape($this->getPassword())
  32813. );
  32814. }
  32815. protected function getPassword()
  32816. {
  32817. if ($this->credentials === null) {
  32818. throw new \LogicException("No svn auth detected.");
  32819. }
  32820. return isset($this->credentials['password']) ? $this->credentials['password'] : '';
  32821. }
  32822. protected function getUsername()
  32823. {
  32824. if ($this->credentials === null) {
  32825. throw new \LogicException("No svn auth detected.");
  32826. }
  32827. return $this->credentials['username'];
  32828. }
  32829. protected function hasAuth()
  32830. {
  32831. if (null !== $this->hasAuth) {
  32832. return $this->hasAuth;
  32833. }
  32834. if (false === $this->createAuthFromConfig()) {
  32835. $this->createAuthFromUrl();
  32836. }
  32837. return (bool) $this->hasAuth;
  32838. }
  32839. protected function getAuthCache()
  32840. {
  32841. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  32842. }
  32843. private function createAuthFromConfig()
  32844. {
  32845. if (!$this->config->has('http-basic')) {
  32846. return $this->hasAuth = false;
  32847. }
  32848. $authConfig = $this->config->get('http-basic');
  32849. $host = parse_url($this->url, PHP_URL_HOST);
  32850. if (isset($authConfig[$host])) {
  32851. $this->credentials['username'] = $authConfig[$host]['username'];
  32852. $this->credentials['password'] = $authConfig[$host]['password'];
  32853. return $this->hasAuth = true;
  32854. }
  32855. return $this->hasAuth = false;
  32856. }
  32857. private function createAuthFromUrl()
  32858. {
  32859. $uri = parse_url($this->url);
  32860. if (empty($uri['user'])) {
  32861. return $this->hasAuth = false;
  32862. }
  32863. $this->credentials['username'] = $uri['user'];
  32864. if (!empty($uri['pass'])) {
  32865. $this->credentials['password'] = $uri['pass'];
  32866. }
  32867. return $this->hasAuth = true;
  32868. }
  32869. public function binaryVersion()
  32870. {
  32871. if (!self::$version) {
  32872. if (0 === $this->process->execute('svn --version', $output)) {
  32873. if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
  32874. self::$version = $match[1];
  32875. }
  32876. }
  32877. }
  32878. return self::$version;
  32879. }
  32880. }
  32881. <?php
  32882. namespace Composer\Util;
  32883. use Composer\Downloader\DownloaderInterface;
  32884. use Composer\Package\PackageInterface;
  32885. use React\Promise\PromiseInterface;
  32886. class SyncHelper
  32887. {
  32888. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, $path, PackageInterface $package, PackageInterface $prevPackage = null)
  32889. {
  32890. $type = $prevPackage ? 'update' : 'install';
  32891. try {
  32892. self::await($loop, $downloader->download($package, $path, $prevPackage));
  32893. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  32894. if ($type === 'update') {
  32895. self::await($loop, $downloader->update($package, $path, $prevPackage));
  32896. } else {
  32897. self::await($loop, $downloader->install($package, $path, $prevPackage));
  32898. }
  32899. } catch (\Exception $e) {
  32900. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  32901. throw $e;
  32902. }
  32903. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  32904. }
  32905. public static function await(Loop $loop, PromiseInterface $promise = null)
  32906. {
  32907. if ($promise) {
  32908. $loop->wait(array($promise));
  32909. }
  32910. }
  32911. }
  32912. <?php
  32913. namespace Composer\Util;
  32914. class Tar
  32915. {
  32916. public static function getComposerJson($pathToArchive)
  32917. {
  32918. $phar = new \PharData($pathToArchive);
  32919. if (!$phar->valid()) {
  32920. return null;
  32921. }
  32922. return self::extractComposerJsonFromFolder($phar);
  32923. }
  32924. private static function extractComposerJsonFromFolder(\PharData $phar)
  32925. {
  32926. if (isset($phar['composer.json'])) {
  32927. return $phar['composer.json']->getContent();
  32928. }
  32929. $topLevelPaths = array();
  32930. foreach ($phar as $folderFile) {
  32931. $name = $folderFile->getBasename();
  32932. if ($folderFile->isDir()) {
  32933. $topLevelPaths[$name] = true;
  32934. if (\count($topLevelPaths) > 1) {
  32935. 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)));
  32936. }
  32937. }
  32938. }
  32939. $composerJsonPath = key($topLevelPaths).'/composer.json';
  32940. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  32941. return $phar[$composerJsonPath]->getContent();
  32942. }
  32943. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  32944. }
  32945. }
  32946. <?php
  32947. namespace Composer\Util;
  32948. use Composer\CaBundle\CaBundle;
  32949. final class TlsHelper
  32950. {
  32951. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  32952. {
  32953. $names = self::getCertificateNames($certificate);
  32954. if (empty($names)) {
  32955. return false;
  32956. }
  32957. $combinedNames = array_merge($names['san'], array($names['cn']));
  32958. $hostname = strtolower($hostname);
  32959. foreach ($combinedNames as $certName) {
  32960. $matcher = self::certNameMatcher($certName);
  32961. if ($matcher && $matcher($hostname)) {
  32962. $cn = $names['cn'];
  32963. return true;
  32964. }
  32965. }
  32966. return false;
  32967. }
  32968. public static function getCertificateNames($certificate)
  32969. {
  32970. if (is_array($certificate)) {
  32971. $info = $certificate;
  32972. } elseif (CaBundle::isOpensslParseSafe()) {
  32973. $info = openssl_x509_parse($certificate, false);
  32974. }
  32975. if (!isset($info['subject']['commonName'])) {
  32976. return null;
  32977. }
  32978. $commonName = strtolower($info['subject']['commonName']);
  32979. $subjectAltNames = array();
  32980. if (isset($info['extensions']['subjectAltName'])) {
  32981. $subjectAltNames = preg_split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  32982. $subjectAltNames = array_filter(array_map(function ($name) {
  32983. if (0 === strpos($name, 'DNS:')) {
  32984. return strtolower(ltrim(substr($name, 4)));
  32985. }
  32986. return null;
  32987. }, $subjectAltNames));
  32988. $subjectAltNames = array_values($subjectAltNames);
  32989. }
  32990. return array(
  32991. 'cn' => $commonName,
  32992. 'san' => $subjectAltNames,
  32993. );
  32994. }
  32995. public static function getCertificateFingerprint($certificate)
  32996. {
  32997. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  32998. $pubkeypem = $pubkeydetails['key'];
  32999. $start = '-----BEGIN PUBLIC KEY-----';
  33000. $end = '-----END PUBLIC KEY-----';
  33001. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  33002. $der = base64_decode($pemtrim);
  33003. return sha1($der);
  33004. }
  33005. public static function isOpensslParseSafe()
  33006. {
  33007. return CaBundle::isOpensslParseSafe();
  33008. }
  33009. private static function certNameMatcher($certName)
  33010. {
  33011. $wildcards = substr_count($certName, '*');
  33012. if (0 === $wildcards) {
  33013. return function ($hostname) use ($certName) {
  33014. return $hostname === $certName;
  33015. };
  33016. }
  33017. if (1 === $wildcards) {
  33018. $components = explode('.', $certName);
  33019. if (3 > count($components)) {
  33020. return;
  33021. }
  33022. $firstComponent = $components[0];
  33023. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  33024. return;
  33025. }
  33026. $wildcardRegex = preg_quote($certName);
  33027. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  33028. $wildcardRegex = "{^{$wildcardRegex}$}";
  33029. return function ($hostname) use ($wildcardRegex) {
  33030. return 1 === preg_match($wildcardRegex, $hostname);
  33031. };
  33032. }
  33033. }
  33034. }
  33035. <?php
  33036. namespace Composer\Util;
  33037. use Composer\Config;
  33038. class Url
  33039. {
  33040. public static function updateDistReference(Config $config, $url, $ref)
  33041. {
  33042. $host = parse_url($url, PHP_URL_HOST);
  33043. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  33044. if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  33045. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33046. } elseif (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  33047. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33048. } elseif (preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  33049. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33050. }
  33051. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  33052. if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  33053. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  33054. }
  33055. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  33056. if (preg_match('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  33057. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  33058. }
  33059. } elseif (in_array($host, $config->get('github-domains'), true)) {
  33060. $url = preg_replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  33061. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  33062. $url = preg_replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  33063. }
  33064. return $url;
  33065. }
  33066. public static function getOrigin(Config $config, $url)
  33067. {
  33068. if (0 === strpos($url, 'file://')) {
  33069. return $url;
  33070. }
  33071. $origin = (string) parse_url($url, PHP_URL_HOST);
  33072. if ($port = parse_url($url, PHP_URL_PORT)) {
  33073. $origin .= ':'.$port;
  33074. }
  33075. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  33076. return 'github.com';
  33077. }
  33078. if ($origin === 'repo.packagist.org') {
  33079. return 'packagist.org';
  33080. }
  33081. if ($origin === '') {
  33082. $origin = $url;
  33083. }
  33084. if (
  33085. is_array($config->get('gitlab-domains'))
  33086. && false === strpos($origin, '/')
  33087. && !in_array($origin, $config->get('gitlab-domains'))
  33088. ) {
  33089. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  33090. if (0 === strpos($gitlabDomain, $origin)) {
  33091. return $gitlabDomain;
  33092. }
  33093. }
  33094. }
  33095. return $origin;
  33096. }
  33097. public static function sanitize($url)
  33098. {
  33099. $url = preg_replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  33100. $url = preg_replace_callback('{(?P<prefix>://|^)(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  33101. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  33102. return $m['prefix'].'***:***@';
  33103. }
  33104. return $m['prefix'].$m['user'].':***@';
  33105. }, $url);
  33106. return $url;
  33107. }
  33108. }
  33109. <?php
  33110. namespace Composer\Util;
  33111. class Zip
  33112. {
  33113. public static function getComposerJson($pathToZip)
  33114. {
  33115. if (!extension_loaded('zip')) {
  33116. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  33117. }
  33118. $zip = new \ZipArchive();
  33119. if ($zip->open($pathToZip) !== true) {
  33120. return null;
  33121. }
  33122. if (0 == $zip->numFiles) {
  33123. $zip->close();
  33124. return null;
  33125. }
  33126. $foundFileIndex = self::locateFile($zip, 'composer.json');
  33127. if (false === $foundFileIndex) {
  33128. $zip->close();
  33129. return null;
  33130. }
  33131. $content = null;
  33132. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  33133. $stream = $zip->getStream($configurationFileName);
  33134. if (false !== $stream) {
  33135. $content = stream_get_contents($stream);
  33136. }
  33137. $zip->close();
  33138. return $content;
  33139. }
  33140. private static function locateFile(\ZipArchive $zip, $filename)
  33141. {
  33142. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  33143. return $index;
  33144. }
  33145. $topLevelPaths = array();
  33146. for ($i = 0; $i < $zip->numFiles; $i++) {
  33147. $name = $zip->getNameIndex($i);
  33148. $dirname = dirname($name);
  33149. if (strpos($name, '__MACOSX') !== false) {
  33150. continue;
  33151. }
  33152. if ($dirname === '.') {
  33153. $topLevelPaths[$name] = true;
  33154. if (\count($topLevelPaths) > 1) {
  33155. 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)));
  33156. }
  33157. continue;
  33158. }
  33159. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  33160. $topLevelPaths[$dirname.'/'] = true;
  33161. if (\count($topLevelPaths) > 1) {
  33162. 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)));
  33163. }
  33164. }
  33165. }
  33166. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  33167. return $index;
  33168. }
  33169. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  33170. }
  33171. }
  33172. <?php
  33173. function includeIfExists($file)
  33174. {
  33175. return file_exists($file) ? include $file : false;
  33176. }
  33177. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  33178. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  33179. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  33180. exit(1);
  33181. }
  33182. return $loader;
  33183. <?php
  33184. /*
  33185. * This file is part of Composer.
  33186. *
  33187. * (c) Nils Adermann <naderman@naderman.de>
  33188. * Jordi Boggiano <j.boggiano@seld.be>
  33189. *
  33190. * For the full copyright and license information, please view the LICENSE
  33191. * file that was distributed with this source code.
  33192. */
  33193. namespace Composer\Autoload;
  33194. /**
  33195. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  33196. *
  33197. * $loader = new \Composer\Autoload\ClassLoader();
  33198. *
  33199. * // register classes with namespaces
  33200. * $loader->add('Symfony\Component', __DIR__.'/component');
  33201. * $loader->add('Symfony', __DIR__.'/framework');
  33202. *
  33203. * // activate the autoloader
  33204. * $loader->register();
  33205. *
  33206. * // to enable searching the include path (eg. for PEAR packages)
  33207. * $loader->setUseIncludePath(true);
  33208. *
  33209. * In this example, if you try to use a class in the Symfony\Component
  33210. * namespace or one of its children (Symfony\Component\Console for instance),
  33211. * the autoloader will first look for the class under the component/
  33212. * directory, and it will then fallback to the framework/ directory if not
  33213. * found before giving up.
  33214. *
  33215. * This class is loosely based on the Symfony UniversalClassLoader.
  33216. *
  33217. * @author Fabien Potencier <fabien@symfony.com>
  33218. * @author Jordi Boggiano <j.boggiano@seld.be>
  33219. * @see https://www.php-fig.org/psr/psr-0/
  33220. * @see https://www.php-fig.org/psr/psr-4/
  33221. */
  33222. class ClassLoader
  33223. {
  33224. // PSR-4
  33225. private $prefixLengthsPsr4 = array();
  33226. private $prefixDirsPsr4 = array();
  33227. private $fallbackDirsPsr4 = array();
  33228. // PSR-0
  33229. private $prefixesPsr0 = array();
  33230. private $fallbackDirsPsr0 = array();
  33231. private $useIncludePath = false;
  33232. private $classMap = array();
  33233. private $classMapAuthoritative = false;
  33234. private $missingClasses = array();
  33235. private $apcuPrefix;
  33236. public function getPrefixes()
  33237. {
  33238. if (!empty($this->prefixesPsr0)) {
  33239. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  33240. }
  33241. return array();
  33242. }
  33243. public function getPrefixesPsr4()
  33244. {
  33245. return $this->prefixDirsPsr4;
  33246. }
  33247. public function getFallbackDirs()
  33248. {
  33249. return $this->fallbackDirsPsr0;
  33250. }
  33251. public function getFallbackDirsPsr4()
  33252. {
  33253. return $this->fallbackDirsPsr4;
  33254. }
  33255. public function getClassMap()
  33256. {
  33257. return $this->classMap;
  33258. }
  33259. /**
  33260. * @param array $classMap Class to filename map
  33261. */
  33262. public function addClassMap(array $classMap)
  33263. {
  33264. if ($this->classMap) {
  33265. $this->classMap = array_merge($this->classMap, $classMap);
  33266. } else {
  33267. $this->classMap = $classMap;
  33268. }
  33269. }
  33270. /**
  33271. * Registers a set of PSR-0 directories for a given prefix, either
  33272. * appending or prepending to the ones previously set for this prefix.
  33273. *
  33274. * @param string $prefix The prefix
  33275. * @param array|string $paths The PSR-0 root directories
  33276. * @param bool $prepend Whether to prepend the directories
  33277. */
  33278. public function add($prefix, $paths, $prepend = false)
  33279. {
  33280. if (!$prefix) {
  33281. if ($prepend) {
  33282. $this->fallbackDirsPsr0 = array_merge(
  33283. (array) $paths,
  33284. $this->fallbackDirsPsr0
  33285. );
  33286. } else {
  33287. $this->fallbackDirsPsr0 = array_merge(
  33288. $this->fallbackDirsPsr0,
  33289. (array) $paths
  33290. );
  33291. }
  33292. return;
  33293. }
  33294. $first = $prefix[0];
  33295. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  33296. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  33297. return;
  33298. }
  33299. if ($prepend) {
  33300. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33301. (array) $paths,
  33302. $this->prefixesPsr0[$first][$prefix]
  33303. );
  33304. } else {
  33305. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33306. $this->prefixesPsr0[$first][$prefix],
  33307. (array) $paths
  33308. );
  33309. }
  33310. }
  33311. /**
  33312. * Registers a set of PSR-4 directories for a given namespace, either
  33313. * appending or prepending to the ones previously set for this namespace.
  33314. *
  33315. * @param string $prefix The prefix/namespace, with trailing '\\'
  33316. * @param array|string $paths The PSR-4 base directories
  33317. * @param bool $prepend Whether to prepend the directories
  33318. *
  33319. * @throws \InvalidArgumentException
  33320. */
  33321. public function addPsr4($prefix, $paths, $prepend = false)
  33322. {
  33323. if (!$prefix) {
  33324. // Register directories for the root namespace.
  33325. if ($prepend) {
  33326. $this->fallbackDirsPsr4 = array_merge(
  33327. (array) $paths,
  33328. $this->fallbackDirsPsr4
  33329. );
  33330. } else {
  33331. $this->fallbackDirsPsr4 = array_merge(
  33332. $this->fallbackDirsPsr4,
  33333. (array) $paths
  33334. );
  33335. }
  33336. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  33337. // Register directories for a new namespace.
  33338. $length = strlen($prefix);
  33339. if ('\\' !== $prefix[$length - 1]) {
  33340. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33341. }
  33342. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33343. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33344. } elseif ($prepend) {
  33345. // Prepend directories for an already registered namespace.
  33346. $this->prefixDirsPsr4[$prefix] = array_merge(
  33347. (array) $paths,
  33348. $this->prefixDirsPsr4[$prefix]
  33349. );
  33350. } else {
  33351. // Append directories for an already registered namespace.
  33352. $this->prefixDirsPsr4[$prefix] = array_merge(
  33353. $this->prefixDirsPsr4[$prefix],
  33354. (array) $paths
  33355. );
  33356. }
  33357. }
  33358. /**
  33359. * Registers a set of PSR-0 directories for a given prefix,
  33360. * replacing any others previously set for this prefix.
  33361. *
  33362. * @param string $prefix The prefix
  33363. * @param array|string $paths The PSR-0 base directories
  33364. */
  33365. public function set($prefix, $paths)
  33366. {
  33367. if (!$prefix) {
  33368. $this->fallbackDirsPsr0 = (array) $paths;
  33369. } else {
  33370. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  33371. }
  33372. }
  33373. /**
  33374. * Registers a set of PSR-4 directories for a given namespace,
  33375. * replacing any others previously set for this namespace.
  33376. *
  33377. * @param string $prefix The prefix/namespace, with trailing '\\'
  33378. * @param array|string $paths The PSR-4 base directories
  33379. *
  33380. * @throws \InvalidArgumentException
  33381. */
  33382. public function setPsr4($prefix, $paths)
  33383. {
  33384. if (!$prefix) {
  33385. $this->fallbackDirsPsr4 = (array) $paths;
  33386. } else {
  33387. $length = strlen($prefix);
  33388. if ('\\' !== $prefix[$length - 1]) {
  33389. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33390. }
  33391. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33392. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33393. }
  33394. }
  33395. /**
  33396. * Turns on searching the include path for class files.
  33397. *
  33398. * @param bool $useIncludePath
  33399. */
  33400. public function setUseIncludePath($useIncludePath)
  33401. {
  33402. $this->useIncludePath = $useIncludePath;
  33403. }
  33404. /**
  33405. * Can be used to check if the autoloader uses the include path to check
  33406. * for classes.
  33407. *
  33408. * @return bool
  33409. */
  33410. public function getUseIncludePath()
  33411. {
  33412. return $this->useIncludePath;
  33413. }
  33414. /**
  33415. * Turns off searching the prefix and fallback directories for classes
  33416. * that have not been registered with the class map.
  33417. *
  33418. * @param bool $classMapAuthoritative
  33419. */
  33420. public function setClassMapAuthoritative($classMapAuthoritative)
  33421. {
  33422. $this->classMapAuthoritative = $classMapAuthoritative;
  33423. }
  33424. /**
  33425. * Should class lookup fail if not found in the current class map?
  33426. *
  33427. * @return bool
  33428. */
  33429. public function isClassMapAuthoritative()
  33430. {
  33431. return $this->classMapAuthoritative;
  33432. }
  33433. /**
  33434. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  33435. *
  33436. * @param string|null $apcuPrefix
  33437. */
  33438. public function setApcuPrefix($apcuPrefix)
  33439. {
  33440. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  33441. }
  33442. /**
  33443. * The APCu prefix in use, or null if APCu caching is not enabled.
  33444. *
  33445. * @return string|null
  33446. */
  33447. public function getApcuPrefix()
  33448. {
  33449. return $this->apcuPrefix;
  33450. }
  33451. /**
  33452. * Registers this instance as an autoloader.
  33453. *
  33454. * @param bool $prepend Whether to prepend the autoloader or not
  33455. */
  33456. public function register($prepend = false)
  33457. {
  33458. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  33459. }
  33460. /**
  33461. * Unregisters this instance as an autoloader.
  33462. */
  33463. public function unregister()
  33464. {
  33465. spl_autoload_unregister(array($this, 'loadClass'));
  33466. }
  33467. /**
  33468. * Loads the given class or interface.
  33469. *
  33470. * @param string $class The name of the class
  33471. * @return bool|null True if loaded, null otherwise
  33472. */
  33473. public function loadClass($class)
  33474. {
  33475. if ($file = $this->findFile($class)) {
  33476. includeFile($file);
  33477. return true;
  33478. }
  33479. }
  33480. /**
  33481. * Finds the path to the file where the class is defined.
  33482. *
  33483. * @param string $class The name of the class
  33484. *
  33485. * @return string|false The path if found, false otherwise
  33486. */
  33487. public function findFile($class)
  33488. {
  33489. // class map lookup
  33490. if (isset($this->classMap[$class])) {
  33491. return $this->classMap[$class];
  33492. }
  33493. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  33494. return false;
  33495. }
  33496. if (null !== $this->apcuPrefix) {
  33497. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  33498. if ($hit) {
  33499. return $file;
  33500. }
  33501. }
  33502. $file = $this->findFileWithExtension($class, '.php');
  33503. // Search for Hack files if we are running on HHVM
  33504. if (false === $file && defined('HHVM_VERSION')) {
  33505. $file = $this->findFileWithExtension($class, '.hh');
  33506. }
  33507. if (null !== $this->apcuPrefix) {
  33508. apcu_add($this->apcuPrefix.$class, $file);
  33509. }
  33510. if (false === $file) {
  33511. // Remember that this class does not exist.
  33512. $this->missingClasses[$class] = true;
  33513. }
  33514. return $file;
  33515. }
  33516. private function findFileWithExtension($class, $ext)
  33517. {
  33518. // PSR-4 lookup
  33519. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  33520. $first = $class[0];
  33521. if (isset($this->prefixLengthsPsr4[$first])) {
  33522. $subPath = $class;
  33523. while (false !== $lastPos = strrpos($subPath, '\\')) {
  33524. $subPath = substr($subPath, 0, $lastPos);
  33525. $search = $subPath . '\\';
  33526. if (isset($this->prefixDirsPsr4[$search])) {
  33527. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  33528. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  33529. if (file_exists($file = $dir . $pathEnd)) {
  33530. return $file;
  33531. }
  33532. }
  33533. }
  33534. }
  33535. }
  33536. // PSR-4 fallback dirs
  33537. foreach ($this->fallbackDirsPsr4 as $dir) {
  33538. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  33539. return $file;
  33540. }
  33541. }
  33542. // PSR-0 lookup
  33543. if (false !== $pos = strrpos($class, '\\')) {
  33544. // namespaced class name
  33545. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  33546. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  33547. } else {
  33548. // PEAR-like class name
  33549. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  33550. }
  33551. if (isset($this->prefixesPsr0[$first])) {
  33552. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  33553. if (0 === strpos($class, $prefix)) {
  33554. foreach ($dirs as $dir) {
  33555. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33556. return $file;
  33557. }
  33558. }
  33559. }
  33560. }
  33561. }
  33562. // PSR-0 fallback dirs
  33563. foreach ($this->fallbackDirsPsr0 as $dir) {
  33564. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33565. return $file;
  33566. }
  33567. }
  33568. // PSR-0 include paths.
  33569. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  33570. return $file;
  33571. }
  33572. return false;
  33573. }
  33574. }
  33575. /**
  33576. * Scope isolated include.
  33577. *
  33578. * Prevents access to $this/self from included files.
  33579. */
  33580. function includeFile($file)
  33581. {
  33582. include $file;
  33583. }
  33584. {
  33585. "$schema": "https://json-schema.org/draft-04/schema#",
  33586. "description": "A representation of packages metadata.",
  33587. "type": "object",
  33588. "oneOf": [
  33589. { "required": [ "packages" ] },
  33590. { "required": [ "providers" ] },
  33591. { "required": [ "provider-includes", "providers-url" ] }
  33592. ],
  33593. "properties": {
  33594. "packages": {
  33595. "type": ["object", "array"],
  33596. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33597. "additionalProperties": { "$ref": "#/definitions/versions" }
  33598. },
  33599. "providers-url": {
  33600. "type": "string",
  33601. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  33602. },
  33603. "provider-includes": {
  33604. "type": "object",
  33605. "description": "A hashmap of provider listings.",
  33606. "additionalProperties": { "$ref": "#/definitions/provider" }
  33607. },
  33608. "providers": {
  33609. "type": "object",
  33610. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33611. "additionalProperties": { "$ref": "#/definitions/provider" }
  33612. },
  33613. "notify-batch": {
  33614. "type": "string",
  33615. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  33616. },
  33617. "search": {
  33618. "type": "string",
  33619. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  33620. },
  33621. "warning": {
  33622. "type": "string",
  33623. "description": "A message that will be output by Composer as a warning when this source is consulted."
  33624. }
  33625. },
  33626. "definitions": {
  33627. "versions": {
  33628. "type": "object",
  33629. "description": "A hashmap of versions and their metadata.",
  33630. "additionalProperties": { "$ref": "#/definitions/version" }
  33631. },
  33632. "version": {
  33633. "type": "object",
  33634. "oneOf": [
  33635. { "$ref": "#/definitions/package" },
  33636. { "$ref": "#/definitions/metapackage" }
  33637. ]
  33638. },
  33639. "package-base": {
  33640. "properties": {
  33641. "name": { "type": "string" },
  33642. "type": { "type": "string" },
  33643. "version": { "type": "string" },
  33644. "version_normalized": {
  33645. "type": "string",
  33646. "description": "Normalized version, optional but can save computational time on client side."
  33647. },
  33648. "autoload": { "type": "object" },
  33649. "require": { "type": "object" },
  33650. "replace": { "type": "object" },
  33651. "conflict": { "type": "object" },
  33652. "provide": { "type": "object" },
  33653. "time": { "type": "string" }
  33654. },
  33655. "additionalProperties": true
  33656. },
  33657. "package": {
  33658. "allOf": [
  33659. { "$ref": "#/definitions/package-base" },
  33660. {
  33661. "properties": {
  33662. "dist": { "type": "object" },
  33663. "source": { "type": "object" }
  33664. }
  33665. },
  33666. { "oneOf": [
  33667. { "required": [ "name", "version", "source" ] },
  33668. { "required": [ "name", "version", "dist" ] }
  33669. ] }
  33670. ]
  33671. },
  33672. "metapackage": {
  33673. "allOf": [
  33674. { "$ref": "#/definitions/package-base" },
  33675. {
  33676. "properties": {
  33677. "type": { "type": "string", "enum": [ "metapackage" ] }
  33678. },
  33679. "required": [ "name", "version", "type" ]
  33680. }
  33681. ]
  33682. },
  33683. "provider": {
  33684. "type": "object",
  33685. "properties": {
  33686. "sha256": {
  33687. "type": "string",
  33688. "description": "Hash value that can be used to validate the resource."
  33689. }
  33690. }
  33691. }
  33692. }
  33693. }
  33694. {
  33695. "$schema": "https://json-schema.org/draft-04/schema#",
  33696. "name": "Package",
  33697. "type": "object",
  33698. "additionalProperties": false,
  33699. "required": [ "name", "description" ],
  33700. "properties": {
  33701. "name": {
  33702. "type": "string",
  33703. "description": "Package name, including 'vendor-name/' prefix.",
  33704. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  33705. },
  33706. "type": {
  33707. "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.",
  33708. "type": "string",
  33709. "pattern": "^[a-z0-9-]+$"
  33710. },
  33711. "target-dir": {
  33712. "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.",
  33713. "type": "string"
  33714. },
  33715. "description": {
  33716. "type": "string",
  33717. "description": "Short package description."
  33718. },
  33719. "keywords": {
  33720. "type": "array",
  33721. "items": {
  33722. "type": "string",
  33723. "description": "A tag/keyword that this package relates to."
  33724. }
  33725. },
  33726. "homepage": {
  33727. "type": "string",
  33728. "description": "Homepage URL for the project.",
  33729. "format": "uri"
  33730. },
  33731. "readme": {
  33732. "type": "string",
  33733. "description": "Relative path to the readme document."
  33734. },
  33735. "version": {
  33736. "type": "string",
  33737. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  33738. "pattern": "^v?\\d+(((\\.\\d+)?\\.\\d+)?\\.\\d+)?|^dev-"
  33739. },
  33740. "time": {
  33741. "type": "string",
  33742. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  33743. },
  33744. "license": {
  33745. "type": ["string", "array"],
  33746. "description": "License name. Or an array of license names."
  33747. },
  33748. "authors": {
  33749. "$ref": "#/definitions/authors"
  33750. },
  33751. "require": {
  33752. "type": "object",
  33753. "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
  33754. "additionalProperties": {
  33755. "type": "string"
  33756. }
  33757. },
  33758. "replace": {
  33759. "type": "object",
  33760. "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
  33761. "additionalProperties": {
  33762. "type": "string"
  33763. }
  33764. },
  33765. "conflict": {
  33766. "type": "object",
  33767. "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
  33768. "additionalProperties": {
  33769. "type": "string"
  33770. }
  33771. },
  33772. "provide": {
  33773. "type": "object",
  33774. "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  33775. "additionalProperties": {
  33776. "type": "string"
  33777. }
  33778. },
  33779. "require-dev": {
  33780. "type": "object",
  33781. "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  33782. "additionalProperties": {
  33783. "type": "string"
  33784. }
  33785. },
  33786. "suggest": {
  33787. "type": "object",
  33788. "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).",
  33789. "additionalProperties": {
  33790. "type": "string"
  33791. }
  33792. },
  33793. "config": {
  33794. "type": "object",
  33795. "description": "Composer options.",
  33796. "properties": {
  33797. "process-timeout": {
  33798. "type": "integer",
  33799. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  33800. },
  33801. "use-include-path": {
  33802. "type": "boolean",
  33803. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  33804. },
  33805. "preferred-install": {
  33806. "type": ["string", "object"],
  33807. "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\"}."
  33808. },
  33809. "notify-on-install": {
  33810. "type": "boolean",
  33811. "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."
  33812. },
  33813. "github-protocols": {
  33814. "type": "array",
  33815. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  33816. "items": {
  33817. "type": "string"
  33818. }
  33819. },
  33820. "github-oauth": {
  33821. "type": "object",
  33822. "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  33823. "additionalProperties": {
  33824. "type": "string"
  33825. }
  33826. },
  33827. "gitlab-oauth": {
  33828. "type": "object",
  33829. "description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  33830. "additionalProperties": {
  33831. "type": "string"
  33832. }
  33833. },
  33834. "gitlab-token": {
  33835. "type": "object",
  33836. "description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  33837. "additionalProperties": {
  33838. "type": "string"
  33839. }
  33840. },
  33841. "bearer": {
  33842. "type": "object",
  33843. "description": "A hash of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  33844. "additionalProperties": {
  33845. "type": "string"
  33846. }
  33847. },
  33848. "disable-tls": {
  33849. "type": "boolean",
  33850. "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."
  33851. },
  33852. "secure-http": {
  33853. "type": "boolean",
  33854. "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."
  33855. },
  33856. "cafile": {
  33857. "type": "string",
  33858. "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."
  33859. },
  33860. "capath": {
  33861. "type": "string",
  33862. "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."
  33863. },
  33864. "http-basic": {
  33865. "type": "object",
  33866. "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  33867. "additionalProperties": {
  33868. "type": "object",
  33869. "required": ["username", "password"],
  33870. "properties": {
  33871. "username": {
  33872. "type": "string",
  33873. "description": "The username used for HTTP Basic authentication"
  33874. },
  33875. "password": {
  33876. "type": "string",
  33877. "description": "The password used for HTTP Basic authentication"
  33878. }
  33879. }
  33880. }
  33881. },
  33882. "store-auths": {
  33883. "type": ["string", "boolean"],
  33884. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  33885. },
  33886. "platform": {
  33887. "type": "object",
  33888. "description": "This is a hash of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  33889. "additionalProperties": {
  33890. "type": "string"
  33891. }
  33892. },
  33893. "vendor-dir": {
  33894. "type": "string",
  33895. "description": "The location where all packages are installed, defaults to \"vendor\"."
  33896. },
  33897. "bin-dir": {
  33898. "type": "string",
  33899. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  33900. },
  33901. "data-dir": {
  33902. "type": "string",
  33903. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  33904. },
  33905. "cache-dir": {
  33906. "type": "string",
  33907. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  33908. },
  33909. "cache-files-dir": {
  33910. "type": "string",
  33911. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  33912. },
  33913. "cache-repo-dir": {
  33914. "type": "string",
  33915. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  33916. },
  33917. "cache-vcs-dir": {
  33918. "type": "string",
  33919. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  33920. },
  33921. "cache-ttl": {
  33922. "type": "integer",
  33923. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  33924. },
  33925. "cache-files-ttl": {
  33926. "type": "integer",
  33927. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  33928. },
  33929. "cache-files-maxsize": {
  33930. "type": ["string", "integer"],
  33931. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  33932. },
  33933. "cache-read-only": {
  33934. "type": ["boolean"],
  33935. "description": "Whether to use the Composer cache in read-only mode."
  33936. },
  33937. "bin-compat": {
  33938. "enum": ["auto", "full"],
  33939. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)."
  33940. },
  33941. "discard-changes": {
  33942. "type": ["string", "boolean"],
  33943. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  33944. },
  33945. "autoloader-suffix": {
  33946. "type": "string",
  33947. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  33948. },
  33949. "optimize-autoloader": {
  33950. "type": "boolean",
  33951. "description": "Always optimize when dumping the autoloader."
  33952. },
  33953. "prepend-autoloader": {
  33954. "type": "boolean",
  33955. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  33956. },
  33957. "classmap-authoritative": {
  33958. "type": "boolean",
  33959. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  33960. },
  33961. "apcu-autoloader": {
  33962. "type": "boolean",
  33963. "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."
  33964. },
  33965. "github-domains": {
  33966. "type": "array",
  33967. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  33968. "items": {
  33969. "type": "string"
  33970. }
  33971. },
  33972. "github-expose-hostname": {
  33973. "type": "boolean",
  33974. "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."
  33975. },
  33976. "gitlab-domains": {
  33977. "type": "array",
  33978. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  33979. "items": {
  33980. "type": "string"
  33981. }
  33982. },
  33983. "use-github-api": {
  33984. "type": "boolean",
  33985. "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."
  33986. },
  33987. "archive-format": {
  33988. "type": "string",
  33989. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  33990. },
  33991. "archive-dir": {
  33992. "type": "string",
  33993. "description": "The default archive path when not provided on cli, defaults to \".\"."
  33994. },
  33995. "htaccess-protect": {
  33996. "type": "boolean",
  33997. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  33998. },
  33999. "sort-packages": {
  34000. "type": "boolean",
  34001. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  34002. },
  34003. "lock": {
  34004. "type": "boolean",
  34005. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  34006. },
  34007. "platform-check": {
  34008. "type": ["boolean", "string"],
  34009. "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."
  34010. }
  34011. }
  34012. },
  34013. "extra": {
  34014. "type": ["object", "array"],
  34015. "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.",
  34016. "additionalProperties": true
  34017. },
  34018. "autoload": {
  34019. "$ref": "#/definitions/autoload"
  34020. },
  34021. "autoload-dev": {
  34022. "type": "object",
  34023. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  34024. "properties": {
  34025. "psr-0": {
  34026. "type": "object",
  34027. "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.",
  34028. "additionalProperties": {
  34029. "type": ["string", "array"],
  34030. "items": {
  34031. "type": "string"
  34032. }
  34033. }
  34034. },
  34035. "psr-4": {
  34036. "type": "object",
  34037. "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.",
  34038. "additionalProperties": {
  34039. "type": ["string", "array"],
  34040. "items": {
  34041. "type": "string"
  34042. }
  34043. }
  34044. },
  34045. "classmap": {
  34046. "type": "array",
  34047. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34048. },
  34049. "files": {
  34050. "type": "array",
  34051. "description": "This is an array of files that are always required on every request."
  34052. }
  34053. }
  34054. },
  34055. "archive": {
  34056. "type": ["object"],
  34057. "description": "Options for creating package archives for distribution.",
  34058. "properties": {
  34059. "name": {
  34060. "type": "string",
  34061. "description": "A base name for archive."
  34062. },
  34063. "exclude": {
  34064. "type": "array",
  34065. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  34066. }
  34067. }
  34068. },
  34069. "repositories": {
  34070. "type": ["object", "array"],
  34071. "description": "A set of additional repositories where packages can be found.",
  34072. "additionalProperties": {
  34073. "anyOf": [
  34074. { "$ref": "#/definitions/repository" },
  34075. { "type": "boolean", "enum": [false] }
  34076. ]
  34077. },
  34078. "items": {
  34079. "anyOf": [
  34080. { "$ref": "#/definitions/repository" },
  34081. {
  34082. "type": "object",
  34083. "additionalProperties": { "type": "boolean", "enum": [false] },
  34084. "minProperties": 1,
  34085. "maxProperties": 1
  34086. }
  34087. ]
  34088. }
  34089. },
  34090. "minimum-stability": {
  34091. "type": ["string"],
  34092. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  34093. "pattern": "^dev|alpha|beta|rc|RC|stable$"
  34094. },
  34095. "prefer-stable": {
  34096. "type": ["boolean"],
  34097. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  34098. },
  34099. "bin": {
  34100. "type": ["string", "array"],
  34101. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34102. "items": {
  34103. "type": "string"
  34104. }
  34105. },
  34106. "include-path": {
  34107. "type": ["array"],
  34108. "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.",
  34109. "items": {
  34110. "type": "string"
  34111. }
  34112. },
  34113. "scripts": {
  34114. "type": ["object"],
  34115. "description": "Script listeners that will be executed before/after some events.",
  34116. "properties": {
  34117. "pre-install-cmd": {
  34118. "type": ["array", "string"],
  34119. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  34120. },
  34121. "post-install-cmd": {
  34122. "type": ["array", "string"],
  34123. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  34124. },
  34125. "pre-update-cmd": {
  34126. "type": ["array", "string"],
  34127. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  34128. },
  34129. "post-update-cmd": {
  34130. "type": ["array", "string"],
  34131. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  34132. },
  34133. "pre-status-cmd": {
  34134. "type": ["array", "string"],
  34135. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  34136. },
  34137. "post-status-cmd": {
  34138. "type": ["array", "string"],
  34139. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  34140. },
  34141. "pre-package-install": {
  34142. "type": ["array", "string"],
  34143. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  34144. },
  34145. "post-package-install": {
  34146. "type": ["array", "string"],
  34147. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  34148. },
  34149. "pre-package-update": {
  34150. "type": ["array", "string"],
  34151. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  34152. },
  34153. "post-package-update": {
  34154. "type": ["array", "string"],
  34155. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  34156. },
  34157. "pre-package-uninstall": {
  34158. "type": ["array", "string"],
  34159. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34160. },
  34161. "post-package-uninstall": {
  34162. "type": ["array", "string"],
  34163. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34164. },
  34165. "pre-autoload-dump": {
  34166. "type": ["array", "string"],
  34167. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34168. },
  34169. "post-autoload-dump": {
  34170. "type": ["array", "string"],
  34171. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34172. },
  34173. "post-root-package-install": {
  34174. "type": ["array", "string"],
  34175. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  34176. },
  34177. "post-create-project-cmd": {
  34178. "type": ["array", "string"],
  34179. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  34180. }
  34181. }
  34182. },
  34183. "scripts-descriptions": {
  34184. "type": ["object"],
  34185. "description": "Descriptions for custom commands, shown in console help.",
  34186. "additionalProperties": {
  34187. "type": "string"
  34188. }
  34189. },
  34190. "support": {
  34191. "type": "object",
  34192. "properties": {
  34193. "email": {
  34194. "type": "string",
  34195. "description": "Email address for support.",
  34196. "format": "email"
  34197. },
  34198. "issues": {
  34199. "type": "string",
  34200. "description": "URL to the issue tracker.",
  34201. "format": "uri"
  34202. },
  34203. "forum": {
  34204. "type": "string",
  34205. "description": "URL to the forum.",
  34206. "format": "uri"
  34207. },
  34208. "wiki": {
  34209. "type": "string",
  34210. "description": "URL to the wiki.",
  34211. "format": "uri"
  34212. },
  34213. "irc": {
  34214. "type": "string",
  34215. "description": "IRC channel for support, as irc://server/channel.",
  34216. "format": "uri"
  34217. },
  34218. "chat": {
  34219. "type": "string",
  34220. "description": "URL to the support chat.",
  34221. "format": "uri"
  34222. },
  34223. "source": {
  34224. "type": "string",
  34225. "description": "URL to browse or download the sources.",
  34226. "format": "uri"
  34227. },
  34228. "docs": {
  34229. "type": "string",
  34230. "description": "URL to the documentation.",
  34231. "format": "uri"
  34232. },
  34233. "rss": {
  34234. "type": "string",
  34235. "description": "URL to the RSS feed.",
  34236. "format": "uri"
  34237. }
  34238. }
  34239. },
  34240. "funding": {
  34241. "type": "array",
  34242. "description": "A list of options to fund the development and maintenance of the package.",
  34243. "items": {
  34244. "type": "object",
  34245. "properties": {
  34246. "type": {
  34247. "type": "string",
  34248. "description": "Type of funding or platform through which funding is possible."
  34249. },
  34250. "url": {
  34251. "type": "string",
  34252. "description": "URL to a website with details on funding and a way to fund the package.",
  34253. "format": "uri"
  34254. }
  34255. }
  34256. }
  34257. },
  34258. "non-feature-branches": {
  34259. "type": ["array"],
  34260. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  34261. "items": {
  34262. "type": "string"
  34263. }
  34264. },
  34265. "default-branch": {
  34266. "type": ["boolean"],
  34267. "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."
  34268. },
  34269. "abandoned": {
  34270. "type": ["boolean", "string"],
  34271. "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."
  34272. },
  34273. "_comment": {
  34274. "type": ["array", "string"],
  34275. "description": "A key to store comments in"
  34276. }
  34277. },
  34278. "definitions": {
  34279. "authors": {
  34280. "type": "array",
  34281. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  34282. "items": {
  34283. "type": "object",
  34284. "additionalProperties": false,
  34285. "required": [ "name"],
  34286. "properties": {
  34287. "name": {
  34288. "type": "string",
  34289. "description": "Full name of the author."
  34290. },
  34291. "email": {
  34292. "type": "string",
  34293. "description": "Email address of the author.",
  34294. "format": "email"
  34295. },
  34296. "homepage": {
  34297. "type": "string",
  34298. "description": "Homepage URL for the author.",
  34299. "format": "uri"
  34300. },
  34301. "role": {
  34302. "type": "string",
  34303. "description": "Author's role in the project."
  34304. }
  34305. }
  34306. }
  34307. },
  34308. "autoload": {
  34309. "type": "object",
  34310. "description": "Description of how the package can be autoloaded.",
  34311. "properties": {
  34312. "psr-0": {
  34313. "type": "object",
  34314. "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.",
  34315. "additionalProperties": {
  34316. "type": ["string", "array"],
  34317. "items": {
  34318. "type": "string"
  34319. }
  34320. }
  34321. },
  34322. "psr-4": {
  34323. "type": "object",
  34324. "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.",
  34325. "additionalProperties": {
  34326. "type": ["string", "array"],
  34327. "items": {
  34328. "type": "string"
  34329. }
  34330. }
  34331. },
  34332. "classmap": {
  34333. "type": "array",
  34334. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34335. },
  34336. "files": {
  34337. "type": "array",
  34338. "description": "This is an array of files that are always required on every request."
  34339. },
  34340. "exclude-from-classmap": {
  34341. "type": "array",
  34342. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  34343. }
  34344. }
  34345. },
  34346. "repository": {
  34347. "type": "object",
  34348. "anyOf": [
  34349. { "$ref": "#/definitions/composer-repository" },
  34350. { "$ref": "#/definitions/vcs-repository" },
  34351. { "$ref": "#/definitions/path-repository" },
  34352. { "$ref": "#/definitions/artifact-repository" },
  34353. { "$ref": "#/definitions/pear-repository" },
  34354. { "$ref": "#/definitions/package-repository" }
  34355. ]
  34356. },
  34357. "composer-repository": {
  34358. "type": "object",
  34359. "required": ["type", "url"],
  34360. "properties": {
  34361. "type": { "type": "string", "enum": ["composer"] },
  34362. "url": { "type": "string" },
  34363. "canonical": { "type": "boolean" },
  34364. "only": {
  34365. "type": "array",
  34366. "items": {
  34367. "type": "string"
  34368. }
  34369. },
  34370. "exclude": {
  34371. "type": "array",
  34372. "items": {
  34373. "type": "string"
  34374. }
  34375. },
  34376. "options": {
  34377. "type": "object",
  34378. "additionalProperties": true
  34379. },
  34380. "allow_ssl_downgrade": { "type": "boolean" },
  34381. "force-lazy-providers": { "type": "boolean" }
  34382. }
  34383. },
  34384. "vcs-repository": {
  34385. "type": "object",
  34386. "required": ["type", "url"],
  34387. "properties": {
  34388. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] },
  34389. "url": { "type": "string" },
  34390. "canonical": { "type": "boolean" },
  34391. "only": {
  34392. "type": "array",
  34393. "items": {
  34394. "type": "string"
  34395. }
  34396. },
  34397. "exclude": {
  34398. "type": "array",
  34399. "items": {
  34400. "type": "string"
  34401. }
  34402. },
  34403. "no-api": { "type": "boolean" },
  34404. "secure-http": { "type": "boolean" },
  34405. "svn-cache-credentials": { "type": "boolean" },
  34406. "trunk-path": { "type": ["string", "boolean"] },
  34407. "branches-path": { "type": ["string", "boolean"] },
  34408. "tags-path": { "type": ["string", "boolean"] },
  34409. "package-path": { "type": "string" },
  34410. "depot": { "type": "string" },
  34411. "branch": { "type": "string" },
  34412. "unique_perforce_client_name": { "type": "string" },
  34413. "p4user": { "type": "string" },
  34414. "p4password": { "type": "string" }
  34415. }
  34416. },
  34417. "path-repository": {
  34418. "type": "object",
  34419. "required": ["type", "url"],
  34420. "properties": {
  34421. "type": { "type": "string", "enum": ["path"] },
  34422. "url": { "type": "string" },
  34423. "canonical": { "type": "boolean" },
  34424. "only": {
  34425. "type": "array",
  34426. "items": {
  34427. "type": "string"
  34428. }
  34429. },
  34430. "exclude": {
  34431. "type": "array",
  34432. "items": {
  34433. "type": "string"
  34434. }
  34435. },
  34436. "options": {
  34437. "type": "object",
  34438. "properties": {
  34439. "symlink": { "type": ["boolean", "null"] }
  34440. },
  34441. "additionalProperties": true
  34442. }
  34443. }
  34444. },
  34445. "artifact-repository": {
  34446. "type": "object",
  34447. "required": ["type", "url"],
  34448. "properties": {
  34449. "type": { "type": "string", "enum": ["artifact"] },
  34450. "url": { "type": "string" },
  34451. "canonical": { "type": "boolean" },
  34452. "only": {
  34453. "type": "array",
  34454. "items": {
  34455. "type": "string"
  34456. }
  34457. },
  34458. "exclude": {
  34459. "type": "array",
  34460. "items": {
  34461. "type": "string"
  34462. }
  34463. }
  34464. }
  34465. },
  34466. "pear-repository": {
  34467. "type": "object",
  34468. "required": ["type", "url"],
  34469. "properties": {
  34470. "type": { "type": "string", "enum": ["pear"] },
  34471. "url": { "type": "string" },
  34472. "canonical": { "type": "boolean" },
  34473. "only": {
  34474. "type": "array",
  34475. "items": {
  34476. "type": "string"
  34477. }
  34478. },
  34479. "exclude": {
  34480. "type": "array",
  34481. "items": {
  34482. "type": "string"
  34483. }
  34484. },
  34485. "vendor-alias": { "type": "string" }
  34486. }
  34487. },
  34488. "package-repository": {
  34489. "type": "object",
  34490. "required": ["type", "package"],
  34491. "properties": {
  34492. "type": { "type": "string", "enum": ["package"] },
  34493. "canonical": { "type": "boolean" },
  34494. "only": {
  34495. "type": "array",
  34496. "items": {
  34497. "type": "string"
  34498. }
  34499. },
  34500. "exclude": {
  34501. "type": "array",
  34502. "items": {
  34503. "type": "string"
  34504. }
  34505. },
  34506. "package": {
  34507. "oneOf": [
  34508. { "$ref": "#/definitions/inline-package" },
  34509. {
  34510. "type": "array",
  34511. "items": { "$ref": "#/definitions/inline-package" }
  34512. }
  34513. ]
  34514. }
  34515. }
  34516. },
  34517. "inline-package": {
  34518. "type": "object",
  34519. "required": ["name", "version"],
  34520. "properties": {
  34521. "name": {
  34522. "type": "string",
  34523. "description": "Package name, including 'vendor-name/' prefix."
  34524. },
  34525. "type": {
  34526. "type": "string"
  34527. },
  34528. "target-dir": {
  34529. "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.",
  34530. "type": "string"
  34531. },
  34532. "description": {
  34533. "type": "string"
  34534. },
  34535. "keywords": {
  34536. "type": "array",
  34537. "items": {
  34538. "type": "string"
  34539. }
  34540. },
  34541. "homepage": {
  34542. "type": "string",
  34543. "format": "uri"
  34544. },
  34545. "version": {
  34546. "type": "string"
  34547. },
  34548. "time": {
  34549. "type": "string"
  34550. },
  34551. "license": {
  34552. "type": [
  34553. "string",
  34554. "array"
  34555. ]
  34556. },
  34557. "authors": {
  34558. "$ref": "#/definitions/authors"
  34559. },
  34560. "require": {
  34561. "type": "object",
  34562. "additionalProperties": {
  34563. "type": "string"
  34564. }
  34565. },
  34566. "replace": {
  34567. "type": "object",
  34568. "additionalProperties": {
  34569. "type": "string"
  34570. }
  34571. },
  34572. "conflict": {
  34573. "type": "object",
  34574. "additionalProperties": {
  34575. "type": "string"
  34576. }
  34577. },
  34578. "provide": {
  34579. "type": "object",
  34580. "additionalProperties": {
  34581. "type": "string"
  34582. }
  34583. },
  34584. "require-dev": {
  34585. "type": "object",
  34586. "additionalProperties": {
  34587. "type": "string"
  34588. }
  34589. },
  34590. "suggest": {
  34591. "type": "object",
  34592. "additionalProperties": {
  34593. "type": "string"
  34594. }
  34595. },
  34596. "extra": {
  34597. "type": ["object", "array"],
  34598. "additionalProperties": true
  34599. },
  34600. "autoload": {
  34601. "$ref": "#/definitions/autoload"
  34602. },
  34603. "archive": {
  34604. "type": ["object"],
  34605. "properties": {
  34606. "exclude": {
  34607. "type": "array"
  34608. }
  34609. }
  34610. },
  34611. "bin": {
  34612. "type": ["string", "array"],
  34613. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34614. "items": {
  34615. "type": "string"
  34616. }
  34617. },
  34618. "include-path": {
  34619. "type": ["array"],
  34620. "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.",
  34621. "items": {
  34622. "type": "string"
  34623. }
  34624. },
  34625. "source": {
  34626. "type": "object",
  34627. "required": ["type", "url", "reference"],
  34628. "properties": {
  34629. "type": {
  34630. "type": "string"
  34631. },
  34632. "url": {
  34633. "type": "string"
  34634. },
  34635. "reference": {
  34636. "type": "string"
  34637. },
  34638. "mirrors": {
  34639. "type": "array"
  34640. }
  34641. }
  34642. },
  34643. "dist": {
  34644. "type": "object",
  34645. "required": ["type", "url"],
  34646. "properties": {
  34647. "type": {
  34648. "type": "string"
  34649. },
  34650. "url": {
  34651. "type": "string"
  34652. },
  34653. "reference": {
  34654. "type": "string"
  34655. },
  34656. "shasum": {
  34657. "type": "string"
  34658. },
  34659. "mirrors": {
  34660. "type": "array"
  34661. }
  34662. }
  34663. }
  34664. },
  34665. "additionalProperties": true
  34666. }
  34667. }
  34668. }
  34669. <?php
  34670. require_once __DIR__ . '/composer/autoload_real.php';
  34671. return ComposerAutoloaderInitComposerPhar1605285066::getLoader();
  34672. <?php
  34673. namespace Composer\Autoload;
  34674. class ClassLoader
  34675. {
  34676. private $prefixLengthsPsr4 = array();
  34677. private $prefixDirsPsr4 = array();
  34678. private $fallbackDirsPsr4 = array();
  34679. private $prefixesPsr0 = array();
  34680. private $fallbackDirsPsr0 = array();
  34681. private $useIncludePath = false;
  34682. private $classMap = array();
  34683. private $classMapAuthoritative = false;
  34684. private $missingClasses = array();
  34685. private $apcuPrefix;
  34686. public function getPrefixes()
  34687. {
  34688. if (!empty($this->prefixesPsr0)) {
  34689. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  34690. }
  34691. return array();
  34692. }
  34693. public function getPrefixesPsr4()
  34694. {
  34695. return $this->prefixDirsPsr4;
  34696. }
  34697. public function getFallbackDirs()
  34698. {
  34699. return $this->fallbackDirsPsr0;
  34700. }
  34701. public function getFallbackDirsPsr4()
  34702. {
  34703. return $this->fallbackDirsPsr4;
  34704. }
  34705. public function getClassMap()
  34706. {
  34707. return $this->classMap;
  34708. }
  34709. public function addClassMap(array $classMap)
  34710. {
  34711. if ($this->classMap) {
  34712. $this->classMap = array_merge($this->classMap, $classMap);
  34713. } else {
  34714. $this->classMap = $classMap;
  34715. }
  34716. }
  34717. public function add($prefix, $paths, $prepend = false)
  34718. {
  34719. if (!$prefix) {
  34720. if ($prepend) {
  34721. $this->fallbackDirsPsr0 = array_merge(
  34722. (array) $paths,
  34723. $this->fallbackDirsPsr0
  34724. );
  34725. } else {
  34726. $this->fallbackDirsPsr0 = array_merge(
  34727. $this->fallbackDirsPsr0,
  34728. (array) $paths
  34729. );
  34730. }
  34731. return;
  34732. }
  34733. $first = $prefix[0];
  34734. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  34735. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  34736. return;
  34737. }
  34738. if ($prepend) {
  34739. $this->prefixesPsr0[$first][$prefix] = array_merge(
  34740. (array) $paths,
  34741. $this->prefixesPsr0[$first][$prefix]
  34742. );
  34743. } else {
  34744. $this->prefixesPsr0[$first][$prefix] = array_merge(
  34745. $this->prefixesPsr0[$first][$prefix],
  34746. (array) $paths
  34747. );
  34748. }
  34749. }
  34750. public function addPsr4($prefix, $paths, $prepend = false)
  34751. {
  34752. if (!$prefix) {
  34753. if ($prepend) {
  34754. $this->fallbackDirsPsr4 = array_merge(
  34755. (array) $paths,
  34756. $this->fallbackDirsPsr4
  34757. );
  34758. } else {
  34759. $this->fallbackDirsPsr4 = array_merge(
  34760. $this->fallbackDirsPsr4,
  34761. (array) $paths
  34762. );
  34763. }
  34764. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  34765. $length = strlen($prefix);
  34766. if ('\\' !== $prefix[$length - 1]) {
  34767. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  34768. }
  34769. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  34770. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  34771. } elseif ($prepend) {
  34772. $this->prefixDirsPsr4[$prefix] = array_merge(
  34773. (array) $paths,
  34774. $this->prefixDirsPsr4[$prefix]
  34775. );
  34776. } else {
  34777. $this->prefixDirsPsr4[$prefix] = array_merge(
  34778. $this->prefixDirsPsr4[$prefix],
  34779. (array) $paths
  34780. );
  34781. }
  34782. }
  34783. public function set($prefix, $paths)
  34784. {
  34785. if (!$prefix) {
  34786. $this->fallbackDirsPsr0 = (array) $paths;
  34787. } else {
  34788. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  34789. }
  34790. }
  34791. public function setPsr4($prefix, $paths)
  34792. {
  34793. if (!$prefix) {
  34794. $this->fallbackDirsPsr4 = (array) $paths;
  34795. } else {
  34796. $length = strlen($prefix);
  34797. if ('\\' !== $prefix[$length - 1]) {
  34798. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  34799. }
  34800. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  34801. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  34802. }
  34803. }
  34804. public function setUseIncludePath($useIncludePath)
  34805. {
  34806. $this->useIncludePath = $useIncludePath;
  34807. }
  34808. public function getUseIncludePath()
  34809. {
  34810. return $this->useIncludePath;
  34811. }
  34812. public function setClassMapAuthoritative($classMapAuthoritative)
  34813. {
  34814. $this->classMapAuthoritative = $classMapAuthoritative;
  34815. }
  34816. public function isClassMapAuthoritative()
  34817. {
  34818. return $this->classMapAuthoritative;
  34819. }
  34820. public function setApcuPrefix($apcuPrefix)
  34821. {
  34822. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  34823. }
  34824. public function getApcuPrefix()
  34825. {
  34826. return $this->apcuPrefix;
  34827. }
  34828. public function register($prepend = false)
  34829. {
  34830. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  34831. }
  34832. public function unregister()
  34833. {
  34834. spl_autoload_unregister(array($this, 'loadClass'));
  34835. }
  34836. public function loadClass($class)
  34837. {
  34838. if ($file = $this->findFile($class)) {
  34839. includeFile($file);
  34840. return true;
  34841. }
  34842. }
  34843. public function findFile($class)
  34844. {
  34845. if (isset($this->classMap[$class])) {
  34846. return $this->classMap[$class];
  34847. }
  34848. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  34849. return false;
  34850. }
  34851. if (null !== $this->apcuPrefix) {
  34852. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  34853. if ($hit) {
  34854. return $file;
  34855. }
  34856. }
  34857. $file = $this->findFileWithExtension($class, '.php');
  34858. if (false === $file && defined('HHVM_VERSION')) {
  34859. $file = $this->findFileWithExtension($class, '.hh');
  34860. }
  34861. if (null !== $this->apcuPrefix) {
  34862. apcu_add($this->apcuPrefix.$class, $file);
  34863. }
  34864. if (false === $file) {
  34865. $this->missingClasses[$class] = true;
  34866. }
  34867. return $file;
  34868. }
  34869. private function findFileWithExtension($class, $ext)
  34870. {
  34871. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  34872. $first = $class[0];
  34873. if (isset($this->prefixLengthsPsr4[$first])) {
  34874. $subPath = $class;
  34875. while (false !== $lastPos = strrpos($subPath, '\\')) {
  34876. $subPath = substr($subPath, 0, $lastPos);
  34877. $search = $subPath . '\\';
  34878. if (isset($this->prefixDirsPsr4[$search])) {
  34879. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  34880. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  34881. if (file_exists($file = $dir . $pathEnd)) {
  34882. return $file;
  34883. }
  34884. }
  34885. }
  34886. }
  34887. }
  34888. foreach ($this->fallbackDirsPsr4 as $dir) {
  34889. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  34890. return $file;
  34891. }
  34892. }
  34893. if (false !== $pos = strrpos($class, '\\')) {
  34894. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  34895. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  34896. } else {
  34897. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  34898. }
  34899. if (isset($this->prefixesPsr0[$first])) {
  34900. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  34901. if (0 === strpos($class, $prefix)) {
  34902. foreach ($dirs as $dir) {
  34903. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  34904. return $file;
  34905. }
  34906. }
  34907. }
  34908. }
  34909. }
  34910. foreach ($this->fallbackDirsPsr0 as $dir) {
  34911. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  34912. return $file;
  34913. }
  34914. }
  34915. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  34916. return $file;
  34917. }
  34918. return false;
  34919. }
  34920. }
  34921. function includeFile($file)
  34922. {
  34923. include $file;
  34924. }
  34925. <?php
  34926. namespace Composer;
  34927. use Composer\Semver\VersionParser;
  34928. class InstalledVersions
  34929. {
  34930. private static $installed = array (
  34931. 'root' =>
  34932. array (
  34933. 'pretty_version' => '2.0.7',
  34934. 'version' => '2.0.7.0',
  34935. 'aliases' =>
  34936. array (
  34937. ),
  34938. 'reference' => 'cbee637510037f293e641857b2a6223d0ea8008d',
  34939. 'name' => 'composer/composer',
  34940. ),
  34941. 'versions' =>
  34942. array (
  34943. 'composer/ca-bundle' =>
  34944. array (
  34945. 'pretty_version' => '1.2.8',
  34946. 'version' => '1.2.8.0',
  34947. 'aliases' =>
  34948. array (
  34949. ),
  34950. 'reference' => '8a7ecad675253e4654ea05505233285377405215',
  34951. ),
  34952. 'composer/composer' =>
  34953. array (
  34954. 'pretty_version' => '2.0.7',
  34955. 'version' => '2.0.7.0',
  34956. 'aliases' =>
  34957. array (
  34958. ),
  34959. 'reference' => 'cbee637510037f293e641857b2a6223d0ea8008d',
  34960. ),
  34961. 'composer/semver' =>
  34962. array (
  34963. 'pretty_version' => '3.2.4',
  34964. 'version' => '3.2.4.0',
  34965. 'aliases' =>
  34966. array (
  34967. ),
  34968. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  34969. ),
  34970. 'composer/spdx-licenses' =>
  34971. array (
  34972. 'pretty_version' => '1.5.4',
  34973. 'version' => '1.5.4.0',
  34974. 'aliases' =>
  34975. array (
  34976. ),
  34977. 'reference' => '6946f785871e2314c60b4524851f3702ea4f2223',
  34978. ),
  34979. 'composer/xdebug-handler' =>
  34980. array (
  34981. 'pretty_version' => '1.4.5',
  34982. 'version' => '1.4.5.0',
  34983. 'aliases' =>
  34984. array (
  34985. ),
  34986. 'reference' => 'f28d44c286812c714741478d968104c5e604a1d4',
  34987. ),
  34988. 'justinrainbow/json-schema' =>
  34989. array (
  34990. 'pretty_version' => '5.2.10',
  34991. 'version' => '5.2.10.0',
  34992. 'aliases' =>
  34993. array (
  34994. ),
  34995. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  34996. ),
  34997. 'psr/log' =>
  34998. array (
  34999. 'pretty_version' => '1.1.3',
  35000. 'version' => '1.1.3.0',
  35001. 'aliases' =>
  35002. array (
  35003. ),
  35004. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  35005. ),
  35006. 'react/promise' =>
  35007. array (
  35008. 'pretty_version' => 'v1.2.1',
  35009. 'version' => '1.2.1.0',
  35010. 'aliases' =>
  35011. array (
  35012. ),
  35013. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  35014. ),
  35015. 'seld/jsonlint' =>
  35016. array (
  35017. 'pretty_version' => '1.8.3',
  35018. 'version' => '1.8.3.0',
  35019. 'aliases' =>
  35020. array (
  35021. ),
  35022. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  35023. ),
  35024. 'seld/phar-utils' =>
  35025. array (
  35026. 'pretty_version' => '1.1.1',
  35027. 'version' => '1.1.1.0',
  35028. 'aliases' =>
  35029. array (
  35030. ),
  35031. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  35032. ),
  35033. 'symfony/console' =>
  35034. array (
  35035. 'pretty_version' => 'v2.8.52',
  35036. 'version' => '2.8.52.0',
  35037. 'aliases' =>
  35038. array (
  35039. ),
  35040. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  35041. ),
  35042. 'symfony/debug' =>
  35043. array (
  35044. 'pretty_version' => 'v2.8.52',
  35045. 'version' => '2.8.52.0',
  35046. 'aliases' =>
  35047. array (
  35048. ),
  35049. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  35050. ),
  35051. 'symfony/filesystem' =>
  35052. array (
  35053. 'pretty_version' => 'v2.8.52',
  35054. 'version' => '2.8.52.0',
  35055. 'aliases' =>
  35056. array (
  35057. ),
  35058. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  35059. ),
  35060. 'symfony/finder' =>
  35061. array (
  35062. 'pretty_version' => 'v2.8.52',
  35063. 'version' => '2.8.52.0',
  35064. 'aliases' =>
  35065. array (
  35066. ),
  35067. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  35068. ),
  35069. 'symfony/polyfill-ctype' =>
  35070. array (
  35071. 'pretty_version' => 'v1.19.0',
  35072. 'version' => '1.19.0.0',
  35073. 'aliases' =>
  35074. array (
  35075. ),
  35076. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  35077. ),
  35078. 'symfony/polyfill-mbstring' =>
  35079. array (
  35080. 'pretty_version' => 'v1.19.0',
  35081. 'version' => '1.19.0.0',
  35082. 'aliases' =>
  35083. array (
  35084. ),
  35085. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  35086. ),
  35087. 'symfony/process' =>
  35088. array (
  35089. 'pretty_version' => 'v2.8.52',
  35090. 'version' => '2.8.52.0',
  35091. 'aliases' =>
  35092. array (
  35093. ),
  35094. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  35095. ),
  35096. ),
  35097. );
  35098. public static function getInstalledPackages()
  35099. {
  35100. return array_keys(self::$installed['versions']);
  35101. }
  35102. public static function isInstalled($packageName)
  35103. {
  35104. return isset(self::$installed['versions'][$packageName]);
  35105. }
  35106. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  35107. {
  35108. $constraint = $parser->parseConstraints($constraint);
  35109. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  35110. return $provided->matches($constraint);
  35111. }
  35112. public static function getVersionRanges($packageName)
  35113. {
  35114. if (!isset(self::$installed['versions'][$packageName])) {
  35115. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35116. }
  35117. $ranges = array();
  35118. if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  35119. $ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
  35120. }
  35121. if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
  35122. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
  35123. }
  35124. if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
  35125. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
  35126. }
  35127. if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
  35128. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
  35129. }
  35130. return implode(' || ', $ranges);
  35131. }
  35132. public static function getVersion($packageName)
  35133. {
  35134. if (!isset(self::$installed['versions'][$packageName])) {
  35135. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35136. }
  35137. if (!isset(self::$installed['versions'][$packageName]['version'])) {
  35138. return null;
  35139. }
  35140. return self::$installed['versions'][$packageName]['version'];
  35141. }
  35142. public static function getPrettyVersion($packageName)
  35143. {
  35144. if (!isset(self::$installed['versions'][$packageName])) {
  35145. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35146. }
  35147. if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  35148. return null;
  35149. }
  35150. return self::$installed['versions'][$packageName]['pretty_version'];
  35151. }
  35152. public static function getReference($packageName)
  35153. {
  35154. if (!isset(self::$installed['versions'][$packageName])) {
  35155. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35156. }
  35157. if (!isset(self::$installed['versions'][$packageName]['reference'])) {
  35158. return null;
  35159. }
  35160. return self::$installed['versions'][$packageName]['reference'];
  35161. }
  35162. public static function getRootPackage()
  35163. {
  35164. return self::$installed['root'];
  35165. }
  35166. public static function getRawData()
  35167. {
  35168. return self::$installed;
  35169. }
  35170. public static function reload($data)
  35171. {
  35172. self::$installed = $data;
  35173. }
  35174. }
  35175. <?php
  35176. $vendorDir = dirname(dirname(__FILE__));
  35177. $baseDir = dirname($vendorDir);
  35178. return array(
  35179. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  35180. );
  35181. <?php
  35182. $vendorDir = dirname(dirname(__FILE__));
  35183. $baseDir = dirname($vendorDir);
  35184. return array(
  35185. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  35186. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  35187. '7844cce90d4037f1a077c08319eef109' => $vendorDir . '/react/promise/src/React/Promise/functions_include.php',
  35188. );
  35189. <?php
  35190. $vendorDir = dirname(dirname(__FILE__));
  35191. $baseDir = dirname($vendorDir);
  35192. return array(
  35193. 'React\\Promise' => array($vendorDir . '/react/promise/src'),
  35194. );
  35195. <?php
  35196. $vendorDir = dirname(dirname(__FILE__));
  35197. $baseDir = dirname($vendorDir);
  35198. return array(
  35199. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  35200. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  35201. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  35202. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  35203. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  35204. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  35205. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  35206. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  35207. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  35208. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  35209. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  35210. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  35211. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  35212. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  35213. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  35214. 'Composer\\' => array($baseDir . '/src/Composer'),
  35215. );
  35216. <?php
  35217. class ComposerAutoloaderInitComposerPhar1605285066
  35218. {
  35219. private static $loader;
  35220. public static function loadClassLoader($class)
  35221. {
  35222. if ('Composer\Autoload\ClassLoader' === $class) {
  35223. require __DIR__ . '/ClassLoader.php';
  35224. }
  35225. }
  35226. public static function getLoader()
  35227. {
  35228. if (null !== self::$loader) {
  35229. return self::$loader;
  35230. }
  35231. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1605285066', 'loadClassLoader'), true, true);
  35232. self::$loader = $loader = new \Composer\Autoload\ClassLoader();
  35233. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1605285066', 'loadClassLoader'));
  35234. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  35235. if ($useStaticLoader) {
  35236. require __DIR__ . '/autoload_static.php';
  35237. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1605285066::getInitializer($loader));
  35238. } else {
  35239. $map = require __DIR__ . '/autoload_namespaces.php';
  35240. foreach ($map as $namespace => $path) {
  35241. $loader->set($namespace, $path);
  35242. }
  35243. $map = require __DIR__ . '/autoload_psr4.php';
  35244. foreach ($map as $namespace => $path) {
  35245. $loader->setPsr4($namespace, $path);
  35246. }
  35247. $classMap = require __DIR__ . '/autoload_classmap.php';
  35248. if ($classMap) {
  35249. $loader->addClassMap($classMap);
  35250. }
  35251. }
  35252. $loader->register(true);
  35253. if ($useStaticLoader) {
  35254. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1605285066::$files;
  35255. } else {
  35256. $includeFiles = require __DIR__ . '/autoload_files.php';
  35257. }
  35258. foreach ($includeFiles as $fileIdentifier => $file) {
  35259. composerRequireComposerPhar1605285066($fileIdentifier, $file);
  35260. }
  35261. return $loader;
  35262. }
  35263. }
  35264. function composerRequireComposerPhar1605285066($fileIdentifier, $file)
  35265. {
  35266. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  35267. require $file;
  35268. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  35269. }
  35270. }
  35271. <?php
  35272. namespace Composer\Autoload;
  35273. class ComposerStaticInitComposerPhar1605285066
  35274. {
  35275. public static $files = array (
  35276. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  35277. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  35278. '7844cce90d4037f1a077c08319eef109' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions_include.php',
  35279. );
  35280. public static $prefixLengthsPsr4 = array (
  35281. 'S' =>
  35282. array (
  35283. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  35284. 'Symfony\\Polyfill\\Ctype\\' => 23,
  35285. 'Symfony\\Component\\Process\\' => 26,
  35286. 'Symfony\\Component\\Finder\\' => 25,
  35287. 'Symfony\\Component\\Filesystem\\' => 29,
  35288. 'Symfony\\Component\\Debug\\' => 24,
  35289. 'Symfony\\Component\\Console\\' => 26,
  35290. 'Seld\\PharUtils\\' => 15,
  35291. 'Seld\\JsonLint\\' => 14,
  35292. ),
  35293. 'P' =>
  35294. array (
  35295. 'Psr\\Log\\' => 8,
  35296. ),
  35297. 'J' =>
  35298. array (
  35299. 'JsonSchema\\' => 11,
  35300. ),
  35301. 'C' =>
  35302. array (
  35303. 'Composer\\XdebugHandler\\' => 23,
  35304. 'Composer\\Spdx\\' => 14,
  35305. 'Composer\\Semver\\' => 16,
  35306. 'Composer\\CaBundle\\' => 18,
  35307. 'Composer\\' => 9,
  35308. ),
  35309. );
  35310. public static $prefixDirsPsr4 = array (
  35311. 'Symfony\\Polyfill\\Mbstring\\' =>
  35312. array (
  35313. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  35314. ),
  35315. 'Symfony\\Polyfill\\Ctype\\' =>
  35316. array (
  35317. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  35318. ),
  35319. 'Symfony\\Component\\Process\\' =>
  35320. array (
  35321. 0 => __DIR__ . '/..' . '/symfony/process',
  35322. ),
  35323. 'Symfony\\Component\\Finder\\' =>
  35324. array (
  35325. 0 => __DIR__ . '/..' . '/symfony/finder',
  35326. ),
  35327. 'Symfony\\Component\\Filesystem\\' =>
  35328. array (
  35329. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  35330. ),
  35331. 'Symfony\\Component\\Debug\\' =>
  35332. array (
  35333. 0 => __DIR__ . '/..' . '/symfony/debug',
  35334. ),
  35335. 'Symfony\\Component\\Console\\' =>
  35336. array (
  35337. 0 => __DIR__ . '/..' . '/symfony/console',
  35338. ),
  35339. 'Seld\\PharUtils\\' =>
  35340. array (
  35341. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  35342. ),
  35343. 'Seld\\JsonLint\\' =>
  35344. array (
  35345. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  35346. ),
  35347. 'Psr\\Log\\' =>
  35348. array (
  35349. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  35350. ),
  35351. 'JsonSchema\\' =>
  35352. array (
  35353. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  35354. ),
  35355. 'Composer\\XdebugHandler\\' =>
  35356. array (
  35357. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  35358. ),
  35359. 'Composer\\Spdx\\' =>
  35360. array (
  35361. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  35362. ),
  35363. 'Composer\\Semver\\' =>
  35364. array (
  35365. 0 => __DIR__ . '/..' . '/composer/semver/src',
  35366. ),
  35367. 'Composer\\CaBundle\\' =>
  35368. array (
  35369. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  35370. ),
  35371. 'Composer\\' =>
  35372. array (
  35373. 0 => __DIR__ . '/../..' . '/src/Composer',
  35374. ),
  35375. );
  35376. public static $prefixesPsr0 = array (
  35377. 'R' =>
  35378. array (
  35379. 'React\\Promise' =>
  35380. array (
  35381. 0 => __DIR__ . '/..' . '/react/promise/src',
  35382. ),
  35383. ),
  35384. );
  35385. public static $classMap = array (
  35386. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  35387. );
  35388. public static function getInitializer(ClassLoader $loader)
  35389. {
  35390. return \Closure::bind(function () use ($loader) {
  35391. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1605285066::$prefixLengthsPsr4;
  35392. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1605285066::$prefixDirsPsr4;
  35393. $loader->prefixesPsr0 = ComposerStaticInitComposerPhar1605285066::$prefixesPsr0;
  35394. $loader->classMap = ComposerStaticInitComposerPhar1605285066::$classMap;
  35395. }, null, ClassLoader::class);
  35396. }
  35397. }
  35398. Copyright (C) 2016 Composer
  35399. Permission is hereby granted, free of charge, to any person obtaining a copy of
  35400. this software and associated documentation files (the "Software"), to deal in
  35401. the Software without restriction, including without limitation the rights to
  35402. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  35403. of the Software, and to permit persons to whom the Software is furnished to do
  35404. so, subject to the following conditions:
  35405. The above copyright notice and this permission notice shall be included in all
  35406. copies or substantial portions of the Software.
  35407. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35408. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  35409. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  35410. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  35411. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  35412. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  35413. SOFTWARE.
  35414. ##
  35415. ## Bundle of CA Root Certificates
  35416. ##
  35417. ## Certificate data from Mozilla as of: Wed Jul 22 03:12:14 2020 GMT
  35418. ##
  35419. ## This is a bundle of X.509 certificates of public Certificate Authorities
  35420. ## (CA). These were automatically extracted from Mozilla's root certificates
  35421. ## file (certdata.txt). This file can be found in the mozilla source tree:
  35422. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  35423. ##
  35424. ## It contains the certificates in PEM format and therefore
  35425. ## can be directly used with curl / libcurl / php_curl, or with
  35426. ## an Apache+mod_ssl webserver for SSL client authentication.
  35427. ## Just configure this file as the SSLCACertificateFile.
  35428. ##
  35429. ## Conversion done with mk-ca-bundle.pl version 1.28.
  35430. ## SHA256: cc6408bd4be7fbfb8699bdb40ccb7f6de5780d681d87785ea362646e4dad5e8e
  35431. ##
  35432. GlobalSign Root CA
  35433. ==================
  35434. -----BEGIN CERTIFICATE-----
  35435. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  35436. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  35437. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  35438. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  35439. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  35440. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  35441. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  35442. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  35443. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  35444. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  35445. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  35446. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  35447. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  35448. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  35449. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  35450. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  35451. -----END CERTIFICATE-----
  35452. GlobalSign Root CA - R2
  35453. =======================
  35454. -----BEGIN CERTIFICATE-----
  35455. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  35456. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  35457. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  35458. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  35459. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  35460. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  35461. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  35462. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  35463. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  35464. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  35465. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  35466. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  35467. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  35468. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  35469. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  35470. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  35471. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  35472. -----END CERTIFICATE-----
  35473. Entrust.net Premium 2048 Secure Server CA
  35474. =========================================
  35475. -----BEGIN CERTIFICATE-----
  35476. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  35477. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  35478. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  35479. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  35480. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  35481. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  35482. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  35483. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  35484. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  35485. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  35486. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  35487. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  35488. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  35489. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  35490. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  35491. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  35492. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  35493. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  35494. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  35495. -----END CERTIFICATE-----
  35496. Baltimore CyberTrust Root
  35497. =========================
  35498. -----BEGIN CERTIFICATE-----
  35499. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  35500. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  35501. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  35502. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  35503. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  35504. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  35505. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  35506. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  35507. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  35508. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  35509. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  35510. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  35511. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  35512. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  35513. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  35514. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  35515. -----END CERTIFICATE-----
  35516. Entrust Root Certification Authority
  35517. ====================================
  35518. -----BEGIN CERTIFICATE-----
  35519. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  35520. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  35521. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  35522. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  35523. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  35524. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  35525. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  35526. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  35527. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  35528. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  35529. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  35530. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  35531. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  35532. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  35533. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  35534. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  35535. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  35536. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  35537. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  35538. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  35539. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  35540. -----END CERTIFICATE-----
  35541. GeoTrust Global CA
  35542. ==================
  35543. -----BEGIN CERTIFICATE-----
  35544. MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK
  35545. Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw
  35546. MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j
  35547. LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  35548. CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo
  35549. BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet
  35550. 8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc
  35551. T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU
  35552. vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD
  35553. AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk
  35554. DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q
  35555. zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4
  35556. d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2
  35557. mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p
  35558. XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm
  35559. Mw==
  35560. -----END CERTIFICATE-----
  35561. GeoTrust Universal CA
  35562. =====================
  35563. -----BEGIN CERTIFICATE-----
  35564. MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  35565. R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1
  35566. MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu
  35567. Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  35568. ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t
  35569. JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e
  35570. RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs
  35571. 7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d
  35572. 8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V
  35573. qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga
  35574. Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB
  35575. Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu
  35576. KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08
  35577. ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0
  35578. XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB
  35579. hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
  35580. aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2
  35581. qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL
  35582. oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK
  35583. xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF
  35584. KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2
  35585. DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK
  35586. xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU
  35587. p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI
  35588. P/rmMuGNG2+k5o7Y+SlIis5z/iw=
  35589. -----END CERTIFICATE-----
  35590. GeoTrust Universal CA 2
  35591. =======================
  35592. -----BEGIN CERTIFICATE-----
  35593. MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  35594. R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0
  35595. MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg
  35596. SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA
  35597. A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0
  35598. DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17
  35599. j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q
  35600. JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a
  35601. QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2
  35602. WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP
  35603. 20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn
  35604. ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC
  35605. SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG
  35606. 8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2
  35607. +/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E
  35608. BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z
  35609. dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ
  35610. 4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+
  35611. mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq
  35612. A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg
  35613. Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP
  35614. pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d
  35615. FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp
  35616. gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm
  35617. X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS
  35618. -----END CERTIFICATE-----
  35619. Comodo AAA Services root
  35620. ========================
  35621. -----BEGIN CERTIFICATE-----
  35622. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  35623. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  35624. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  35625. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  35626. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  35627. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  35628. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  35629. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  35630. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  35631. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  35632. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  35633. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  35634. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  35635. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  35636. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  35637. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  35638. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  35639. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  35640. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  35641. -----END CERTIFICATE-----
  35642. QuoVadis Root CA
  35643. ================
  35644. -----BEGIN CERTIFICATE-----
  35645. MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE
  35646. ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
  35647. eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz
  35648. MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp
  35649. cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD
  35650. EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF
  35651. AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk
  35652. J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL
  35653. F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL
  35654. YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen
  35655. AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w
  35656. PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y
  35657. ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7
  35658. MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj
  35659. YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs
  35660. ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh
  35661. Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW
  35662. Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu
  35663. BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw
  35664. FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0
  35665. aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6
  35666. tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo
  35667. fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul
  35668. LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x
  35669. gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi
  35670. 5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi
  35671. 5nrQNiOKSnQ2+Q==
  35672. -----END CERTIFICATE-----
  35673. QuoVadis Root CA 2
  35674. ==================
  35675. -----BEGIN CERTIFICATE-----
  35676. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  35677. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  35678. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  35679. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  35680. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  35681. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  35682. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  35683. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  35684. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  35685. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  35686. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  35687. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  35688. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  35689. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  35690. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  35691. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  35692. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  35693. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  35694. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  35695. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  35696. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  35697. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  35698. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  35699. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  35700. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  35701. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  35702. -----END CERTIFICATE-----
  35703. QuoVadis Root CA 3
  35704. ==================
  35705. -----BEGIN CERTIFICATE-----
  35706. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  35707. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  35708. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  35709. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  35710. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  35711. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  35712. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  35713. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  35714. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  35715. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  35716. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  35717. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  35718. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  35719. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  35720. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  35721. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  35722. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  35723. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  35724. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  35725. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  35726. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  35727. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  35728. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  35729. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  35730. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  35731. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  35732. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  35733. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  35734. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  35735. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  35736. -----END CERTIFICATE-----
  35737. Security Communication Root CA
  35738. ==============================
  35739. -----BEGIN CERTIFICATE-----
  35740. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  35741. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  35742. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  35743. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  35744. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  35745. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  35746. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  35747. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  35748. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  35749. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  35750. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  35751. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  35752. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  35753. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  35754. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  35755. FL39vmwLAw==
  35756. -----END CERTIFICATE-----
  35757. Sonera Class 2 Root CA
  35758. ======================
  35759. -----BEGIN CERTIFICATE-----
  35760. MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG
  35761. U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw
  35762. NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh
  35763. IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3
  35764. /Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT
  35765. dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG
  35766. f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P
  35767. tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH
  35768. nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT
  35769. XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt
  35770. 0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI
  35771. cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph
  35772. Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx
  35773. EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH
  35774. llpwrN9M
  35775. -----END CERTIFICATE-----
  35776. XRamp Global CA Root
  35777. ====================
  35778. -----BEGIN CERTIFICATE-----
  35779. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  35780. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  35781. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  35782. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  35783. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  35784. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  35785. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  35786. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  35787. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  35788. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  35789. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  35790. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  35791. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  35792. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  35793. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  35794. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  35795. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  35796. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  35797. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  35798. -----END CERTIFICATE-----
  35799. Go Daddy Class 2 CA
  35800. ===================
  35801. -----BEGIN CERTIFICATE-----
  35802. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  35803. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  35804. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  35805. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  35806. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  35807. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  35808. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  35809. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  35810. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  35811. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  35812. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  35813. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  35814. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  35815. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  35816. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  35817. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  35818. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  35819. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  35820. vZ8=
  35821. -----END CERTIFICATE-----
  35822. Starfield Class 2 CA
  35823. ====================
  35824. -----BEGIN CERTIFICATE-----
  35825. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  35826. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  35827. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  35828. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  35829. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  35830. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  35831. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  35832. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  35833. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  35834. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  35835. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  35836. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  35837. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  35838. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  35839. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  35840. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  35841. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  35842. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  35843. QBFGmh95DmK/D5fs4C8fF5Q=
  35844. -----END CERTIFICATE-----
  35845. Taiwan GRCA
  35846. ===========
  35847. -----BEGIN CERTIFICATE-----
  35848. MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQG
  35849. EwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4X
  35850. DTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1owPzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dv
  35851. dmVybm1lbnQgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQAD
  35852. ggIPADCCAgoCggIBAJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qN
  35853. w8XRIePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1qgQdW8or5
  35854. BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKyyhwOeYHWtXBiCAEuTk8O
  35855. 1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAtsF/tnyMKtsc2AtJfcdgEWFelq16TheEfO
  35856. htX7MfP6Mb40qij7cEwdScevLJ1tZqa2jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wov
  35857. J5pGfaENda1UhhXcSTvxls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7
  35858. Q3hub/FCVGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHKYS1t
  35859. B6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoHEgKXTiCQ8P8NHuJB
  35860. O9NAOueNXdpm5AKwB1KYXA6OM5zCppX7VRluTI6uSw+9wThNXo+EHWbNxWCWtFJaBYmOlXqYwZE8
  35861. lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1UdDgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNV
  35862. HRMEBTADAQH/MDkGBGcqBwAEMTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg2
  35863. 09yewDL7MTqKUWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ
  35864. TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyfqzvS/3WXy6Tj
  35865. Zwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaKZEk9GhiHkASfQlK3T8v+R0F2
  35866. Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFEJPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlU
  35867. D7gsL0u8qV1bYH+Mh6XgUmMqvtg7hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6Qz
  35868. DxARvBMB1uUO07+1EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+Hbk
  35869. Z6MmnD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WXudpVBrkk
  35870. 7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44VbnzssQwmSNOXfJIoRIM3BKQ
  35871. CZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDeLMDDav7v3Aun+kbfYNucpllQdSNpc5Oy
  35872. +fwC00fmcc4QAu4njIT/rEUNE1yDMuAlpYYsfPQS
  35873. -----END CERTIFICATE-----
  35874. DigiCert Assured ID Root CA
  35875. ===========================
  35876. -----BEGIN CERTIFICATE-----
  35877. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  35878. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  35879. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  35880. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  35881. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  35882. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  35883. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  35884. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  35885. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  35886. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  35887. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  35888. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  35889. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  35890. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  35891. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  35892. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  35893. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  35894. -----END CERTIFICATE-----
  35895. DigiCert Global Root CA
  35896. =======================
  35897. -----BEGIN CERTIFICATE-----
  35898. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  35899. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  35900. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  35901. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  35902. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  35903. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  35904. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  35905. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  35906. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  35907. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  35908. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  35909. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  35910. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  35911. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  35912. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  35913. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  35914. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  35915. -----END CERTIFICATE-----
  35916. DigiCert High Assurance EV Root CA
  35917. ==================================
  35918. -----BEGIN CERTIFICATE-----
  35919. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  35920. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  35921. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  35922. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  35923. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  35924. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  35925. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  35926. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  35927. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  35928. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  35929. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  35930. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  35931. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  35932. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  35933. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  35934. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  35935. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  35936. -----END CERTIFICATE-----
  35937. DST Root CA X3
  35938. ==============
  35939. -----BEGIN CERTIFICATE-----
  35940. MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK
  35941. ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X
  35942. DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1
  35943. cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD
  35944. ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT
  35945. rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9
  35946. UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy
  35947. xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d
  35948. utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T
  35949. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ
  35950. MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug
  35951. dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE
  35952. GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw
  35953. RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS
  35954. fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
  35955. -----END CERTIFICATE-----
  35956. SwissSign Gold CA - G2
  35957. ======================
  35958. -----BEGIN CERTIFICATE-----
  35959. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  35960. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  35961. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  35962. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  35963. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  35964. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  35965. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  35966. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  35967. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  35968. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  35969. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  35970. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  35971. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  35972. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  35973. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  35974. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  35975. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  35976. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  35977. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  35978. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  35979. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  35980. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  35981. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  35982. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  35983. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  35984. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  35985. -----END CERTIFICATE-----
  35986. SwissSign Silver CA - G2
  35987. ========================
  35988. -----BEGIN CERTIFICATE-----
  35989. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  35990. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  35991. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  35992. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  35993. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  35994. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  35995. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  35996. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  35997. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  35998. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  35999. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  36000. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  36001. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  36002. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  36003. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  36004. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  36005. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  36006. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  36007. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  36008. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  36009. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  36010. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  36011. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  36012. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  36013. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  36014. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  36015. -----END CERTIFICATE-----
  36016. GeoTrust Primary Certification Authority
  36017. ========================================
  36018. -----BEGIN CERTIFICATE-----
  36019. MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG
  36020. EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD
  36021. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx
  36022. CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ
  36023. cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  36024. CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN
  36025. b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9
  36026. nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge
  36027. RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt
  36028. tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  36029. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI
  36030. hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K
  36031. Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN
  36032. NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa
  36033. Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG
  36034. 1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=
  36035. -----END CERTIFICATE-----
  36036. thawte Primary Root CA
  36037. ======================
  36038. -----BEGIN CERTIFICATE-----
  36039. MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE
  36040. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36041. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36042. cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3
  36043. MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg
  36044. SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv
  36045. KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT
  36046. FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs
  36047. oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ
  36048. 1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc
  36049. q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K
  36050. aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p
  36051. afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD
  36052. VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF
  36053. AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE
  36054. uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX
  36055. xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89
  36056. jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH
  36057. z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA==
  36058. -----END CERTIFICATE-----
  36059. VeriSign Class 3 Public Primary Certification Authority - G5
  36060. ============================================================
  36061. -----BEGIN CERTIFICATE-----
  36062. MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
  36063. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36064. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36065. IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
  36066. ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
  36067. yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
  36068. biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
  36069. dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
  36070. YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  36071. ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
  36072. j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
  36073. Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
  36074. Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
  36075. fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
  36076. BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
  36077. Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
  36078. aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
  36079. SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
  36080. X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
  36081. KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
  36082. Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
  36083. ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
  36084. -----END CERTIFICATE-----
  36085. SecureTrust CA
  36086. ==============
  36087. -----BEGIN CERTIFICATE-----
  36088. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  36089. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  36090. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  36091. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  36092. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  36093. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  36094. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  36095. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  36096. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  36097. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  36098. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  36099. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  36100. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  36101. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  36102. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  36103. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  36104. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  36105. -----END CERTIFICATE-----
  36106. Secure Global CA
  36107. ================
  36108. -----BEGIN CERTIFICATE-----
  36109. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  36110. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  36111. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  36112. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  36113. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  36114. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  36115. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  36116. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  36117. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  36118. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  36119. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  36120. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  36121. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  36122. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  36123. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  36124. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  36125. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  36126. -----END CERTIFICATE-----
  36127. COMODO Certification Authority
  36128. ==============================
  36129. -----BEGIN CERTIFICATE-----
  36130. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  36131. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  36132. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  36133. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  36134. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  36135. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  36136. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  36137. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  36138. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  36139. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  36140. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  36141. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  36142. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  36143. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  36144. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  36145. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  36146. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  36147. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  36148. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  36149. -----END CERTIFICATE-----
  36150. Network Solutions Certificate Authority
  36151. =======================================
  36152. -----BEGIN CERTIFICATE-----
  36153. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  36154. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  36155. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  36156. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  36157. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  36158. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  36159. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  36160. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  36161. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  36162. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  36163. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  36164. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  36165. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  36166. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  36167. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  36168. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  36169. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  36170. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  36171. -----END CERTIFICATE-----
  36172. COMODO ECC Certification Authority
  36173. ==================================
  36174. -----BEGIN CERTIFICATE-----
  36175. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  36176. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  36177. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  36178. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  36179. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  36180. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  36181. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  36182. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  36183. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  36184. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  36185. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  36186. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  36187. -----END CERTIFICATE-----
  36188. OISTE WISeKey Global Root GA CA
  36189. ===============================
  36190. -----BEGIN CERTIFICATE-----
  36191. MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCBijELMAkGA1UE
  36192. BhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHlyaWdodCAoYykgMjAwNTEiMCAG
  36193. A1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBH
  36194. bG9iYWwgUm9vdCBHQSBDQTAeFw0wNTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYD
  36195. VQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIw
  36196. IAYDVQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5
  36197. IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0+zAJs9
  36198. Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxRVVuuk+g3/ytr6dTqvirdqFEr12bDYVxg
  36199. Asj1znJ7O7jyTmUIms2kahnBAbtzptf2w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbD
  36200. d50kc3vkDIzh2TbhmYsFmQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ
  36201. /yxViJGg4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t94B3R
  36202. LoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw
  36203. AwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  36204. KoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOxSPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vIm
  36205. MMkQyh2I+3QZH4VFvbBsUfk2ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4
  36206. +vg1YFkCExh8vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa
  36207. hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZiFj4A4xylNoEY
  36208. okxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ/L7fCg0=
  36209. -----END CERTIFICATE-----
  36210. Certigna
  36211. ========
  36212. -----BEGIN CERTIFICATE-----
  36213. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  36214. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  36215. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  36216. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  36217. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  36218. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  36219. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  36220. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  36221. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  36222. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  36223. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  36224. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  36225. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  36226. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  36227. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  36228. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  36229. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  36230. -----END CERTIFICATE-----
  36231. Cybertrust Global Root
  36232. ======================
  36233. -----BEGIN CERTIFICATE-----
  36234. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  36235. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  36236. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  36237. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  36238. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  36239. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  36240. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  36241. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  36242. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  36243. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  36244. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  36245. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  36246. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  36247. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  36248. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  36249. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  36250. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  36251. -----END CERTIFICATE-----
  36252. ePKI Root Certification Authority
  36253. =================================
  36254. -----BEGIN CERTIFICATE-----
  36255. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  36256. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  36257. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  36258. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  36259. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  36260. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  36261. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  36262. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  36263. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  36264. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  36265. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  36266. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  36267. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  36268. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  36269. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  36270. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  36271. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  36272. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  36273. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  36274. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  36275. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  36276. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  36277. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  36278. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  36279. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  36280. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  36281. -----END CERTIFICATE-----
  36282. certSIGN ROOT CA
  36283. ================
  36284. -----BEGIN CERTIFICATE-----
  36285. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  36286. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  36287. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  36288. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  36289. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  36290. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  36291. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  36292. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  36293. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  36294. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  36295. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  36296. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  36297. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  36298. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  36299. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  36300. -----END CERTIFICATE-----
  36301. GeoTrust Primary Certification Authority - G3
  36302. =============================================
  36303. -----BEGIN CERTIFICATE-----
  36304. MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE
  36305. BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0
  36306. IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy
  36307. eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz
  36308. NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo
  36309. YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT
  36310. LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI
  36311. hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j
  36312. K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE
  36313. c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C
  36314. IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu
  36315. dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC
  36316. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr
  36317. 2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9
  36318. cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE
  36319. Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD
  36320. AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s
  36321. t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt
  36322. -----END CERTIFICATE-----
  36323. thawte Primary Root CA - G2
  36324. ===========================
  36325. -----BEGIN CERTIFICATE-----
  36326. MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC
  36327. VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu
  36328. IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg
  36329. Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV
  36330. MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG
  36331. b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt
  36332. IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS
  36333. LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5
  36334. 8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU
  36335. mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN
  36336. G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K
  36337. rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==
  36338. -----END CERTIFICATE-----
  36339. thawte Primary Root CA - G3
  36340. ===========================
  36341. -----BEGIN CERTIFICATE-----
  36342. MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE
  36343. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36344. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36345. cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w
  36346. ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh
  36347. d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD
  36348. VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG
  36349. A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  36350. MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At
  36351. P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC
  36352. +BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY
  36353. 7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW
  36354. vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E
  36355. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ
  36356. KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK
  36357. A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu
  36358. t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC
  36359. 8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm
  36360. er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A=
  36361. -----END CERTIFICATE-----
  36362. GeoTrust Primary Certification Authority - G2
  36363. =============================================
  36364. -----BEGIN CERTIFICATE-----
  36365. MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC
  36366. VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu
  36367. Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD
  36368. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1
  36369. OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg
  36370. MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl
  36371. b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG
  36372. BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc
  36373. KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD
  36374. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+
  36375. EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m
  36376. ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2
  36377. npaqBA+K
  36378. -----END CERTIFICATE-----
  36379. VeriSign Universal Root Certification Authority
  36380. ===============================================
  36381. -----BEGIN CERTIFICATE-----
  36382. MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
  36383. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36384. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36385. IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
  36386. IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
  36387. UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
  36388. cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
  36389. IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
  36390. aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
  36391. 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
  36392. MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
  36393. 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
  36394. AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
  36395. tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
  36396. CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
  36397. a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
  36398. DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
  36399. Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
  36400. Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
  36401. P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
  36402. wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
  36403. mJO37M2CYfE45k+XmCpajQ==
  36404. -----END CERTIFICATE-----
  36405. VeriSign Class 3 Public Primary Certification Authority - G4
  36406. ============================================================
  36407. -----BEGIN CERTIFICATE-----
  36408. MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
  36409. VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
  36410. b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
  36411. ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
  36412. YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
  36413. MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
  36414. cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
  36415. b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
  36416. IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
  36417. Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
  36418. rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
  36419. /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
  36420. HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
  36421. Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
  36422. A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
  36423. AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
  36424. -----END CERTIFICATE-----
  36425. NetLock Arany (Class Gold) Főtanúsítvány
  36426. ========================================
  36427. -----BEGIN CERTIFICATE-----
  36428. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  36429. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  36430. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  36431. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  36432. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  36433. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  36434. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  36435. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  36436. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  36437. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  36438. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  36439. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  36440. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  36441. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  36442. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  36443. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  36444. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  36445. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  36446. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  36447. -----END CERTIFICATE-----
  36448. Hongkong Post Root CA 1
  36449. =======================
  36450. -----BEGIN CERTIFICATE-----
  36451. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  36452. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  36453. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  36454. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  36455. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  36456. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  36457. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  36458. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  36459. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  36460. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  36461. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  36462. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  36463. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  36464. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  36465. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  36466. -----END CERTIFICATE-----
  36467. SecureSign RootCA11
  36468. ===================
  36469. -----BEGIN CERTIFICATE-----
  36470. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  36471. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  36472. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  36473. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  36474. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  36475. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  36476. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  36477. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  36478. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  36479. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  36480. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  36481. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  36482. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  36483. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  36484. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  36485. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  36486. -----END CERTIFICATE-----
  36487. Microsec e-Szigno Root CA 2009
  36488. ==============================
  36489. -----BEGIN CERTIFICATE-----
  36490. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  36491. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  36492. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  36493. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  36494. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  36495. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  36496. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  36497. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  36498. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  36499. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  36500. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  36501. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  36502. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  36503. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  36504. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  36505. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  36506. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  36507. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  36508. LXpUq3DDfSJlgnCW
  36509. -----END CERTIFICATE-----
  36510. GlobalSign Root CA - R3
  36511. =======================
  36512. -----BEGIN CERTIFICATE-----
  36513. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  36514. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  36515. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  36516. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  36517. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  36518. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  36519. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  36520. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  36521. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  36522. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  36523. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  36524. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  36525. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  36526. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  36527. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  36528. kpeDMdmztcpHWD9f
  36529. -----END CERTIFICATE-----
  36530. Autoridad de Certificacion Firmaprofesional CIF A62634068
  36531. =========================================================
  36532. -----BEGIN CERTIFICATE-----
  36533. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  36534. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  36535. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  36536. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  36537. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  36538. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  36539. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  36540. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  36541. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  36542. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  36543. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  36544. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  36545. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  36546. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  36547. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  36548. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  36549. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  36550. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  36551. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  36552. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  36553. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  36554. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  36555. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  36556. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  36557. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  36558. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  36559. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  36560. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  36561. -----END CERTIFICATE-----
  36562. Izenpe.com
  36563. ==========
  36564. -----BEGIN CERTIFICATE-----
  36565. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  36566. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  36567. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  36568. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  36569. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  36570. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  36571. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  36572. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  36573. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  36574. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  36575. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  36576. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  36577. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  36578. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  36579. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  36580. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  36581. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  36582. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  36583. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  36584. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  36585. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  36586. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  36587. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  36588. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  36589. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  36590. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  36591. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  36592. -----END CERTIFICATE-----
  36593. Chambers of Commerce Root - 2008
  36594. ================================
  36595. -----BEGIN CERTIFICATE-----
  36596. MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD
  36597. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  36598. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  36599. QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy
  36600. Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl
  36601. ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF
  36602. EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl
  36603. cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
  36604. AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA
  36605. XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj
  36606. h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/
  36607. ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk
  36608. NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g
  36609. D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331
  36610. lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ
  36611. 0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj
  36612. ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2
  36613. EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI
  36614. G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ
  36615. BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh
  36616. bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh
  36617. bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC
  36618. CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH
  36619. AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1
  36620. wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH
  36621. 3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU
  36622. RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6
  36623. M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1
  36624. YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF
  36625. 9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK
  36626. zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG
  36627. nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg
  36628. OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ
  36629. -----END CERTIFICATE-----
  36630. Global Chambersign Root - 2008
  36631. ==============================
  36632. -----BEGIN CERTIFICATE-----
  36633. MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD
  36634. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  36635. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  36636. QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx
  36637. NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg
  36638. Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ
  36639. QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD
  36640. aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf
  36641. VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf
  36642. XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0
  36643. ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB
  36644. /gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA
  36645. TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M
  36646. H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe
  36647. Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF
  36648. HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh
  36649. wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB
  36650. AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT
  36651. BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE
  36652. BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm
  36653. aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm
  36654. aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp
  36655. 1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0
  36656. dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG
  36657. /5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6
  36658. ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s
  36659. dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg
  36660. 9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH
  36661. foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du
  36662. qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr
  36663. P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq
  36664. c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z
  36665. 09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B
  36666. -----END CERTIFICATE-----
  36667. Go Daddy Root Certificate Authority - G2
  36668. ========================================
  36669. -----BEGIN CERTIFICATE-----
  36670. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  36671. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  36672. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  36673. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  36674. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  36675. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  36676. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  36677. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  36678. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  36679. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  36680. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  36681. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  36682. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  36683. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  36684. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  36685. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  36686. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  36687. -----END CERTIFICATE-----
  36688. Starfield Root Certificate Authority - G2
  36689. =========================================
  36690. -----BEGIN CERTIFICATE-----
  36691. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  36692. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  36693. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  36694. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  36695. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  36696. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  36697. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  36698. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  36699. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  36700. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  36701. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  36702. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  36703. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  36704. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  36705. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  36706. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  36707. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  36708. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  36709. -----END CERTIFICATE-----
  36710. Starfield Services Root Certificate Authority - G2
  36711. ==================================================
  36712. -----BEGIN CERTIFICATE-----
  36713. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  36714. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  36715. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  36716. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  36717. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  36718. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  36719. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  36720. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  36721. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  36722. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  36723. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  36724. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  36725. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  36726. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  36727. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  36728. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  36729. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  36730. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  36731. -----END CERTIFICATE-----
  36732. AffirmTrust Commercial
  36733. ======================
  36734. -----BEGIN CERTIFICATE-----
  36735. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  36736. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  36737. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  36738. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  36739. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  36740. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  36741. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  36742. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  36743. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  36744. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  36745. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  36746. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  36747. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  36748. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  36749. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  36750. -----END CERTIFICATE-----
  36751. AffirmTrust Networking
  36752. ======================
  36753. -----BEGIN CERTIFICATE-----
  36754. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  36755. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  36756. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  36757. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  36758. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  36759. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  36760. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  36761. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  36762. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  36763. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  36764. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  36765. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  36766. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  36767. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  36768. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  36769. -----END CERTIFICATE-----
  36770. AffirmTrust Premium
  36771. ===================
  36772. -----BEGIN CERTIFICATE-----
  36773. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  36774. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  36775. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  36776. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  36777. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  36778. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  36779. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  36780. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  36781. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  36782. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  36783. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  36784. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  36785. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  36786. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  36787. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  36788. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  36789. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  36790. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  36791. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  36792. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  36793. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  36794. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  36795. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  36796. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  36797. -----END CERTIFICATE-----
  36798. AffirmTrust Premium ECC
  36799. =======================
  36800. -----BEGIN CERTIFICATE-----
  36801. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  36802. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  36803. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  36804. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  36805. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  36806. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  36807. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  36808. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  36809. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  36810. eQ==
  36811. -----END CERTIFICATE-----
  36812. Certum Trusted Network CA
  36813. =========================
  36814. -----BEGIN CERTIFICATE-----
  36815. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  36816. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  36817. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  36818. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  36819. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  36820. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  36821. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  36822. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  36823. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  36824. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  36825. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  36826. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  36827. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  36828. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  36829. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  36830. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  36831. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  36832. -----END CERTIFICATE-----
  36833. TWCA Root Certification Authority
  36834. =================================
  36835. -----BEGIN CERTIFICATE-----
  36836. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  36837. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  36838. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  36839. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  36840. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  36841. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  36842. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  36843. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  36844. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  36845. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  36846. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  36847. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  36848. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  36849. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  36850. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  36851. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  36852. -----END CERTIFICATE-----
  36853. Security Communication RootCA2
  36854. ==============================
  36855. -----BEGIN CERTIFICATE-----
  36856. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  36857. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  36858. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  36859. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  36860. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  36861. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  36862. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  36863. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  36864. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  36865. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  36866. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  36867. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  36868. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  36869. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  36870. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  36871. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  36872. -----END CERTIFICATE-----
  36873. EC-ACC
  36874. ======
  36875. -----BEGIN CERTIFICATE-----
  36876. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  36877. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  36878. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  36879. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  36880. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  36881. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  36882. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  36883. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  36884. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  36885. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  36886. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  36887. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  36888. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  36889. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  36890. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  36891. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  36892. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  36893. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  36894. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  36895. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  36896. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  36897. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  36898. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  36899. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  36900. 5EI=
  36901. -----END CERTIFICATE-----
  36902. Hellenic Academic and Research Institutions RootCA 2011
  36903. =======================================================
  36904. -----BEGIN CERTIFICATE-----
  36905. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  36906. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  36907. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  36908. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  36909. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  36910. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  36911. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  36912. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  36913. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  36914. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  36915. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  36916. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  36917. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  36918. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  36919. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  36920. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  36921. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  36922. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  36923. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  36924. -----END CERTIFICATE-----
  36925. Actalis Authentication Root CA
  36926. ==============================
  36927. -----BEGIN CERTIFICATE-----
  36928. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  36929. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  36930. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  36931. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  36932. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  36933. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  36934. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  36935. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  36936. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  36937. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  36938. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  36939. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  36940. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  36941. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  36942. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  36943. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  36944. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  36945. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  36946. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  36947. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  36948. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  36949. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  36950. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  36951. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  36952. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  36953. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  36954. -----END CERTIFICATE-----
  36955. Trustis FPS Root CA
  36956. ===================
  36957. -----BEGIN CERTIFICATE-----
  36958. MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG
  36959. EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290
  36960. IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV
  36961. BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ
  36962. KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ
  36963. RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk
  36964. H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa
  36965. cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt
  36966. o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA
  36967. AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd
  36968. BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c
  36969. GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC
  36970. yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P
  36971. 8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV
  36972. l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl
  36973. iB6XzCGcKQENZetX2fNXlrtIzYE=
  36974. -----END CERTIFICATE-----
  36975. Buypass Class 2 Root CA
  36976. =======================
  36977. -----BEGIN CERTIFICATE-----
  36978. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  36979. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  36980. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  36981. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  36982. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  36983. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  36984. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  36985. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  36986. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  36987. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  36988. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  36989. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  36990. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  36991. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  36992. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  36993. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  36994. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  36995. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  36996. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  36997. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  36998. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  36999. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  37000. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  37001. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  37002. rJgWVqA=
  37003. -----END CERTIFICATE-----
  37004. Buypass Class 3 Root CA
  37005. =======================
  37006. -----BEGIN CERTIFICATE-----
  37007. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  37008. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  37009. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  37010. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  37011. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  37012. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  37013. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  37014. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  37015. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  37016. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  37017. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  37018. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  37019. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  37020. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  37021. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  37022. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  37023. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  37024. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  37025. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  37026. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  37027. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  37028. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  37029. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  37030. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  37031. Cp/HuZc=
  37032. -----END CERTIFICATE-----
  37033. T-TeleSec GlobalRoot Class 3
  37034. ============================
  37035. -----BEGIN CERTIFICATE-----
  37036. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37037. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37038. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  37039. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37040. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37041. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  37042. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  37043. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  37044. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  37045. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  37046. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  37047. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  37048. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  37049. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  37050. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  37051. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  37052. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  37053. -----END CERTIFICATE-----
  37054. EE Certification Centre Root CA
  37055. ===============================
  37056. -----BEGIN CERTIFICATE-----
  37057. MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQG
  37058. EwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1czEoMCYGA1UEAwwfRUUgQ2Vy
  37059. dGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYGCSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIw
  37060. MTAxMDMwMTAxMDMwWhgPMjAzMDEyMTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlB
  37061. UyBTZXJ0aWZpdHNlZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRy
  37062. ZSBSb290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEBAQUAA4IB
  37063. DwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUyeuuOF0+W2Ap7kaJjbMeM
  37064. TC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvObntl8jixwKIy72KyaOBhU8E2lf/slLo2
  37065. rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIwWFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw
  37066. 93X2PaRka9ZP585ArQ/dMtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtN
  37067. P2MbRMNE1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYDVR0T
  37068. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/zQas8fElyalL1BSZ
  37069. MEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEF
  37070. BQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEFBQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+Rj
  37071. xY6hUFaTlrg4wCQiZrxTFGGVv9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqM
  37072. lIpPnTX/dqQGE5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u
  37073. uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIWiAYLtqZLICjU
  37074. 3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/vGVCJYMzpJJUPwssd8m92kMfM
  37075. dcGWxZ0=
  37076. -----END CERTIFICATE-----
  37077. D-TRUST Root Class 3 CA 2 2009
  37078. ==============================
  37079. -----BEGIN CERTIFICATE-----
  37080. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37081. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  37082. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  37083. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  37084. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  37085. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  37086. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  37087. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  37088. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  37089. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  37090. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  37091. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  37092. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  37093. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  37094. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  37095. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  37096. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  37097. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  37098. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  37099. -----END CERTIFICATE-----
  37100. D-TRUST Root Class 3 CA 2 EV 2009
  37101. =================================
  37102. -----BEGIN CERTIFICATE-----
  37103. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37104. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37105. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37106. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37107. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  37108. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  37109. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  37110. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  37111. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  37112. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  37113. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  37114. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  37115. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  37116. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  37117. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  37118. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  37119. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  37120. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  37121. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  37122. w9y4AyHqnxbxLFS1
  37123. -----END CERTIFICATE-----
  37124. CA Disig Root R2
  37125. ================
  37126. -----BEGIN CERTIFICATE-----
  37127. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  37128. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  37129. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  37130. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  37131. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  37132. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  37133. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  37134. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  37135. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  37136. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  37137. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  37138. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  37139. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  37140. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  37141. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  37142. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  37143. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  37144. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  37145. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  37146. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  37147. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  37148. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  37149. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  37150. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  37151. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  37152. -----END CERTIFICATE-----
  37153. ACCVRAIZ1
  37154. =========
  37155. -----BEGIN CERTIFICATE-----
  37156. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  37157. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  37158. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  37159. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  37160. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  37161. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  37162. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  37163. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  37164. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  37165. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  37166. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  37167. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  37168. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  37169. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  37170. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  37171. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  37172. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  37173. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  37174. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  37175. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  37176. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  37177. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  37178. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  37179. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  37180. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  37181. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  37182. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  37183. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  37184. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  37185. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  37186. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  37187. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  37188. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  37189. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  37190. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  37191. EfbRD0tVNEYqi4Y7
  37192. -----END CERTIFICATE-----
  37193. TWCA Global Root CA
  37194. ===================
  37195. -----BEGIN CERTIFICATE-----
  37196. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  37197. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  37198. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  37199. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  37200. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  37201. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  37202. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  37203. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  37204. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  37205. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  37206. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  37207. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  37208. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  37209. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  37210. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  37211. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  37212. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  37213. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  37214. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  37215. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  37216. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  37217. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  37218. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  37219. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  37220. -----END CERTIFICATE-----
  37221. TeliaSonera Root CA v1
  37222. ======================
  37223. -----BEGIN CERTIFICATE-----
  37224. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  37225. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  37226. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  37227. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  37228. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  37229. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  37230. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  37231. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  37232. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  37233. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  37234. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  37235. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  37236. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  37237. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  37238. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  37239. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  37240. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  37241. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  37242. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  37243. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  37244. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  37245. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  37246. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  37247. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  37248. -----END CERTIFICATE-----
  37249. E-Tugra Certification Authority
  37250. ===============================
  37251. -----BEGIN CERTIFICATE-----
  37252. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  37253. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  37254. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  37255. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  37256. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  37257. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  37258. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  37259. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  37260. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  37261. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  37262. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  37263. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  37264. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  37265. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  37266. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  37267. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  37268. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  37269. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  37270. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  37271. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  37272. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  37273. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  37274. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  37275. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  37276. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  37277. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  37278. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  37279. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  37280. C7TbO6Orb1wdtn7os4I07QZcJA==
  37281. -----END CERTIFICATE-----
  37282. T-TeleSec GlobalRoot Class 2
  37283. ============================
  37284. -----BEGIN CERTIFICATE-----
  37285. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37286. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37287. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  37288. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37289. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37290. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  37291. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  37292. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  37293. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  37294. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  37295. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  37296. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  37297. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  37298. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  37299. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  37300. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  37301. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  37302. -----END CERTIFICATE-----
  37303. Atos TrustedRoot 2011
  37304. =====================
  37305. -----BEGIN CERTIFICATE-----
  37306. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  37307. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  37308. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  37309. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  37310. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  37311. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  37312. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  37313. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  37314. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  37315. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  37316. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  37317. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  37318. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  37319. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  37320. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  37321. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  37322. -----END CERTIFICATE-----
  37323. QuoVadis Root CA 1 G3
  37324. =====================
  37325. -----BEGIN CERTIFICATE-----
  37326. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37327. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37328. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  37329. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  37330. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  37331. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  37332. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  37333. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  37334. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  37335. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  37336. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  37337. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  37338. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  37339. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37340. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  37341. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  37342. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  37343. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  37344. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  37345. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  37346. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  37347. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  37348. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  37349. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  37350. hMJKzRwuJIczYOXD
  37351. -----END CERTIFICATE-----
  37352. QuoVadis Root CA 2 G3
  37353. =====================
  37354. -----BEGIN CERTIFICATE-----
  37355. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37356. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37357. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  37358. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  37359. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  37360. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  37361. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  37362. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  37363. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  37364. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  37365. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  37366. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  37367. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  37368. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37369. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  37370. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  37371. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  37372. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  37373. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  37374. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  37375. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  37376. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  37377. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  37378. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  37379. O3jtZsSOeWmD3n+M
  37380. -----END CERTIFICATE-----
  37381. QuoVadis Root CA 3 G3
  37382. =====================
  37383. -----BEGIN CERTIFICATE-----
  37384. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  37385. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37386. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  37387. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  37388. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  37389. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  37390. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  37391. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  37392. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  37393. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  37394. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  37395. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  37396. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  37397. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37398. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  37399. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  37400. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  37401. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  37402. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  37403. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  37404. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  37405. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  37406. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  37407. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  37408. PpxxVJkES/1Y+Zj0
  37409. -----END CERTIFICATE-----
  37410. DigiCert Assured ID Root G2
  37411. ===========================
  37412. -----BEGIN CERTIFICATE-----
  37413. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  37414. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  37415. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  37416. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  37417. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  37418. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  37419. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  37420. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  37421. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  37422. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  37423. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  37424. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  37425. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  37426. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  37427. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  37428. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  37429. IhNzbM8m9Yop5w==
  37430. -----END CERTIFICATE-----
  37431. DigiCert Assured ID Root G3
  37432. ===========================
  37433. -----BEGIN CERTIFICATE-----
  37434. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  37435. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  37436. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37437. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37438. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  37439. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  37440. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  37441. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  37442. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  37443. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  37444. 1vUhZscv6pZjamVFkpUBtA==
  37445. -----END CERTIFICATE-----
  37446. DigiCert Global Root G2
  37447. =======================
  37448. -----BEGIN CERTIFICATE-----
  37449. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  37450. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  37451. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  37452. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  37453. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  37454. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  37455. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  37456. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  37457. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  37458. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  37459. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  37460. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  37461. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  37462. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  37463. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  37464. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  37465. MrY=
  37466. -----END CERTIFICATE-----
  37467. DigiCert Global Root G3
  37468. =======================
  37469. -----BEGIN CERTIFICATE-----
  37470. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  37471. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  37472. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  37473. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  37474. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  37475. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  37476. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  37477. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  37478. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  37479. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  37480. VOKa5Vt8sycX
  37481. -----END CERTIFICATE-----
  37482. DigiCert Trusted Root G4
  37483. ========================
  37484. -----BEGIN CERTIFICATE-----
  37485. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  37486. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  37487. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37488. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37489. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  37490. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  37491. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  37492. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  37493. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  37494. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  37495. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  37496. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  37497. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  37498. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  37499. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  37500. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  37501. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  37502. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  37503. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  37504. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  37505. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  37506. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  37507. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  37508. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  37509. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  37510. 82Z+
  37511. -----END CERTIFICATE-----
  37512. COMODO RSA Certification Authority
  37513. ==================================
  37514. -----BEGIN CERTIFICATE-----
  37515. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  37516. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  37517. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  37518. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  37519. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  37520. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  37521. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  37522. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  37523. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  37524. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  37525. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  37526. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  37527. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  37528. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  37529. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  37530. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  37531. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  37532. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  37533. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  37534. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  37535. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  37536. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  37537. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  37538. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  37539. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  37540. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  37541. LaZRfyHBNVOFBkpdn627G190
  37542. -----END CERTIFICATE-----
  37543. USERTrust RSA Certification Authority
  37544. =====================================
  37545. -----BEGIN CERTIFICATE-----
  37546. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  37547. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37548. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37549. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  37550. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37551. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37552. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  37553. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  37554. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  37555. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  37556. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  37557. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  37558. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  37559. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  37560. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  37561. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  37562. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  37563. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  37564. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  37565. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  37566. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  37567. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  37568. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  37569. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  37570. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  37571. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  37572. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  37573. -----END CERTIFICATE-----
  37574. USERTrust ECC Certification Authority
  37575. =====================================
  37576. -----BEGIN CERTIFICATE-----
  37577. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  37578. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37579. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37580. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  37581. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37582. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37583. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  37584. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  37585. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  37586. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  37587. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  37588. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  37589. -----END CERTIFICATE-----
  37590. GlobalSign ECC Root CA - R4
  37591. ===========================
  37592. -----BEGIN CERTIFICATE-----
  37593. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  37594. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37595. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37596. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37597. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  37598. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  37599. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  37600. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  37601. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  37602. -----END CERTIFICATE-----
  37603. GlobalSign ECC Root CA - R5
  37604. ===========================
  37605. -----BEGIN CERTIFICATE-----
  37606. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  37607. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37608. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37609. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37610. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  37611. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  37612. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  37613. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  37614. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  37615. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  37616. -----END CERTIFICATE-----
  37617. Staat der Nederlanden Root CA - G3
  37618. ==================================
  37619. -----BEGIN CERTIFICATE-----
  37620. MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
  37621. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  37622. Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
  37623. TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
  37624. ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
  37625. olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
  37626. x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
  37627. EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
  37628. Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
  37629. mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5
  37630. 1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp
  37631. 07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHPbMk7ccHViLVlvMDo
  37632. FxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXtBznaqB16nzaeErAMZRKQFWDZJkBE
  37633. 41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTtXUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMB
  37634. AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleu
  37635. yjWcLhL75LpdINyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD
  37636. U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwpLiniyMMB8jPq
  37637. KqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8Ipf3YF3qKS9Ysr1YvY2WTxB1
  37638. v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixpgZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA
  37639. 8KCWAg8zxXHzniN9lLf9OtMJgwYh/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b
  37640. 8KKaa8MFSu1BYBQw0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0r
  37641. mj1AfsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq4BZ+Extq
  37642. 1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR1VmiiXTTn74eS9fGbbeI
  37643. JG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV
  37644. tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk=
  37645. -----END CERTIFICATE-----
  37646. Staat der Nederlanden EV Root CA
  37647. ================================
  37648. -----BEGIN CERTIFICATE-----
  37649. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  37650. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  37651. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  37652. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  37653. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  37654. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  37655. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  37656. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  37657. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  37658. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  37659. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  37660. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  37661. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  37662. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  37663. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  37664. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  37665. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  37666. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  37667. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  37668. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  37669. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  37670. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  37671. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  37672. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  37673. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  37674. -----END CERTIFICATE-----
  37675. IdenTrust Commercial Root CA 1
  37676. ==============================
  37677. -----BEGIN CERTIFICATE-----
  37678. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  37679. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  37680. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  37681. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  37682. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  37683. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  37684. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  37685. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  37686. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  37687. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  37688. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  37689. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  37690. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  37691. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  37692. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  37693. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  37694. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  37695. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  37696. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  37697. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  37698. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  37699. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  37700. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  37701. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  37702. cGzM7vRX+Bi6hG6H
  37703. -----END CERTIFICATE-----
  37704. IdenTrust Public Sector Root CA 1
  37705. =================================
  37706. -----BEGIN CERTIFICATE-----
  37707. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  37708. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  37709. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  37710. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  37711. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  37712. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  37713. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  37714. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  37715. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  37716. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  37717. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  37718. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  37719. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  37720. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  37721. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  37722. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  37723. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  37724. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  37725. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  37726. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  37727. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  37728. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  37729. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  37730. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  37731. 3Wl9af0AVqW3rLatt8o+Ae+c
  37732. -----END CERTIFICATE-----
  37733. Entrust Root Certification Authority - G2
  37734. =========================================
  37735. -----BEGIN CERTIFICATE-----
  37736. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  37737. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  37738. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  37739. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  37740. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  37741. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  37742. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  37743. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  37744. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  37745. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  37746. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  37747. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  37748. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  37749. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  37750. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  37751. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  37752. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  37753. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  37754. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  37755. e4pIb4tF9g==
  37756. -----END CERTIFICATE-----
  37757. Entrust Root Certification Authority - EC1
  37758. ==========================================
  37759. -----BEGIN CERTIFICATE-----
  37760. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  37761. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  37762. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  37763. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  37764. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  37765. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  37766. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  37767. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  37768. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  37769. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  37770. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  37771. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  37772. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  37773. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  37774. -----END CERTIFICATE-----
  37775. CFCA EV ROOT
  37776. ============
  37777. -----BEGIN CERTIFICATE-----
  37778. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  37779. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  37780. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  37781. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  37782. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  37783. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  37784. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  37785. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  37786. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  37787. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  37788. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  37789. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  37790. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  37791. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  37792. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  37793. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  37794. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  37795. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  37796. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  37797. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  37798. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  37799. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  37800. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  37801. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  37802. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  37803. -----END CERTIFICATE-----
  37804. OISTE WISeKey Global Root GB CA
  37805. ===============================
  37806. -----BEGIN CERTIFICATE-----
  37807. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  37808. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  37809. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  37810. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  37811. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  37812. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  37813. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  37814. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  37815. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  37816. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  37817. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  37818. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  37819. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  37820. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  37821. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  37822. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  37823. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  37824. -----END CERTIFICATE-----
  37825. SZAFIR ROOT CA2
  37826. ===============
  37827. -----BEGIN CERTIFICATE-----
  37828. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  37829. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  37830. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  37831. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  37832. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  37833. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  37834. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  37835. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  37836. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  37837. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  37838. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  37839. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  37840. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  37841. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  37842. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  37843. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  37844. -----END CERTIFICATE-----
  37845. Certum Trusted Network CA 2
  37846. ===========================
  37847. -----BEGIN CERTIFICATE-----
  37848. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  37849. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  37850. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  37851. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  37852. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  37853. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  37854. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  37855. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  37856. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  37857. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  37858. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  37859. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  37860. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  37861. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  37862. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  37863. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37864. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  37865. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  37866. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  37867. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  37868. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  37869. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  37870. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  37871. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  37872. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  37873. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  37874. zAYspsbiDrW5viSP
  37875. -----END CERTIFICATE-----
  37876. Hellenic Academic and Research Institutions RootCA 2015
  37877. =======================================================
  37878. -----BEGIN CERTIFICATE-----
  37879. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  37880. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  37881. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  37882. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  37883. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  37884. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  37885. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  37886. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  37887. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  37888. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  37889. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  37890. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  37891. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  37892. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  37893. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  37894. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  37895. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37896. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  37897. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  37898. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  37899. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  37900. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  37901. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  37902. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  37903. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  37904. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  37905. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  37906. p/UsQu0yrbYhnr68
  37907. -----END CERTIFICATE-----
  37908. Hellenic Academic and Research Institutions ECC RootCA 2015
  37909. ===========================================================
  37910. -----BEGIN CERTIFICATE-----
  37911. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  37912. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  37913. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  37914. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  37915. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  37916. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  37917. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  37918. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  37919. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  37920. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  37921. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  37922. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  37923. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  37924. -----END CERTIFICATE-----
  37925. ISRG Root X1
  37926. ============
  37927. -----BEGIN CERTIFICATE-----
  37928. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  37929. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  37930. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  37931. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  37932. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  37933. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  37934. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  37935. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  37936. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  37937. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  37938. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  37939. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  37940. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  37941. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  37942. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  37943. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  37944. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  37945. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  37946. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  37947. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  37948. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  37949. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  37950. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  37951. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  37952. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  37953. -----END CERTIFICATE-----
  37954. AC RAIZ FNMT-RCM
  37955. ================
  37956. -----BEGIN CERTIFICATE-----
  37957. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  37958. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  37959. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  37960. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  37961. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  37962. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  37963. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  37964. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  37965. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  37966. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  37967. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  37968. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  37969. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  37970. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  37971. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  37972. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  37973. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  37974. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  37975. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  37976. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  37977. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  37978. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  37979. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  37980. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  37981. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  37982. -----END CERTIFICATE-----
  37983. Amazon Root CA 1
  37984. ================
  37985. -----BEGIN CERTIFICATE-----
  37986. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  37987. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  37988. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  37989. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  37990. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  37991. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  37992. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  37993. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  37994. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  37995. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  37996. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  37997. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  37998. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  37999. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  38000. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  38001. -----END CERTIFICATE-----
  38002. Amazon Root CA 2
  38003. ================
  38004. -----BEGIN CERTIFICATE-----
  38005. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  38006. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  38007. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  38008. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  38009. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  38010. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  38011. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  38012. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  38013. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  38014. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  38015. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  38016. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  38017. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  38018. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  38019. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  38020. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  38021. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  38022. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  38023. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  38024. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  38025. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  38026. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  38027. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  38028. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  38029. -----END CERTIFICATE-----
  38030. Amazon Root CA 3
  38031. ================
  38032. -----BEGIN CERTIFICATE-----
  38033. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  38034. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  38035. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38036. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  38037. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  38038. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  38039. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  38040. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  38041. -----END CERTIFICATE-----
  38042. Amazon Root CA 4
  38043. ================
  38044. -----BEGIN CERTIFICATE-----
  38045. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  38046. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  38047. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38048. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  38049. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  38050. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  38051. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  38052. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  38053. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  38054. -----END CERTIFICATE-----
  38055. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  38056. =============================================
  38057. -----BEGIN CERTIFICATE-----
  38058. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  38059. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  38060. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  38061. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  38062. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  38063. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  38064. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  38065. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  38066. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  38067. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  38068. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  38069. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  38070. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  38071. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  38072. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  38073. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  38074. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  38075. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  38076. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  38077. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  38078. -----END CERTIFICATE-----
  38079. GDCA TrustAUTH R5 ROOT
  38080. ======================
  38081. -----BEGIN CERTIFICATE-----
  38082. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  38083. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  38084. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  38085. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  38086. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  38087. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  38088. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  38089. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  38090. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  38091. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  38092. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  38093. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  38094. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  38095. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  38096. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  38097. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  38098. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  38099. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  38100. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  38101. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  38102. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  38103. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  38104. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  38105. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  38106. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  38107. -----END CERTIFICATE-----
  38108. TrustCor RootCert CA-1
  38109. ======================
  38110. -----BEGIN CERTIFICATE-----
  38111. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  38112. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38113. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38114. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  38115. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  38116. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  38117. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  38118. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  38119. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  38120. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  38121. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  38122. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  38123. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  38124. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  38125. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  38126. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  38127. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  38128. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  38129. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  38130. -----END CERTIFICATE-----
  38131. TrustCor RootCert CA-2
  38132. ======================
  38133. -----BEGIN CERTIFICATE-----
  38134. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  38135. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  38136. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  38137. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  38138. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  38139. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  38140. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  38141. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  38142. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  38143. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  38144. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  38145. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  38146. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  38147. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  38148. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  38149. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  38150. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  38151. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  38152. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  38153. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  38154. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  38155. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  38156. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  38157. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  38158. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  38159. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  38160. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  38161. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  38162. -----END CERTIFICATE-----
  38163. TrustCor ECA-1
  38164. ==============
  38165. -----BEGIN CERTIFICATE-----
  38166. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  38167. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38168. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38169. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  38170. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  38171. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  38172. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  38173. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  38174. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  38175. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  38176. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  38177. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  38178. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  38179. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  38180. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  38181. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  38182. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  38183. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  38184. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  38185. -----END CERTIFICATE-----
  38186. SSL.com Root Certification Authority RSA
  38187. ========================================
  38188. -----BEGIN CERTIFICATE-----
  38189. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  38190. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  38191. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  38192. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38193. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  38194. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  38195. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  38196. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  38197. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  38198. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  38199. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  38200. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  38201. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  38202. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  38203. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  38204. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  38205. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  38206. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  38207. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  38208. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  38209. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  38210. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  38211. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  38212. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  38213. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  38214. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  38215. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  38216. -----END CERTIFICATE-----
  38217. SSL.com Root Certification Authority ECC
  38218. ========================================
  38219. -----BEGIN CERTIFICATE-----
  38220. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  38221. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  38222. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  38223. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  38224. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  38225. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  38226. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  38227. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  38228. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  38229. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  38230. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  38231. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  38232. -----END CERTIFICATE-----
  38233. SSL.com EV Root Certification Authority RSA R2
  38234. ==============================================
  38235. -----BEGIN CERTIFICATE-----
  38236. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  38237. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  38238. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  38239. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  38240. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  38241. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  38242. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  38243. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  38244. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  38245. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  38246. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  38247. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  38248. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  38249. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  38250. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  38251. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  38252. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  38253. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  38254. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  38255. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  38256. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  38257. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  38258. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  38259. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  38260. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  38261. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  38262. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  38263. -----END CERTIFICATE-----
  38264. SSL.com EV Root Certification Authority ECC
  38265. ===========================================
  38266. -----BEGIN CERTIFICATE-----
  38267. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  38268. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  38269. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  38270. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38271. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  38272. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  38273. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  38274. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  38275. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  38276. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  38277. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  38278. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  38279. -----END CERTIFICATE-----
  38280. GlobalSign Root CA - R6
  38281. =======================
  38282. -----BEGIN CERTIFICATE-----
  38283. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  38284. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  38285. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  38286. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  38287. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  38288. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  38289. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  38290. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  38291. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  38292. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  38293. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  38294. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  38295. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  38296. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  38297. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  38298. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  38299. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  38300. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  38301. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  38302. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  38303. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  38304. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  38305. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  38306. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  38307. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  38308. -----END CERTIFICATE-----
  38309. OISTE WISeKey Global Root GC CA
  38310. ===============================
  38311. -----BEGIN CERTIFICATE-----
  38312. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  38313. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  38314. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  38315. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  38316. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  38317. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  38318. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  38319. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  38320. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  38321. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  38322. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  38323. -----END CERTIFICATE-----
  38324. GTS Root R1
  38325. ===========
  38326. -----BEGIN CERTIFICATE-----
  38327. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38328. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38329. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38330. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  38331. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  38332. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  38333. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  38334. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  38335. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  38336. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  38337. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  38338. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  38339. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  38340. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38341. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  38342. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  38343. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  38344. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  38345. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  38346. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  38347. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  38348. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  38349. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  38350. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  38351. CFF1pkgl
  38352. -----END CERTIFICATE-----
  38353. GTS Root R2
  38354. ===========
  38355. -----BEGIN CERTIFICATE-----
  38356. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38357. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38358. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38359. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  38360. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  38361. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  38362. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  38363. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  38364. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  38365. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  38366. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  38367. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  38368. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  38369. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38370. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  38371. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  38372. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  38373. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  38374. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  38375. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  38376. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  38377. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  38378. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  38379. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  38380. o/DUhgkC
  38381. -----END CERTIFICATE-----
  38382. GTS Root R3
  38383. ===========
  38384. -----BEGIN CERTIFICATE-----
  38385. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38386. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38387. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38388. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  38389. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  38390. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  38391. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  38392. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  38393. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  38394. KaqW04MjyaR7YbPMAuhd
  38395. -----END CERTIFICATE-----
  38396. GTS Root R4
  38397. ===========
  38398. -----BEGIN CERTIFICATE-----
  38399. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38400. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38401. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38402. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  38403. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  38404. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  38405. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  38406. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  38407. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  38408. zPKwTdb+mciUqXWi4w==
  38409. -----END CERTIFICATE-----
  38410. UCA Global G2 Root
  38411. ==================
  38412. -----BEGIN CERTIFICATE-----
  38413. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  38414. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  38415. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  38416. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  38417. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  38418. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  38419. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  38420. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  38421. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  38422. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  38423. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  38424. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  38425. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  38426. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  38427. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  38428. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  38429. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  38430. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  38431. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  38432. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  38433. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  38434. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  38435. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  38436. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  38437. -----END CERTIFICATE-----
  38438. UCA Extended Validation Root
  38439. ============================
  38440. -----BEGIN CERTIFICATE-----
  38441. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  38442. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  38443. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  38444. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  38445. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  38446. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  38447. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  38448. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  38449. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  38450. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  38451. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  38452. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  38453. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  38454. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  38455. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  38456. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  38457. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  38458. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  38459. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  38460. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  38461. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  38462. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  38463. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  38464. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  38465. dhh2n1ax
  38466. -----END CERTIFICATE-----
  38467. Certigna Root CA
  38468. ================
  38469. -----BEGIN CERTIFICATE-----
  38470. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  38471. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  38472. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  38473. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  38474. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  38475. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  38476. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  38477. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  38478. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  38479. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  38480. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  38481. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  38482. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  38483. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  38484. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  38485. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  38486. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  38487. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  38488. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  38489. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  38490. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  38491. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  38492. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  38493. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  38494. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  38495. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  38496. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  38497. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  38498. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  38499. -----END CERTIFICATE-----
  38500. emSign Root CA - G1
  38501. ===================
  38502. -----BEGIN CERTIFICATE-----
  38503. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  38504. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  38505. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  38506. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  38507. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  38508. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  38509. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  38510. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  38511. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  38512. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  38513. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  38514. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  38515. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  38516. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  38517. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  38518. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  38519. iN66zB+Afko=
  38520. -----END CERTIFICATE-----
  38521. emSign ECC Root CA - G3
  38522. =======================
  38523. -----BEGIN CERTIFICATE-----
  38524. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  38525. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  38526. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  38527. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  38528. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  38529. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  38530. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  38531. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  38532. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  38533. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  38534. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  38535. -----END CERTIFICATE-----
  38536. emSign Root CA - C1
  38537. ===================
  38538. -----BEGIN CERTIFICATE-----
  38539. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  38540. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  38541. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  38542. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  38543. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  38544. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  38545. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  38546. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  38547. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  38548. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  38549. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  38550. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  38551. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  38552. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  38553. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  38554. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  38555. -----END CERTIFICATE-----
  38556. emSign ECC Root CA - C3
  38557. =======================
  38558. -----BEGIN CERTIFICATE-----
  38559. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  38560. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  38561. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  38562. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  38563. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  38564. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  38565. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  38566. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  38567. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  38568. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  38569. -----END CERTIFICATE-----
  38570. Hongkong Post Root CA 3
  38571. =======================
  38572. -----BEGIN CERTIFICATE-----
  38573. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  38574. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  38575. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  38576. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  38577. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  38578. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  38579. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  38580. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  38581. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  38582. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  38583. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  38584. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  38585. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  38586. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  38587. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  38588. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  38589. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  38590. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  38591. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  38592. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  38593. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  38594. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  38595. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  38596. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  38597. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  38598. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  38599. dBb9HxEGmpv0
  38600. -----END CERTIFICATE-----
  38601. Entrust Root Certification Authority - G4
  38602. =========================================
  38603. -----BEGIN CERTIFICATE-----
  38604. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  38605. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  38606. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  38607. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  38608. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  38609. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  38610. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  38611. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  38612. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  38613. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  38614. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  38615. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  38616. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  38617. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  38618. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  38619. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  38620. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  38621. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  38622. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  38623. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  38624. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  38625. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  38626. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  38627. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  38628. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  38629. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  38630. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  38631. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  38632. kcpG2om3PVODLAgfi49T3f+sHw==
  38633. -----END CERTIFICATE-----
  38634. Microsoft ECC Root Certificate Authority 2017
  38635. =============================================
  38636. -----BEGIN CERTIFICATE-----
  38637. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  38638. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  38639. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  38640. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  38641. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  38642. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  38643. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  38644. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  38645. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  38646. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  38647. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  38648. -----END CERTIFICATE-----
  38649. Microsoft RSA Root Certificate Authority 2017
  38650. =============================================
  38651. -----BEGIN CERTIFICATE-----
  38652. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  38653. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  38654. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  38655. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  38656. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  38657. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  38658. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  38659. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  38660. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  38661. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  38662. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  38663. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  38664. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  38665. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  38666. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  38667. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  38668. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  38669. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  38670. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  38671. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  38672. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  38673. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  38674. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  38675. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  38676. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  38677. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  38678. -----END CERTIFICATE-----
  38679. e-Szigno Root CA 2017
  38680. =====================
  38681. -----BEGIN CERTIFICATE-----
  38682. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  38683. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  38684. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  38685. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  38686. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  38687. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  38688. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  38689. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  38690. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  38691. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  38692. svxyqltZ+efcMQ==
  38693. -----END CERTIFICATE-----
  38694. certSIGN Root CA G2
  38695. ===================
  38696. -----BEGIN CERTIFICATE-----
  38697. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  38698. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  38699. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  38700. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  38701. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  38702. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  38703. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  38704. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  38705. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  38706. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  38707. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  38708. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  38709. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  38710. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  38711. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  38712. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  38713. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  38714. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  38715. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  38716. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  38717. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  38718. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  38719. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  38720. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  38721. -----END CERTIFICATE-----
  38722. <?php
  38723. namespace Composer\CaBundle;
  38724. use Psr\Log\LoggerInterface;
  38725. use Symfony\Component\Process\PhpProcess;
  38726. class CaBundle
  38727. {
  38728. private static $caPath;
  38729. private static $caFileValidity = array();
  38730. private static $useOpensslParse;
  38731. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  38732. {
  38733. if (self::$caPath !== null) {
  38734. return self::$caPath;
  38735. }
  38736. $caBundlePaths = array();
  38737. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  38738. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  38739. $caBundlePaths[] = ini_get('openssl.cafile');
  38740. $caBundlePaths[] = ini_get('openssl.capath');
  38741. $otherLocations = array(
  38742. '/etc/pki/tls/certs/ca-bundle.crt',
  38743. '/etc/ssl/certs/ca-certificates.crt',
  38744. '/etc/ssl/ca-bundle.pem',
  38745. '/usr/local/share/certs/ca-root-nss.crt',
  38746. '/usr/ssl/certs/ca-bundle.crt',
  38747. '/opt/local/share/curl/curl-ca-bundle.crt',
  38748. '/usr/local/share/curl/curl-ca-bundle.crt',
  38749. '/usr/share/ssl/certs/ca-bundle.crt',
  38750. '/etc/ssl/cert.pem',
  38751. '/usr/local/etc/ssl/cert.pem',
  38752. '/usr/local/etc/openssl/cert.pem',
  38753. '/usr/local/etc/openssl@1.1/cert.pem',
  38754. );
  38755. foreach($otherLocations as $location) {
  38756. $otherLocations[] = dirname($location);
  38757. }
  38758. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  38759. foreach ($caBundlePaths as $caBundle) {
  38760. if (self::caFileUsable($caBundle, $logger)) {
  38761. return self::$caPath = $caBundle;
  38762. }
  38763. if (self::caDirUsable($caBundle)) {
  38764. return self::$caPath = $caBundle;
  38765. }
  38766. }
  38767. return self::$caPath = static::getBundledCaBundlePath();
  38768. }
  38769. public static function getBundledCaBundlePath()
  38770. {
  38771. $caBundleFile = __DIR__.'/../res/cacert.pem';
  38772. if (0 === strpos($caBundleFile, 'phar://')) {
  38773. file_put_contents(
  38774. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-'),
  38775. file_get_contents($caBundleFile)
  38776. );
  38777. register_shutdown_function(function() use ($tempCaBundleFile) {
  38778. @unlink($tempCaBundleFile);
  38779. });
  38780. $caBundleFile = $tempCaBundleFile;
  38781. }
  38782. return $caBundleFile;
  38783. }
  38784. public static function validateCaFile($filename, LoggerInterface $logger = null)
  38785. {
  38786. static $warned = false;
  38787. if (isset(self::$caFileValidity[$filename])) {
  38788. return self::$caFileValidity[$filename];
  38789. }
  38790. $contents = file_get_contents($filename);
  38791. if (!static::isOpensslParseSafe()) {
  38792. if (!$warned && $logger) {
  38793. $logger->warning(sprintf(
  38794. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  38795. PHP_VERSION
  38796. ));
  38797. $warned = true;
  38798. }
  38799. $isValid = !empty($contents);
  38800. } else {
  38801. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  38802. $isValid = (bool) openssl_x509_parse($contents);
  38803. }
  38804. if ($logger) {
  38805. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  38806. }
  38807. return self::$caFileValidity[$filename] = $isValid;
  38808. }
  38809. public static function isOpensslParseSafe()
  38810. {
  38811. if (null !== self::$useOpensslParse) {
  38812. return self::$useOpensslParse;
  38813. }
  38814. if (PHP_VERSION_ID >= 50600) {
  38815. return self::$useOpensslParse = true;
  38816. }
  38817. if (
  38818. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  38819. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  38820. || (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50507)
  38821. ) {
  38822. return self::$useOpensslParse = true;
  38823. }
  38824. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  38825. return self::$useOpensslParse = false;
  38826. }
  38827. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  38828. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  38829. if (preg_match($regex, PHP_VERSION, $m)) {
  38830. return ((int) $m[1]) >= $fixedVersion;
  38831. }
  38832. return false;
  38833. };
  38834. if (
  38835. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  38836. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  38837. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  38838. ) {
  38839. return self::$useOpensslParse = true;
  38840. }
  38841. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  38842. return self::$useOpensslParse = false;
  38843. }
  38844. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  38845. $script = <<<'EOT'
  38846. error_reporting(-1);
  38847. $info = openssl_x509_parse(base64_decode('%s'));
  38848. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  38849. EOT;
  38850. $script = '<'."?php\n".sprintf($script, $cert);
  38851. try {
  38852. $process = new PhpProcess($script);
  38853. $process->mustRun();
  38854. } catch (\Exception $e) {
  38855. return self::$useOpensslParse = false;
  38856. }
  38857. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  38858. $errorOutput = trim($process->getErrorOutput());
  38859. if (
  38860. count($output) === 3
  38861. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  38862. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  38863. && $output[2] === 'int(-1)'
  38864. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  38865. ) {
  38866. return self::$useOpensslParse = true;
  38867. }
  38868. return self::$useOpensslParse = false;
  38869. }
  38870. public static function reset()
  38871. {
  38872. self::$caFileValidity = array();
  38873. self::$caPath = null;
  38874. self::$useOpensslParse = null;
  38875. }
  38876. private static function getEnvVariable($name)
  38877. {
  38878. if (isset($_SERVER[$name])) {
  38879. return (string) $_SERVER[$name];
  38880. }
  38881. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  38882. return (string) $value;
  38883. }
  38884. return false;
  38885. }
  38886. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  38887. {
  38888. return $certFile && @is_file($certFile) && @is_readable($certFile) && static::validateCaFile($certFile, $logger);
  38889. }
  38890. private static function caDirUsable($certDir)
  38891. {
  38892. return $certDir && @is_dir($certDir) && @is_readable($certDir) && glob($certDir . '/*');
  38893. }
  38894. }
  38895. <?php return array (
  38896. 'root' =>
  38897. array (
  38898. 'pretty_version' => '2.0.7',
  38899. 'version' => '2.0.7.0',
  38900. 'aliases' =>
  38901. array (
  38902. ),
  38903. 'reference' => 'cbee637510037f293e641857b2a6223d0ea8008d',
  38904. 'name' => 'composer/composer',
  38905. ),
  38906. 'versions' =>
  38907. array (
  38908. 'composer/ca-bundle' =>
  38909. array (
  38910. 'pretty_version' => '1.2.8',
  38911. 'version' => '1.2.8.0',
  38912. 'aliases' =>
  38913. array (
  38914. ),
  38915. 'reference' => '8a7ecad675253e4654ea05505233285377405215',
  38916. ),
  38917. 'composer/composer' =>
  38918. array (
  38919. 'pretty_version' => '2.0.7',
  38920. 'version' => '2.0.7.0',
  38921. 'aliases' =>
  38922. array (
  38923. ),
  38924. 'reference' => 'cbee637510037f293e641857b2a6223d0ea8008d',
  38925. ),
  38926. 'composer/semver' =>
  38927. array (
  38928. 'pretty_version' => '3.2.4',
  38929. 'version' => '3.2.4.0',
  38930. 'aliases' =>
  38931. array (
  38932. ),
  38933. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  38934. ),
  38935. 'composer/spdx-licenses' =>
  38936. array (
  38937. 'pretty_version' => '1.5.4',
  38938. 'version' => '1.5.4.0',
  38939. 'aliases' =>
  38940. array (
  38941. ),
  38942. 'reference' => '6946f785871e2314c60b4524851f3702ea4f2223',
  38943. ),
  38944. 'composer/xdebug-handler' =>
  38945. array (
  38946. 'pretty_version' => '1.4.5',
  38947. 'version' => '1.4.5.0',
  38948. 'aliases' =>
  38949. array (
  38950. ),
  38951. 'reference' => 'f28d44c286812c714741478d968104c5e604a1d4',
  38952. ),
  38953. 'justinrainbow/json-schema' =>
  38954. array (
  38955. 'pretty_version' => '5.2.10',
  38956. 'version' => '5.2.10.0',
  38957. 'aliases' =>
  38958. array (
  38959. ),
  38960. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  38961. ),
  38962. 'psr/log' =>
  38963. array (
  38964. 'pretty_version' => '1.1.3',
  38965. 'version' => '1.1.3.0',
  38966. 'aliases' =>
  38967. array (
  38968. ),
  38969. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  38970. ),
  38971. 'react/promise' =>
  38972. array (
  38973. 'pretty_version' => 'v1.2.1',
  38974. 'version' => '1.2.1.0',
  38975. 'aliases' =>
  38976. array (
  38977. ),
  38978. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  38979. ),
  38980. 'seld/jsonlint' =>
  38981. array (
  38982. 'pretty_version' => '1.8.3',
  38983. 'version' => '1.8.3.0',
  38984. 'aliases' =>
  38985. array (
  38986. ),
  38987. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  38988. ),
  38989. 'seld/phar-utils' =>
  38990. array (
  38991. 'pretty_version' => '1.1.1',
  38992. 'version' => '1.1.1.0',
  38993. 'aliases' =>
  38994. array (
  38995. ),
  38996. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  38997. ),
  38998. 'symfony/console' =>
  38999. array (
  39000. 'pretty_version' => 'v2.8.52',
  39001. 'version' => '2.8.52.0',
  39002. 'aliases' =>
  39003. array (
  39004. ),
  39005. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  39006. ),
  39007. 'symfony/debug' =>
  39008. array (
  39009. 'pretty_version' => 'v2.8.52',
  39010. 'version' => '2.8.52.0',
  39011. 'aliases' =>
  39012. array (
  39013. ),
  39014. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  39015. ),
  39016. 'symfony/filesystem' =>
  39017. array (
  39018. 'pretty_version' => 'v2.8.52',
  39019. 'version' => '2.8.52.0',
  39020. 'aliases' =>
  39021. array (
  39022. ),
  39023. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  39024. ),
  39025. 'symfony/finder' =>
  39026. array (
  39027. 'pretty_version' => 'v2.8.52',
  39028. 'version' => '2.8.52.0',
  39029. 'aliases' =>
  39030. array (
  39031. ),
  39032. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  39033. ),
  39034. 'symfony/polyfill-ctype' =>
  39035. array (
  39036. 'pretty_version' => 'v1.19.0',
  39037. 'version' => '1.19.0.0',
  39038. 'aliases' =>
  39039. array (
  39040. ),
  39041. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  39042. ),
  39043. 'symfony/polyfill-mbstring' =>
  39044. array (
  39045. 'pretty_version' => 'v1.19.0',
  39046. 'version' => '1.19.0.0',
  39047. 'aliases' =>
  39048. array (
  39049. ),
  39050. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  39051. ),
  39052. 'symfony/process' =>
  39053. array (
  39054. 'pretty_version' => 'v2.8.52',
  39055. 'version' => '2.8.52.0',
  39056. 'aliases' =>
  39057. array (
  39058. ),
  39059. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  39060. ),
  39061. ),
  39062. );
  39063. Copyright (C) 2015 Composer
  39064. Permission is hereby granted, free of charge, to any person obtaining a copy of
  39065. this software and associated documentation files (the "Software"), to deal in
  39066. the Software without restriction, including without limitation the rights to
  39067. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  39068. of the Software, and to permit persons to whom the Software is furnished to do
  39069. so, subject to the following conditions:
  39070. The above copyright notice and this permission notice shall be included in all
  39071. copies or substantial portions of the Software.
  39072. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39073. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  39074. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  39075. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39076. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39077. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  39078. SOFTWARE.
  39079. <?php
  39080. namespace Composer\Semver;
  39081. use Composer\Semver\Constraint\Constraint;
  39082. class Comparator
  39083. {
  39084. public static function greaterThan($version1, $version2)
  39085. {
  39086. return self::compare($version1, '>', $version2);
  39087. }
  39088. public static function greaterThanOrEqualTo($version1, $version2)
  39089. {
  39090. return self::compare($version1, '>=', $version2);
  39091. }
  39092. public static function lessThan($version1, $version2)
  39093. {
  39094. return self::compare($version1, '<', $version2);
  39095. }
  39096. public static function lessThanOrEqualTo($version1, $version2)
  39097. {
  39098. return self::compare($version1, '<=', $version2);
  39099. }
  39100. public static function equalTo($version1, $version2)
  39101. {
  39102. return self::compare($version1, '==', $version2);
  39103. }
  39104. public static function notEqualTo($version1, $version2)
  39105. {
  39106. return self::compare($version1, '!=', $version2);
  39107. }
  39108. public static function compare($version1, $operator, $version2)
  39109. {
  39110. $constraint = new Constraint($operator, $version2);
  39111. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  39112. }
  39113. }
  39114. <?php
  39115. namespace Composer\Semver;
  39116. use Composer\Semver\Constraint\Constraint;
  39117. use Composer\Semver\Constraint\ConstraintInterface;
  39118. class CompilingMatcher
  39119. {
  39120. private static $compiledCheckerCache = array();
  39121. private static $enabled;
  39122. private static $transOpInt = array(
  39123. Constraint::OP_EQ => '==',
  39124. Constraint::OP_LT => '<',
  39125. Constraint::OP_LE => '<=',
  39126. Constraint::OP_GT => '>',
  39127. Constraint::OP_GE => '>=',
  39128. Constraint::OP_NE => '!=',
  39129. );
  39130. public static function match(ConstraintInterface $constraint, $operator, $version)
  39131. {
  39132. if (self::$enabled === null) {
  39133. self::$enabled = !\in_array('eval', explode(',', ini_get('disable_functions')), true);
  39134. }
  39135. if (!self::$enabled) {
  39136. return $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  39137. }
  39138. $cacheKey = $operator.$constraint;
  39139. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  39140. $code = $constraint->compile($operator);
  39141. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  39142. } else {
  39143. $function = self::$compiledCheckerCache[$cacheKey];
  39144. }
  39145. return $function($version, strpos($version, 'dev-') === 0);
  39146. }
  39147. }
  39148. <?php
  39149. namespace Composer\Semver\Constraint;
  39150. class Bound
  39151. {
  39152. private $version;
  39153. private $isInclusive;
  39154. public function __construct($version, $isInclusive)
  39155. {
  39156. $this->version = $version;
  39157. $this->isInclusive = $isInclusive;
  39158. }
  39159. public function getVersion()
  39160. {
  39161. return $this->version;
  39162. }
  39163. public function isInclusive()
  39164. {
  39165. return $this->isInclusive;
  39166. }
  39167. public function isZero()
  39168. {
  39169. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  39170. }
  39171. public function isPositiveInfinity()
  39172. {
  39173. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  39174. }
  39175. public function compareTo(Bound $other, $operator)
  39176. {
  39177. if (!\in_array($operator, array('<', '>'), true)) {
  39178. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  39179. }
  39180. if ($this == $other) {
  39181. return false;
  39182. }
  39183. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  39184. if (0 !== $compareResult) {
  39185. return (('>' === $operator) ? 1 : -1) === $compareResult;
  39186. }
  39187. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  39188. }
  39189. public function __toString()
  39190. {
  39191. return sprintf(
  39192. '%s [%s]',
  39193. $this->getVersion(),
  39194. $this->isInclusive() ? 'inclusive' : 'exclusive'
  39195. );
  39196. }
  39197. public static function zero()
  39198. {
  39199. return new Bound('0.0.0.0-dev', true);
  39200. }
  39201. public static function positiveInfinity()
  39202. {
  39203. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  39204. }
  39205. }
  39206. <?php
  39207. namespace Composer\Semver\Constraint;
  39208. class Constraint implements ConstraintInterface
  39209. {
  39210. const OP_EQ = 0;
  39211. const OP_LT = 1;
  39212. const OP_LE = 2;
  39213. const OP_GT = 3;
  39214. const OP_GE = 4;
  39215. const OP_NE = 5;
  39216. private static $transOpStr = array(
  39217. '=' => self::OP_EQ,
  39218. '==' => self::OP_EQ,
  39219. '<' => self::OP_LT,
  39220. '<=' => self::OP_LE,
  39221. '>' => self::OP_GT,
  39222. '>=' => self::OP_GE,
  39223. '<>' => self::OP_NE,
  39224. '!=' => self::OP_NE,
  39225. );
  39226. private static $transOpInt = array(
  39227. self::OP_EQ => '==',
  39228. self::OP_LT => '<',
  39229. self::OP_LE => '<=',
  39230. self::OP_GT => '>',
  39231. self::OP_GE => '>=',
  39232. self::OP_NE => '!=',
  39233. );
  39234. protected $operator;
  39235. protected $version;
  39236. protected $prettyString;
  39237. protected $lowerBound;
  39238. protected $upperBound;
  39239. public function __construct($operator, $version)
  39240. {
  39241. if (!isset(self::$transOpStr[$operator])) {
  39242. throw new \InvalidArgumentException(sprintf(
  39243. 'Invalid operator "%s" given, expected one of: %s',
  39244. $operator,
  39245. implode(', ', self::getSupportedOperators())
  39246. ));
  39247. }
  39248. $this->operator = self::$transOpStr[$operator];
  39249. $this->version = $version;
  39250. }
  39251. public function getVersion()
  39252. {
  39253. return $this->version;
  39254. }
  39255. public function getOperator()
  39256. {
  39257. return self::$transOpInt[$this->operator];
  39258. }
  39259. public function matches(ConstraintInterface $provider)
  39260. {
  39261. if ($provider instanceof self) {
  39262. return $this->matchSpecific($provider);
  39263. }
  39264. return $provider->matches($this);
  39265. }
  39266. public function setPrettyString($prettyString)
  39267. {
  39268. $this->prettyString = $prettyString;
  39269. }
  39270. public function getPrettyString()
  39271. {
  39272. if ($this->prettyString) {
  39273. return $this->prettyString;
  39274. }
  39275. return $this->__toString();
  39276. }
  39277. public static function getSupportedOperators()
  39278. {
  39279. return array_keys(self::$transOpStr);
  39280. }
  39281. public static function getOperatorConstant($operator)
  39282. {
  39283. return self::$transOpStr[$operator];
  39284. }
  39285. public function versionCompare($a, $b, $operator, $compareBranches = false)
  39286. {
  39287. if (!isset(self::$transOpStr[$operator])) {
  39288. throw new \InvalidArgumentException(sprintf(
  39289. 'Invalid operator "%s" given, expected one of: %s',
  39290. $operator,
  39291. implode(', ', self::getSupportedOperators())
  39292. ));
  39293. }
  39294. $aIsBranch = strpos($a, 'dev-') === 0;
  39295. $bIsBranch = strpos($b, 'dev-') === 0;
  39296. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  39297. return $a !== $b;
  39298. }
  39299. if ($aIsBranch && $bIsBranch) {
  39300. return $operator === '==' && $a === $b;
  39301. }
  39302. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  39303. return false;
  39304. }
  39305. return \version_compare($a, $b, $operator);
  39306. }
  39307. public function compile($otherOperator)
  39308. {
  39309. if (strpos($this->version, 'dev-') === 0) {
  39310. if (self::OP_EQ === $this->operator) {
  39311. if (self::OP_EQ === $otherOperator) {
  39312. return sprintf('$b && $v === %s', \var_export($this->version, true));
  39313. }
  39314. if (self::OP_NE === $otherOperator) {
  39315. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39316. }
  39317. return 'false';
  39318. }
  39319. if (self::OP_NE === $this->operator) {
  39320. if (self::OP_EQ === $otherOperator) {
  39321. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39322. }
  39323. if (self::OP_NE === $otherOperator) {
  39324. return 'true';
  39325. }
  39326. return '!$b';
  39327. }
  39328. return 'false';
  39329. }
  39330. if (self::OP_EQ === $this->operator) {
  39331. if (self::OP_EQ === $otherOperator) {
  39332. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  39333. }
  39334. if (self::OP_NE === $otherOperator) {
  39335. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  39336. }
  39337. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  39338. }
  39339. if (self::OP_NE === $this->operator) {
  39340. if (self::OP_EQ === $otherOperator) {
  39341. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  39342. }
  39343. if (self::OP_NE === $otherOperator) {
  39344. return 'true';
  39345. }
  39346. return '!$b';
  39347. }
  39348. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  39349. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  39350. return '!$b';
  39351. }
  39352. } elseif (self::OP_GT === $this->operator || self::OP_GE === $this->operator) {
  39353. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  39354. return '!$b';
  39355. }
  39356. }
  39357. if (self::OP_NE === $otherOperator) {
  39358. return 'true';
  39359. }
  39360. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  39361. if ($this->operator === self::OP_LE) {
  39362. if ($otherOperator === self::OP_GT) {
  39363. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39364. }
  39365. } elseif ($this->operator === self::OP_GE) {
  39366. if ($otherOperator === self::OP_LT) {
  39367. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39368. }
  39369. }
  39370. return sprintf('!$b && %s', $codeComparison);
  39371. }
  39372. public function matchSpecific(Constraint $provider, $compareBranches = false)
  39373. {
  39374. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  39375. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  39376. $isEqualOp = self::OP_EQ === $this->operator;
  39377. $isNonEqualOp = self::OP_NE === $this->operator;
  39378. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  39379. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  39380. if ($isNonEqualOp || $isProviderNonEqualOp) {
  39381. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  39382. return false;
  39383. }
  39384. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  39385. return false;
  39386. }
  39387. if (!$isEqualOp && !$isProviderEqualOp) {
  39388. return true;
  39389. }
  39390. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  39391. }
  39392. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  39393. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  39394. }
  39395. $version1 = $isEqualOp ? $this->version : $provider->version;
  39396. $version2 = $isEqualOp ? $provider->version : $this->version;
  39397. $operator = $isEqualOp ? $provider->operator : $this->operator;
  39398. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  39399. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  39400. && self::$transOpInt[$this->operator] !== $noEqualOp
  39401. && \version_compare($provider->version, $this->version, '=='));
  39402. }
  39403. return false;
  39404. }
  39405. public function __toString()
  39406. {
  39407. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  39408. }
  39409. public function getLowerBound()
  39410. {
  39411. $this->extractBounds();
  39412. return $this->lowerBound;
  39413. }
  39414. public function getUpperBound()
  39415. {
  39416. $this->extractBounds();
  39417. return $this->upperBound;
  39418. }
  39419. private function extractBounds()
  39420. {
  39421. if (null !== $this->lowerBound) {
  39422. return;
  39423. }
  39424. if (strpos($this->version, 'dev-') === 0) {
  39425. $this->lowerBound = Bound::zero();
  39426. $this->upperBound = Bound::positiveInfinity();
  39427. return;
  39428. }
  39429. switch ($this->operator) {
  39430. case self::OP_EQ:
  39431. $this->lowerBound = new Bound($this->version, true);
  39432. $this->upperBound = new Bound($this->version, true);
  39433. break;
  39434. case self::OP_LT:
  39435. $this->lowerBound = Bound::zero();
  39436. $this->upperBound = new Bound($this->version, false);
  39437. break;
  39438. case self::OP_LE:
  39439. $this->lowerBound = Bound::zero();
  39440. $this->upperBound = new Bound($this->version, true);
  39441. break;
  39442. case self::OP_GT:
  39443. $this->lowerBound = new Bound($this->version, false);
  39444. $this->upperBound = Bound::positiveInfinity();
  39445. break;
  39446. case self::OP_GE:
  39447. $this->lowerBound = new Bound($this->version, true);
  39448. $this->upperBound = Bound::positiveInfinity();
  39449. break;
  39450. case self::OP_NE:
  39451. $this->lowerBound = Bound::zero();
  39452. $this->upperBound = Bound::positiveInfinity();
  39453. break;
  39454. }
  39455. }
  39456. }
  39457. <?php
  39458. namespace Composer\Semver\Constraint;
  39459. interface ConstraintInterface
  39460. {
  39461. public function matches(ConstraintInterface $provider);
  39462. public function compile($operator);
  39463. public function getUpperBound();
  39464. public function getLowerBound();
  39465. public function getPrettyString();
  39466. public function setPrettyString($prettyString);
  39467. public function __toString();
  39468. }
  39469. <?php
  39470. namespace Composer\Semver\Constraint;
  39471. class MatchAllConstraint implements ConstraintInterface
  39472. {
  39473. protected $prettyString;
  39474. public function matches(ConstraintInterface $provider)
  39475. {
  39476. return true;
  39477. }
  39478. public function compile($operator)
  39479. {
  39480. return 'true';
  39481. }
  39482. public function setPrettyString($prettyString)
  39483. {
  39484. $this->prettyString = $prettyString;
  39485. }
  39486. public function getPrettyString()
  39487. {
  39488. if ($this->prettyString) {
  39489. return $this->prettyString;
  39490. }
  39491. return (string) $this;
  39492. }
  39493. public function __toString()
  39494. {
  39495. return '*';
  39496. }
  39497. public function getUpperBound()
  39498. {
  39499. return Bound::positiveInfinity();
  39500. }
  39501. public function getLowerBound()
  39502. {
  39503. return Bound::zero();
  39504. }
  39505. }
  39506. <?php
  39507. namespace Composer\Semver\Constraint;
  39508. class MatchNoneConstraint implements ConstraintInterface
  39509. {
  39510. protected $prettyString;
  39511. public function matches(ConstraintInterface $provider)
  39512. {
  39513. return false;
  39514. }
  39515. public function compile($operator)
  39516. {
  39517. return 'false';
  39518. }
  39519. public function setPrettyString($prettyString)
  39520. {
  39521. $this->prettyString = $prettyString;
  39522. }
  39523. public function getPrettyString()
  39524. {
  39525. if ($this->prettyString) {
  39526. return $this->prettyString;
  39527. }
  39528. return (string) $this;
  39529. }
  39530. public function __toString()
  39531. {
  39532. return '[]';
  39533. }
  39534. public function getUpperBound()
  39535. {
  39536. return new Bound('0.0.0.0-dev', false);
  39537. }
  39538. public function getLowerBound()
  39539. {
  39540. return new Bound('0.0.0.0-dev', false);
  39541. }
  39542. }
  39543. <?php
  39544. namespace Composer\Semver\Constraint;
  39545. class MultiConstraint implements ConstraintInterface
  39546. {
  39547. protected $constraints;
  39548. protected $prettyString;
  39549. protected $string;
  39550. protected $conjunctive;
  39551. protected $lowerBound;
  39552. protected $upperBound;
  39553. public function __construct(array $constraints, $conjunctive = true)
  39554. {
  39555. if (\count($constraints) < 2) {
  39556. throw new \InvalidArgumentException(
  39557. 'Must provide at least two constraints for a MultiConstraint. Use '.
  39558. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  39559. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  39560. );
  39561. }
  39562. $this->constraints = $constraints;
  39563. $this->conjunctive = $conjunctive;
  39564. }
  39565. public function getConstraints()
  39566. {
  39567. return $this->constraints;
  39568. }
  39569. public function isConjunctive()
  39570. {
  39571. return $this->conjunctive;
  39572. }
  39573. public function isDisjunctive()
  39574. {
  39575. return !$this->conjunctive;
  39576. }
  39577. public function compile($otherOperator)
  39578. {
  39579. $parts = array();
  39580. foreach ($this->constraints as $constraint) {
  39581. $code = $constraint->compile($otherOperator);
  39582. if ($code === 'true') {
  39583. if (!$this->conjunctive) {
  39584. return 'true';
  39585. }
  39586. } elseif ($code === 'false') {
  39587. if ($this->conjunctive) {
  39588. return 'false';
  39589. }
  39590. } else {
  39591. $parts[] = '('.$code.')';
  39592. }
  39593. }
  39594. if (!$parts) {
  39595. return $this->conjunctive ? 'true' : 'false';
  39596. }
  39597. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  39598. }
  39599. public function matches(ConstraintInterface $provider)
  39600. {
  39601. if (false === $this->conjunctive) {
  39602. foreach ($this->constraints as $constraint) {
  39603. if ($provider->matches($constraint)) {
  39604. return true;
  39605. }
  39606. }
  39607. return false;
  39608. }
  39609. foreach ($this->constraints as $constraint) {
  39610. if (!$provider->matches($constraint)) {
  39611. return false;
  39612. }
  39613. }
  39614. return true;
  39615. }
  39616. public function setPrettyString($prettyString)
  39617. {
  39618. $this->prettyString = $prettyString;
  39619. }
  39620. public function getPrettyString()
  39621. {
  39622. if ($this->prettyString) {
  39623. return $this->prettyString;
  39624. }
  39625. return (string) $this;
  39626. }
  39627. public function __toString()
  39628. {
  39629. if ($this->string !== null) {
  39630. return $this->string;
  39631. }
  39632. $constraints = array();
  39633. foreach ($this->constraints as $constraint) {
  39634. $constraints[] = (string) $constraint;
  39635. }
  39636. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  39637. }
  39638. public function getLowerBound()
  39639. {
  39640. $this->extractBounds();
  39641. return $this->lowerBound;
  39642. }
  39643. public function getUpperBound()
  39644. {
  39645. $this->extractBounds();
  39646. return $this->upperBound;
  39647. }
  39648. public static function create(array $constraints, $conjunctive = true)
  39649. {
  39650. if (0 === \count($constraints)) {
  39651. return new MatchAllConstraint();
  39652. }
  39653. if (1 === \count($constraints)) {
  39654. return $constraints[0];
  39655. }
  39656. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  39657. if ($optimized !== null) {
  39658. list($constraints, $conjunctive) = $optimized;
  39659. if (\count($constraints) === 1) {
  39660. return $constraints[0];
  39661. }
  39662. }
  39663. return new self($constraints, $conjunctive);
  39664. }
  39665. private static function optimizeConstraints(array $constraints, $conjunctive)
  39666. {
  39667. if (!$conjunctive) {
  39668. $left = $constraints[0];
  39669. $mergedConstraints = array();
  39670. $optimized = false;
  39671. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  39672. $right = $constraints[$i];
  39673. if (
  39674. $left instanceof self
  39675. && $left->conjunctive
  39676. && $right instanceof self
  39677. && $right->conjunctive
  39678. && \count($left->constraints) === 2
  39679. && \count($right->constraints) === 2
  39680. && ($left0 = (string) $left->constraints[0])
  39681. && $left0[0] === '>' && $left0[1] === '='
  39682. && ($left1 = (string) $left->constraints[1])
  39683. && $left1[0] === '<'
  39684. && ($right0 = (string) $right->constraints[0])
  39685. && $right0[0] === '>' && $right0[1] === '='
  39686. && ($right1 = (string) $right->constraints[1])
  39687. && $right1[0] === '<'
  39688. && substr($left1, 2) === substr($right0, 3)
  39689. ) {
  39690. $optimized = true;
  39691. $left = new MultiConstraint(
  39692. array(
  39693. $left->constraints[0],
  39694. $right->constraints[1],
  39695. ),
  39696. true);
  39697. } else {
  39698. $mergedConstraints[] = $left;
  39699. $left = $right;
  39700. }
  39701. }
  39702. if ($optimized) {
  39703. $mergedConstraints[] = $left;
  39704. return array($mergedConstraints, false);
  39705. }
  39706. }
  39707. return null;
  39708. }
  39709. private function extractBounds()
  39710. {
  39711. if (null !== $this->lowerBound) {
  39712. return;
  39713. }
  39714. foreach ($this->constraints as $constraint) {
  39715. if (null === $this->lowerBound && null === $this->upperBound) {
  39716. $this->lowerBound = $constraint->getLowerBound();
  39717. $this->upperBound = $constraint->getUpperBound();
  39718. continue;
  39719. }
  39720. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  39721. $this->lowerBound = $constraint->getLowerBound();
  39722. }
  39723. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  39724. $this->upperBound = $constraint->getUpperBound();
  39725. }
  39726. }
  39727. }
  39728. }
  39729. <?php
  39730. namespace Composer\Semver;
  39731. use Composer\Semver\Constraint\Constraint;
  39732. class Interval
  39733. {
  39734. private $start;
  39735. private $end;
  39736. public function __construct(Constraint $start, Constraint $end)
  39737. {
  39738. $this->start = $start;
  39739. $this->end = $end;
  39740. }
  39741. public function getStart()
  39742. {
  39743. return $this->start;
  39744. }
  39745. public function getEnd()
  39746. {
  39747. return $this->end;
  39748. }
  39749. public static function fromZero()
  39750. {
  39751. static $zero;
  39752. if (null === $zero) {
  39753. $zero = new Constraint('>=', '0.0.0.0-dev');
  39754. }
  39755. return $zero;
  39756. }
  39757. public static function untilPositiveInfinity()
  39758. {
  39759. static $positiveInfinity;
  39760. if (null === $positiveInfinity) {
  39761. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  39762. }
  39763. return $positiveInfinity;
  39764. }
  39765. public static function any()
  39766. {
  39767. return new self(self::fromZero(), self::untilPositiveInfinity());
  39768. }
  39769. public static function anyDev()
  39770. {
  39771. return array('names' => array(), 'exclude' => true);
  39772. }
  39773. public static function noDev()
  39774. {
  39775. return array('names' => array(), 'exclude' => false);
  39776. }
  39777. }
  39778. <?php
  39779. namespace Composer\Semver;
  39780. use Composer\Semver\Constraint\Constraint;
  39781. use Composer\Semver\Constraint\ConstraintInterface;
  39782. use Composer\Semver\Constraint\MatchAllConstraint;
  39783. use Composer\Semver\Constraint\MatchNoneConstraint;
  39784. use Composer\Semver\Constraint\MultiConstraint;
  39785. class Intervals
  39786. {
  39787. private static $intervalsCache = array();
  39788. private static $opSortOrder = array(
  39789. '>=' => -3,
  39790. '<' => -2,
  39791. '>' => 2,
  39792. '<=' => 3,
  39793. );
  39794. public static function clear()
  39795. {
  39796. self::$intervalsCache = array();
  39797. }
  39798. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  39799. {
  39800. if ($constraint instanceof MatchAllConstraint) {
  39801. return true;
  39802. }
  39803. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  39804. return false;
  39805. }
  39806. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  39807. $candidateIntervals = self::get($candidate);
  39808. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  39809. return false;
  39810. }
  39811. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  39812. if (!isset($candidateIntervals['numeric'][$index])) {
  39813. return false;
  39814. }
  39815. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  39816. return false;
  39817. }
  39818. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  39819. return false;
  39820. }
  39821. }
  39822. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  39823. return false;
  39824. }
  39825. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  39826. return false;
  39827. }
  39828. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  39829. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  39830. return false;
  39831. }
  39832. }
  39833. return true;
  39834. }
  39835. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  39836. {
  39837. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  39838. return true;
  39839. }
  39840. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  39841. return false;
  39842. }
  39843. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  39844. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  39845. }
  39846. public static function compactConstraint(ConstraintInterface $constraint)
  39847. {
  39848. if (!$constraint instanceof MultiConstraint) {
  39849. return $constraint;
  39850. }
  39851. $intervals = self::generateIntervals($constraint);
  39852. $constraints = array();
  39853. $hasNumericMatchAll = false;
  39854. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  39855. $constraints[] = $intervals['numeric'][0]->getStart();
  39856. $hasNumericMatchAll = true;
  39857. } else {
  39858. $unEqualConstraints = array();
  39859. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  39860. $interval = $intervals['numeric'][$i];
  39861. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  39862. $nextInterval = $intervals['numeric'][$i+1];
  39863. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  39864. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  39865. $unEqualConstraints[] = $interval->getStart();
  39866. }
  39867. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  39868. continue;
  39869. }
  39870. }
  39871. if (\count($unEqualConstraints) > 0) {
  39872. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  39873. $unEqualConstraints[] = $interval->getEnd();
  39874. }
  39875. if (\count($unEqualConstraints) > 1) {
  39876. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  39877. } else {
  39878. $constraints[] = $unEqualConstraints[0];
  39879. }
  39880. $unEqualConstraints = array();
  39881. continue;
  39882. }
  39883. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  39884. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  39885. continue;
  39886. }
  39887. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  39888. $constraints[] = $interval->getEnd();
  39889. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  39890. $constraints[] = $interval->getStart();
  39891. } else {
  39892. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  39893. }
  39894. }
  39895. }
  39896. $devConstraints = array();
  39897. if (0 === \count($intervals['branches']['names'])) {
  39898. if ($intervals['branches']['exclude']) {
  39899. if ($hasNumericMatchAll) {
  39900. return new MatchAllConstraint;
  39901. }
  39902. }
  39903. } else {
  39904. foreach ($intervals['branches']['names'] as $branchName) {
  39905. if ($intervals['branches']['exclude']) {
  39906. $devConstraints[] = new Constraint('!=', $branchName);
  39907. } else {
  39908. $devConstraints[] = new Constraint('==', $branchName);
  39909. }
  39910. }
  39911. if ($intervals['branches']['exclude']) {
  39912. if (\count($constraints) > 1) {
  39913. return new MultiConstraint(array_merge(
  39914. array(new MultiConstraint($constraints, false)),
  39915. $devConstraints
  39916. ), true);
  39917. }
  39918. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  39919. if (\count($devConstraints) > 1) {
  39920. return new MultiConstraint($devConstraints, true);
  39921. }
  39922. return $devConstraints[0];
  39923. }
  39924. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  39925. }
  39926. $constraints = array_merge($constraints, $devConstraints);
  39927. }
  39928. if (\count($constraints) > 1) {
  39929. return new MultiConstraint($constraints, false);
  39930. }
  39931. if (\count($constraints) === 1) {
  39932. return $constraints[0];
  39933. }
  39934. return new MatchNoneConstraint;
  39935. }
  39936. public static function get(ConstraintInterface $constraint)
  39937. {
  39938. $key = (string) $constraint;
  39939. if (!isset(self::$intervalsCache[$key])) {
  39940. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  39941. }
  39942. return self::$intervalsCache[$key];
  39943. }
  39944. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  39945. {
  39946. if ($constraint instanceof MatchAllConstraint) {
  39947. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  39948. }
  39949. if ($constraint instanceof MatchNoneConstraint) {
  39950. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  39951. }
  39952. if ($constraint instanceof Constraint) {
  39953. return self::generateSingleConstraintIntervals($constraint);
  39954. }
  39955. if (!$constraint instanceof MultiConstraint) {
  39956. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  39957. }
  39958. $constraints = $constraint->getConstraints();
  39959. $numericGroups = array();
  39960. $constraintBranches = array();
  39961. foreach ($constraints as $c) {
  39962. $res = self::get($c);
  39963. $numericGroups[] = $res['numeric'];
  39964. $constraintBranches[] = $res['branches'];
  39965. }
  39966. if ($constraint->isDisjunctive()) {
  39967. $branches = Interval::noDev();
  39968. foreach ($constraintBranches as $b) {
  39969. if ($b['exclude']) {
  39970. if ($branches['exclude']) {
  39971. $branches['names'] = array_intersect($branches['names'], $b['names']);
  39972. } else {
  39973. $branches['exclude'] = true;
  39974. $branches['names'] = array_diff($b['names'], $branches['names']);
  39975. }
  39976. } else {
  39977. if ($branches['exclude']) {
  39978. $branches['names'] = array_diff($branches['names'], $b['names']);
  39979. } else {
  39980. $branches['names'] = array_merge($branches['names'], $b['names']);
  39981. }
  39982. }
  39983. }
  39984. } else {
  39985. $branches = Interval::anyDev();
  39986. foreach ($constraintBranches as $b) {
  39987. if ($b['exclude']) {
  39988. if ($branches['exclude']) {
  39989. $branches['names'] = array_merge($branches['names'], $b['names']);
  39990. } else {
  39991. $branches['names'] = array_diff($branches['names'], $b['names']);
  39992. }
  39993. } else {
  39994. if ($branches['exclude']) {
  39995. $branches['names'] = array_diff($b['names'], $branches['names']);
  39996. $branches['exclude'] = false;
  39997. } else {
  39998. $branches['names'] = array_intersect($branches['names'], $b['names']);
  39999. }
  40000. }
  40001. }
  40002. }
  40003. $branches['names'] = array_unique($branches['names']);
  40004. if (\count($numericGroups) === 1) {
  40005. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  40006. }
  40007. $borders = array();
  40008. foreach ($numericGroups as $group) {
  40009. foreach ($group as $interval) {
  40010. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  40011. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  40012. }
  40013. }
  40014. $opSortOrder = self::$opSortOrder;
  40015. usort($borders, function ($a, $b) use ($opSortOrder) {
  40016. $order = version_compare($a['version'], $b['version']);
  40017. if ($order === 0) {
  40018. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  40019. }
  40020. return $order;
  40021. });
  40022. $activeIntervals = 0;
  40023. $intervals = array();
  40024. $index = 0;
  40025. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  40026. $active = false;
  40027. $start = null;
  40028. foreach ($borders as $border) {
  40029. if ($border['side'] === 'start') {
  40030. $activeIntervals++;
  40031. } else {
  40032. $activeIntervals--;
  40033. }
  40034. if (!$active && $activeIntervals >= $activationThreshold) {
  40035. $start = new Constraint($border['operator'], $border['version']);
  40036. $active = true;
  40037. }
  40038. if ($active && $activeIntervals < $activationThreshold) {
  40039. $active = false;
  40040. if (
  40041. version_compare($start->getVersion(), $border['version'], '=')
  40042. && (
  40043. ($start->getOperator() === '>' && $border['operator'] === '<=')
  40044. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  40045. )
  40046. ) {
  40047. unset($intervals[$index]);
  40048. } else {
  40049. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  40050. $index++;
  40051. if ($stopOnFirstValidInterval) {
  40052. break;
  40053. }
  40054. }
  40055. $start = null;
  40056. }
  40057. }
  40058. return array('numeric' => $intervals, 'branches' => $branches);
  40059. }
  40060. private static function generateSingleConstraintIntervals(Constraint $constraint)
  40061. {
  40062. $op = $constraint->getOperator();
  40063. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  40064. $intervals = array();
  40065. $branches = array('names' => array(), 'exclude' => false);
  40066. if ($op === '!=') {
  40067. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  40068. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  40069. } elseif ($op === '==') {
  40070. $branches['names'][] = $constraint->getVersion();
  40071. }
  40072. return array(
  40073. 'numeric' => $intervals,
  40074. 'branches' => $branches,
  40075. );
  40076. }
  40077. if ($op[0] === '>') {
  40078. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  40079. }
  40080. if ($op[0] === '<') {
  40081. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  40082. }
  40083. if ($op === '!=') {
  40084. return array('numeric' => array(
  40085. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  40086. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  40087. ), 'branches' => Interval::anyDev());
  40088. }
  40089. return array('numeric' => array(
  40090. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  40091. ), 'branches' => Interval::noDev());
  40092. }
  40093. }
  40094. <?php
  40095. namespace Composer\Semver;
  40096. use Composer\Semver\Constraint\Constraint;
  40097. class Semver
  40098. {
  40099. const SORT_ASC = 1;
  40100. const SORT_DESC = -1;
  40101. private static $versionParser;
  40102. public static function satisfies($version, $constraints)
  40103. {
  40104. if (null === self::$versionParser) {
  40105. self::$versionParser = new VersionParser();
  40106. }
  40107. $versionParser = self::$versionParser;
  40108. $provider = new Constraint('==', $versionParser->normalize($version));
  40109. $parsedConstraints = $versionParser->parseConstraints($constraints);
  40110. return $parsedConstraints->matches($provider);
  40111. }
  40112. public static function satisfiedBy(array $versions, $constraints)
  40113. {
  40114. $versions = array_filter($versions, function ($version) use ($constraints) {
  40115. return Semver::satisfies($version, $constraints);
  40116. });
  40117. return array_values($versions);
  40118. }
  40119. public static function sort(array $versions)
  40120. {
  40121. return self::usort($versions, self::SORT_ASC);
  40122. }
  40123. public static function rsort(array $versions)
  40124. {
  40125. return self::usort($versions, self::SORT_DESC);
  40126. }
  40127. private static function usort(array $versions, $direction)
  40128. {
  40129. if (null === self::$versionParser) {
  40130. self::$versionParser = new VersionParser();
  40131. }
  40132. $versionParser = self::$versionParser;
  40133. $normalized = array();
  40134. foreach ($versions as $key => $version) {
  40135. $normalizedVersion = $versionParser->normalize($version);
  40136. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  40137. $normalized[] = array($normalizedVersion, $key);
  40138. }
  40139. usort($normalized, function (array $left, array $right) use ($direction) {
  40140. if ($left[0] === $right[0]) {
  40141. return 0;
  40142. }
  40143. if (Comparator::lessThan($left[0], $right[0])) {
  40144. return -$direction;
  40145. }
  40146. return $direction;
  40147. });
  40148. $sorted = array();
  40149. foreach ($normalized as $item) {
  40150. $sorted[] = $versions[$item[1]];
  40151. }
  40152. return $sorted;
  40153. }
  40154. }
  40155. <?php
  40156. namespace Composer\Semver;
  40157. use Composer\Semver\Constraint\ConstraintInterface;
  40158. use Composer\Semver\Constraint\MatchAllConstraint;
  40159. use Composer\Semver\Constraint\MultiConstraint;
  40160. use Composer\Semver\Constraint\Constraint;
  40161. class VersionParser
  40162. {
  40163. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  40164. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  40165. public static function parseStability($version)
  40166. {
  40167. $version = preg_replace('{#.+$}', '', $version);
  40168. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  40169. return 'dev';
  40170. }
  40171. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  40172. if (!empty($match[3])) {
  40173. return 'dev';
  40174. }
  40175. if (!empty($match[1])) {
  40176. if ('beta' === $match[1] || 'b' === $match[1]) {
  40177. return 'beta';
  40178. }
  40179. if ('alpha' === $match[1] || 'a' === $match[1]) {
  40180. return 'alpha';
  40181. }
  40182. if ('rc' === $match[1]) {
  40183. return 'RC';
  40184. }
  40185. }
  40186. return 'stable';
  40187. }
  40188. public static function normalizeStability($stability)
  40189. {
  40190. $stability = strtolower($stability);
  40191. return $stability === 'rc' ? 'RC' : $stability;
  40192. }
  40193. public function normalize($version, $fullVersion = null)
  40194. {
  40195. $version = trim($version);
  40196. $origVersion = $version;
  40197. if (null === $fullVersion) {
  40198. $fullVersion = $version;
  40199. }
  40200. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  40201. $version = $match[1];
  40202. }
  40203. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  40204. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  40205. }
  40206. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  40207. $version = 'dev-' . $version;
  40208. }
  40209. if (stripos($version, 'dev-') === 0) {
  40210. return 'dev-' . substr($version, 4);
  40211. }
  40212. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  40213. $version = $match[1];
  40214. }
  40215. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  40216. $version = $matches[1]
  40217. . (!empty($matches[2]) ? $matches[2] : '.0')
  40218. . (!empty($matches[3]) ? $matches[3] : '.0')
  40219. . (!empty($matches[4]) ? $matches[4] : '.0');
  40220. $index = 5;
  40221. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  40222. $version = preg_replace('{\D}', '.', $matches[1]);
  40223. $index = 2;
  40224. }
  40225. if (isset($index)) {
  40226. if (!empty($matches[$index])) {
  40227. if ('stable' === $matches[$index]) {
  40228. return $version;
  40229. }
  40230. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  40231. }
  40232. if (!empty($matches[$index + 2])) {
  40233. $version .= '-dev';
  40234. }
  40235. return $version;
  40236. }
  40237. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  40238. try {
  40239. $normalized = $this->normalizeBranch($match[1]);
  40240. if (strpos($normalized, 'dev-') === false) {
  40241. return $normalized;
  40242. }
  40243. } catch (\Exception $e) {
  40244. }
  40245. }
  40246. $extraMessage = '';
  40247. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  40248. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  40249. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  40250. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  40251. }
  40252. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  40253. }
  40254. public function parseNumericAliasPrefix($branch)
  40255. {
  40256. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  40257. return $matches['version'] . '.';
  40258. }
  40259. return false;
  40260. }
  40261. public function normalizeBranch($name)
  40262. {
  40263. $name = trim($name);
  40264. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  40265. $version = '';
  40266. for ($i = 1; $i < 5; ++$i) {
  40267. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  40268. }
  40269. return str_replace('x', '9999999', $version) . '-dev';
  40270. }
  40271. return 'dev-' . $name;
  40272. }
  40273. public function normalizeDefaultBranch($name)
  40274. {
  40275. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  40276. return '9999999-dev';
  40277. }
  40278. return $name;
  40279. }
  40280. public function parseConstraints($constraints)
  40281. {
  40282. $prettyConstraint = $constraints;
  40283. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  40284. $orGroups = array();
  40285. foreach ($orConstraints as $constraints) {
  40286. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  40287. if (\count($andConstraints) > 1) {
  40288. $constraintObjects = array();
  40289. foreach ($andConstraints as $constraint) {
  40290. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  40291. $constraintObjects[] = $parsedConstraint;
  40292. }
  40293. }
  40294. } else {
  40295. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  40296. }
  40297. if (1 === \count($constraintObjects)) {
  40298. $constraint = $constraintObjects[0];
  40299. } else {
  40300. $constraint = new MultiConstraint($constraintObjects);
  40301. }
  40302. $orGroups[] = $constraint;
  40303. }
  40304. $constraint = MultiConstraint::create($orGroups, false);
  40305. $constraint->setPrettyString($prettyConstraint);
  40306. return $constraint;
  40307. }
  40308. private function parseConstraint($constraint)
  40309. {
  40310. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  40311. $constraint = $match[1];
  40312. }
  40313. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  40314. $constraint = '' !== $match[1] ? $match[1] : '*';
  40315. if ($match[2] !== 'stable') {
  40316. $stabilityModifier = $match[2];
  40317. }
  40318. }
  40319. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  40320. $constraint = $match[1];
  40321. }
  40322. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  40323. if (!empty($match[1]) || !empty($match[2])) {
  40324. return array(new Constraint('>=', '0.0.0.0-dev'));
  40325. }
  40326. return array(new MatchAllConstraint());
  40327. }
  40328. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  40329. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  40330. if (strpos($constraint, '~>') === 0) {
  40331. throw new \UnexpectedValueException(
  40332. 'Could not parse version constraint ' . $constraint . ': ' .
  40333. 'Invalid operator "~>", you probably meant to use the "~" operator'
  40334. );
  40335. }
  40336. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  40337. $position = 4;
  40338. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40339. $position = 3;
  40340. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40341. $position = 2;
  40342. } else {
  40343. $position = 1;
  40344. }
  40345. if (!empty($matches[8])) {
  40346. $position++;
  40347. }
  40348. $stabilitySuffix = '';
  40349. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40350. $stabilitySuffix .= '-dev';
  40351. }
  40352. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40353. $lowerBound = new Constraint('>=', $lowVersion);
  40354. $highPosition = max(1, $position - 1);
  40355. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  40356. $upperBound = new Constraint('<', $highVersion);
  40357. return array(
  40358. $lowerBound,
  40359. $upperBound,
  40360. );
  40361. }
  40362. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  40363. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  40364. $position = 1;
  40365. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  40366. $position = 2;
  40367. } else {
  40368. $position = 3;
  40369. }
  40370. $stabilitySuffix = '';
  40371. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40372. $stabilitySuffix .= '-dev';
  40373. }
  40374. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40375. $lowerBound = new Constraint('>=', $lowVersion);
  40376. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40377. $upperBound = new Constraint('<', $highVersion);
  40378. return array(
  40379. $lowerBound,
  40380. $upperBound,
  40381. );
  40382. }
  40383. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  40384. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40385. $position = 3;
  40386. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40387. $position = 2;
  40388. } else {
  40389. $position = 1;
  40390. }
  40391. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  40392. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40393. if ($lowVersion === '0.0.0.0-dev') {
  40394. return array(new Constraint('<', $highVersion));
  40395. }
  40396. return array(
  40397. new Constraint('>=', $lowVersion),
  40398. new Constraint('<', $highVersion),
  40399. );
  40400. }
  40401. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  40402. $lowStabilitySuffix = '';
  40403. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  40404. $lowStabilitySuffix = '-dev';
  40405. }
  40406. $lowVersion = $this->normalize($matches['from']);
  40407. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  40408. $empty = function ($x) {
  40409. return ($x === 0 || $x === '0') ? false : empty($x);
  40410. };
  40411. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  40412. $highVersion = $this->normalize($matches['to']);
  40413. $upperBound = new Constraint('<=', $highVersion);
  40414. } else {
  40415. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  40416. $this->normalize($matches['to']);
  40417. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  40418. $upperBound = new Constraint('<', $highVersion);
  40419. }
  40420. return array(
  40421. $lowerBound,
  40422. $upperBound,
  40423. );
  40424. }
  40425. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  40426. try {
  40427. try {
  40428. $version = $this->normalize($matches[2]);
  40429. } catch (\UnexpectedValueException $e) {
  40430. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  40431. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  40432. } else {
  40433. throw $e;
  40434. }
  40435. }
  40436. $op = $matches[1] ?: '=';
  40437. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  40438. $version .= '-' . $stabilityModifier;
  40439. } elseif ('<' === $op || '>=' === $op) {
  40440. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  40441. if (strpos($matches[2], 'dev-') !== 0) {
  40442. $version .= '-dev';
  40443. }
  40444. }
  40445. }
  40446. return array(new Constraint($matches[1] ?: '=', $version));
  40447. } catch (\Exception $e) {
  40448. }
  40449. }
  40450. $message = 'Could not parse version constraint ' . $constraint;
  40451. if (isset($e)) {
  40452. $message .= ': ' . $e->getMessage();
  40453. }
  40454. throw new \UnexpectedValueException($message);
  40455. }
  40456. private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
  40457. {
  40458. for ($i = 4; $i > 0; --$i) {
  40459. if ($i > $position) {
  40460. $matches[$i] = $pad;
  40461. } elseif ($i === $position && $increment) {
  40462. $matches[$i] += $increment;
  40463. if ($matches[$i] < 0) {
  40464. $matches[$i] = $pad;
  40465. --$position;
  40466. if ($i === 1) {
  40467. return null;
  40468. }
  40469. }
  40470. }
  40471. }
  40472. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  40473. }
  40474. private function expandStability($stability)
  40475. {
  40476. $stability = strtolower($stability);
  40477. switch ($stability) {
  40478. case 'a':
  40479. return 'alpha';
  40480. case 'b':
  40481. return 'beta';
  40482. case 'p':
  40483. case 'pl':
  40484. return 'patch';
  40485. case 'rc':
  40486. return 'RC';
  40487. default:
  40488. return $stability;
  40489. }
  40490. }
  40491. }
  40492. Copyright (C) 2015 Composer
  40493. Permission is hereby granted, free of charge, to any person obtaining a copy of
  40494. this software and associated documentation files (the "Software"), to deal in
  40495. the Software without restriction, including without limitation the rights to
  40496. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  40497. of the Software, and to permit persons to whom the Software is furnished to do
  40498. so, subject to the following conditions:
  40499. The above copyright notice and this permission notice shall be included in all
  40500. copies or substantial portions of the Software.
  40501. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  40502. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40503. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  40504. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  40505. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  40506. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  40507. SOFTWARE.
  40508. {
  40509. "389-exception": [
  40510. "389 Directory Server Exception"
  40511. ],
  40512. "Autoconf-exception-2.0": [
  40513. "Autoconf exception 2.0"
  40514. ],
  40515. "Autoconf-exception-3.0": [
  40516. "Autoconf exception 3.0"
  40517. ],
  40518. "Bison-exception-2.2": [
  40519. "Bison exception 2.2"
  40520. ],
  40521. "Bootloader-exception": [
  40522. "Bootloader Distribution Exception"
  40523. ],
  40524. "Classpath-exception-2.0": [
  40525. "Classpath exception 2.0"
  40526. ],
  40527. "CLISP-exception-2.0": [
  40528. "CLISP exception 2.0"
  40529. ],
  40530. "DigiRule-FOSS-exception": [
  40531. "DigiRule FOSS License Exception"
  40532. ],
  40533. "eCos-exception-2.0": [
  40534. "eCos exception 2.0"
  40535. ],
  40536. "Fawkes-Runtime-exception": [
  40537. "Fawkes Runtime Exception"
  40538. ],
  40539. "FLTK-exception": [
  40540. "FLTK exception"
  40541. ],
  40542. "Font-exception-2.0": [
  40543. "Font exception 2.0"
  40544. ],
  40545. "freertos-exception-2.0": [
  40546. "FreeRTOS Exception 2.0"
  40547. ],
  40548. "GCC-exception-2.0": [
  40549. "GCC Runtime Library exception 2.0"
  40550. ],
  40551. "GCC-exception-3.1": [
  40552. "GCC Runtime Library exception 3.1"
  40553. ],
  40554. "gnu-javamail-exception": [
  40555. "GNU JavaMail exception"
  40556. ],
  40557. "GPL-3.0-linking-exception": [
  40558. "GPL-3.0 Linking Exception"
  40559. ],
  40560. "GPL-3.0-linking-source-exception": [
  40561. "GPL-3.0 Linking Exception (with Corresponding Source)"
  40562. ],
  40563. "GPL-CC-1.0": [
  40564. "GPL Cooperation Commitment 1.0"
  40565. ],
  40566. "i2p-gpl-java-exception": [
  40567. "i2p GPL+Java Exception"
  40568. ],
  40569. "LGPL-3.0-linking-exception": [
  40570. "LGPL-3.0 Linking Exception"
  40571. ],
  40572. "Libtool-exception": [
  40573. "Libtool Exception"
  40574. ],
  40575. "Linux-syscall-note": [
  40576. "Linux Syscall Note"
  40577. ],
  40578. "LLVM-exception": [
  40579. "LLVM Exception"
  40580. ],
  40581. "LZMA-exception": [
  40582. "LZMA exception"
  40583. ],
  40584. "mif-exception": [
  40585. "Macros and Inline Functions Exception"
  40586. ],
  40587. "Nokia-Qt-exception-1.1": [
  40588. "Nokia Qt LGPL exception 1.1"
  40589. ],
  40590. "OCaml-LGPL-linking-exception": [
  40591. "OCaml LGPL Linking Exception"
  40592. ],
  40593. "OCCT-exception-1.0": [
  40594. "Open CASCADE Exception 1.0"
  40595. ],
  40596. "OpenJDK-assembly-exception-1.0": [
  40597. "OpenJDK Assembly exception 1.0"
  40598. ],
  40599. "openvpn-openssl-exception": [
  40600. "OpenVPN OpenSSL Exception"
  40601. ],
  40602. "PS-or-PDF-font-exception-20170817": [
  40603. "PS/PDF font exception (2017-08-17)"
  40604. ],
  40605. "Qt-GPL-exception-1.0": [
  40606. "Qt GPL exception 1.0"
  40607. ],
  40608. "Qt-LGPL-exception-1.1": [
  40609. "Qt LGPL exception 1.1"
  40610. ],
  40611. "Qwt-exception-1.0": [
  40612. "Qwt exception 1.0"
  40613. ],
  40614. "SHL-2.0": [
  40615. "Solderpad Hardware License v2.0"
  40616. ],
  40617. "SHL-2.1": [
  40618. "Solderpad Hardware License v2.1"
  40619. ],
  40620. "Swift-exception": [
  40621. "Swift Exception"
  40622. ],
  40623. "u-boot-exception-2.0": [
  40624. "U-Boot exception 2.0"
  40625. ],
  40626. "Universal-FOSS-exception-1.0": [
  40627. "Universal FOSS Exception, Version 1.0"
  40628. ],
  40629. "WxWindows-exception-3.1": [
  40630. "WxWindows Library Exception 3.1"
  40631. ]
  40632. }{
  40633. "0BSD": [
  40634. "BSD Zero Clause License",
  40635. true,
  40636. false
  40637. ],
  40638. "AAL": [
  40639. "Attribution Assurance License",
  40640. true,
  40641. false
  40642. ],
  40643. "Abstyles": [
  40644. "Abstyles License",
  40645. false,
  40646. false
  40647. ],
  40648. "Adobe-2006": [
  40649. "Adobe Systems Incorporated Source Code License Agreement",
  40650. false,
  40651. false
  40652. ],
  40653. "Adobe-Glyph": [
  40654. "Adobe Glyph List License",
  40655. false,
  40656. false
  40657. ],
  40658. "ADSL": [
  40659. "Amazon Digital Services License",
  40660. false,
  40661. false
  40662. ],
  40663. "AFL-1.1": [
  40664. "Academic Free License v1.1",
  40665. true,
  40666. false
  40667. ],
  40668. "AFL-1.2": [
  40669. "Academic Free License v1.2",
  40670. true,
  40671. false
  40672. ],
  40673. "AFL-2.0": [
  40674. "Academic Free License v2.0",
  40675. true,
  40676. false
  40677. ],
  40678. "AFL-2.1": [
  40679. "Academic Free License v2.1",
  40680. true,
  40681. false
  40682. ],
  40683. "AFL-3.0": [
  40684. "Academic Free License v3.0",
  40685. true,
  40686. false
  40687. ],
  40688. "Afmparse": [
  40689. "Afmparse License",
  40690. false,
  40691. false
  40692. ],
  40693. "AGPL-1.0": [
  40694. "Affero General Public License v1.0",
  40695. false,
  40696. true
  40697. ],
  40698. "AGPL-1.0-only": [
  40699. "Affero General Public License v1.0 only",
  40700. false,
  40701. false
  40702. ],
  40703. "AGPL-1.0-or-later": [
  40704. "Affero General Public License v1.0 or later",
  40705. false,
  40706. false
  40707. ],
  40708. "AGPL-3.0": [
  40709. "GNU Affero General Public License v3.0",
  40710. true,
  40711. true
  40712. ],
  40713. "AGPL-3.0-only": [
  40714. "GNU Affero General Public License v3.0 only",
  40715. true,
  40716. false
  40717. ],
  40718. "AGPL-3.0-or-later": [
  40719. "GNU Affero General Public License v3.0 or later",
  40720. true,
  40721. false
  40722. ],
  40723. "Aladdin": [
  40724. "Aladdin Free Public License",
  40725. false,
  40726. false
  40727. ],
  40728. "AMDPLPA": [
  40729. "AMD's plpa_map.c License",
  40730. false,
  40731. false
  40732. ],
  40733. "AML": [
  40734. "Apple MIT License",
  40735. false,
  40736. false
  40737. ],
  40738. "AMPAS": [
  40739. "Academy of Motion Picture Arts and Sciences BSD",
  40740. false,
  40741. false
  40742. ],
  40743. "ANTLR-PD": [
  40744. "ANTLR Software Rights Notice",
  40745. false,
  40746. false
  40747. ],
  40748. "Apache-1.0": [
  40749. "Apache License 1.0",
  40750. false,
  40751. false
  40752. ],
  40753. "Apache-1.1": [
  40754. "Apache License 1.1",
  40755. true,
  40756. false
  40757. ],
  40758. "Apache-2.0": [
  40759. "Apache License 2.0",
  40760. true,
  40761. false
  40762. ],
  40763. "APAFML": [
  40764. "Adobe Postscript AFM License",
  40765. false,
  40766. false
  40767. ],
  40768. "APL-1.0": [
  40769. "Adaptive Public License 1.0",
  40770. true,
  40771. false
  40772. ],
  40773. "APSL-1.0": [
  40774. "Apple Public Source License 1.0",
  40775. true,
  40776. false
  40777. ],
  40778. "APSL-1.1": [
  40779. "Apple Public Source License 1.1",
  40780. true,
  40781. false
  40782. ],
  40783. "APSL-1.2": [
  40784. "Apple Public Source License 1.2",
  40785. true,
  40786. false
  40787. ],
  40788. "APSL-2.0": [
  40789. "Apple Public Source License 2.0",
  40790. true,
  40791. false
  40792. ],
  40793. "Artistic-1.0": [
  40794. "Artistic License 1.0",
  40795. true,
  40796. false
  40797. ],
  40798. "Artistic-1.0-cl8": [
  40799. "Artistic License 1.0 w/clause 8",
  40800. true,
  40801. false
  40802. ],
  40803. "Artistic-1.0-Perl": [
  40804. "Artistic License 1.0 (Perl)",
  40805. true,
  40806. false
  40807. ],
  40808. "Artistic-2.0": [
  40809. "Artistic License 2.0",
  40810. true,
  40811. false
  40812. ],
  40813. "Bahyph": [
  40814. "Bahyph License",
  40815. false,
  40816. false
  40817. ],
  40818. "Barr": [
  40819. "Barr License",
  40820. false,
  40821. false
  40822. ],
  40823. "Beerware": [
  40824. "Beerware License",
  40825. false,
  40826. false
  40827. ],
  40828. "BitTorrent-1.0": [
  40829. "BitTorrent Open Source License v1.0",
  40830. false,
  40831. false
  40832. ],
  40833. "BitTorrent-1.1": [
  40834. "BitTorrent Open Source License v1.1",
  40835. false,
  40836. false
  40837. ],
  40838. "blessing": [
  40839. "SQLite Blessing",
  40840. false,
  40841. false
  40842. ],
  40843. "BlueOak-1.0.0": [
  40844. "Blue Oak Model License 1.0.0",
  40845. false,
  40846. false
  40847. ],
  40848. "Borceux": [
  40849. "Borceux license",
  40850. false,
  40851. false
  40852. ],
  40853. "BSD-1-Clause": [
  40854. "BSD 1-Clause License",
  40855. true,
  40856. false
  40857. ],
  40858. "BSD-2-Clause": [
  40859. "BSD 2-Clause \"Simplified\" License",
  40860. true,
  40861. false
  40862. ],
  40863. "BSD-2-Clause-FreeBSD": [
  40864. "BSD 2-Clause FreeBSD License",
  40865. false,
  40866. false
  40867. ],
  40868. "BSD-2-Clause-NetBSD": [
  40869. "BSD 2-Clause NetBSD License",
  40870. false,
  40871. true
  40872. ],
  40873. "BSD-2-Clause-Patent": [
  40874. "BSD-2-Clause Plus Patent License",
  40875. true,
  40876. false
  40877. ],
  40878. "BSD-3-Clause": [
  40879. "BSD 3-Clause \"New\" or \"Revised\" License",
  40880. true,
  40881. false
  40882. ],
  40883. "BSD-3-Clause-Attribution": [
  40884. "BSD with attribution",
  40885. false,
  40886. false
  40887. ],
  40888. "BSD-3-Clause-Clear": [
  40889. "BSD 3-Clause Clear License",
  40890. false,
  40891. false
  40892. ],
  40893. "BSD-3-Clause-LBNL": [
  40894. "Lawrence Berkeley National Labs BSD variant license",
  40895. true,
  40896. false
  40897. ],
  40898. "BSD-3-Clause-No-Nuclear-License": [
  40899. "BSD 3-Clause No Nuclear License",
  40900. false,
  40901. false
  40902. ],
  40903. "BSD-3-Clause-No-Nuclear-License-2014": [
  40904. "BSD 3-Clause No Nuclear License 2014",
  40905. false,
  40906. false
  40907. ],
  40908. "BSD-3-Clause-No-Nuclear-Warranty": [
  40909. "BSD 3-Clause No Nuclear Warranty",
  40910. false,
  40911. false
  40912. ],
  40913. "BSD-3-Clause-Open-MPI": [
  40914. "BSD 3-Clause Open MPI variant",
  40915. false,
  40916. false
  40917. ],
  40918. "BSD-4-Clause": [
  40919. "BSD 4-Clause \"Original\" or \"Old\" License",
  40920. false,
  40921. false
  40922. ],
  40923. "BSD-4-Clause-UC": [
  40924. "BSD-4-Clause (University of California-Specific)",
  40925. false,
  40926. false
  40927. ],
  40928. "BSD-Protection": [
  40929. "BSD Protection License",
  40930. false,
  40931. false
  40932. ],
  40933. "BSD-Source-Code": [
  40934. "BSD Source Code Attribution",
  40935. false,
  40936. false
  40937. ],
  40938. "BSL-1.0": [
  40939. "Boost Software License 1.0",
  40940. true,
  40941. false
  40942. ],
  40943. "bzip2-1.0.5": [
  40944. "bzip2 and libbzip2 License v1.0.5",
  40945. false,
  40946. false
  40947. ],
  40948. "bzip2-1.0.6": [
  40949. "bzip2 and libbzip2 License v1.0.6",
  40950. false,
  40951. false
  40952. ],
  40953. "CAL-1.0": [
  40954. "Cryptographic Autonomy License 1.0",
  40955. true,
  40956. false
  40957. ],
  40958. "CAL-1.0-Combined-Work-Exception": [
  40959. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  40960. true,
  40961. false
  40962. ],
  40963. "Caldera": [
  40964. "Caldera License",
  40965. false,
  40966. false
  40967. ],
  40968. "CATOSL-1.1": [
  40969. "Computer Associates Trusted Open Source License 1.1",
  40970. true,
  40971. false
  40972. ],
  40973. "CC-BY-1.0": [
  40974. "Creative Commons Attribution 1.0 Generic",
  40975. false,
  40976. false
  40977. ],
  40978. "CC-BY-2.0": [
  40979. "Creative Commons Attribution 2.0 Generic",
  40980. false,
  40981. false
  40982. ],
  40983. "CC-BY-2.5": [
  40984. "Creative Commons Attribution 2.5 Generic",
  40985. false,
  40986. false
  40987. ],
  40988. "CC-BY-3.0": [
  40989. "Creative Commons Attribution 3.0 Unported",
  40990. false,
  40991. false
  40992. ],
  40993. "CC-BY-4.0": [
  40994. "Creative Commons Attribution 4.0 International",
  40995. false,
  40996. false
  40997. ],
  40998. "CC-BY-NC-1.0": [
  40999. "Creative Commons Attribution Non Commercial 1.0 Generic",
  41000. false,
  41001. false
  41002. ],
  41003. "CC-BY-NC-2.0": [
  41004. "Creative Commons Attribution Non Commercial 2.0 Generic",
  41005. false,
  41006. false
  41007. ],
  41008. "CC-BY-NC-2.5": [
  41009. "Creative Commons Attribution Non Commercial 2.5 Generic",
  41010. false,
  41011. false
  41012. ],
  41013. "CC-BY-NC-3.0": [
  41014. "Creative Commons Attribution Non Commercial 3.0 Unported",
  41015. false,
  41016. false
  41017. ],
  41018. "CC-BY-NC-4.0": [
  41019. "Creative Commons Attribution Non Commercial 4.0 International",
  41020. false,
  41021. false
  41022. ],
  41023. "CC-BY-NC-ND-1.0": [
  41024. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  41025. false,
  41026. false
  41027. ],
  41028. "CC-BY-NC-ND-2.0": [
  41029. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  41030. false,
  41031. false
  41032. ],
  41033. "CC-BY-NC-ND-2.5": [
  41034. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  41035. false,
  41036. false
  41037. ],
  41038. "CC-BY-NC-ND-3.0": [
  41039. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  41040. false,
  41041. false
  41042. ],
  41043. "CC-BY-NC-ND-4.0": [
  41044. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  41045. false,
  41046. false
  41047. ],
  41048. "CC-BY-NC-SA-1.0": [
  41049. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  41050. false,
  41051. false
  41052. ],
  41053. "CC-BY-NC-SA-2.0": [
  41054. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  41055. false,
  41056. false
  41057. ],
  41058. "CC-BY-NC-SA-2.5": [
  41059. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  41060. false,
  41061. false
  41062. ],
  41063. "CC-BY-NC-SA-3.0": [
  41064. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  41065. false,
  41066. false
  41067. ],
  41068. "CC-BY-NC-SA-4.0": [
  41069. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  41070. false,
  41071. false
  41072. ],
  41073. "CC-BY-ND-1.0": [
  41074. "Creative Commons Attribution No Derivatives 1.0 Generic",
  41075. false,
  41076. false
  41077. ],
  41078. "CC-BY-ND-2.0": [
  41079. "Creative Commons Attribution No Derivatives 2.0 Generic",
  41080. false,
  41081. false
  41082. ],
  41083. "CC-BY-ND-2.5": [
  41084. "Creative Commons Attribution No Derivatives 2.5 Generic",
  41085. false,
  41086. false
  41087. ],
  41088. "CC-BY-ND-3.0": [
  41089. "Creative Commons Attribution No Derivatives 3.0 Unported",
  41090. false,
  41091. false
  41092. ],
  41093. "CC-BY-ND-4.0": [
  41094. "Creative Commons Attribution No Derivatives 4.0 International",
  41095. false,
  41096. false
  41097. ],
  41098. "CC-BY-SA-1.0": [
  41099. "Creative Commons Attribution Share Alike 1.0 Generic",
  41100. false,
  41101. false
  41102. ],
  41103. "CC-BY-SA-2.0": [
  41104. "Creative Commons Attribution Share Alike 2.0 Generic",
  41105. false,
  41106. false
  41107. ],
  41108. "CC-BY-SA-2.5": [
  41109. "Creative Commons Attribution Share Alike 2.5 Generic",
  41110. false,
  41111. false
  41112. ],
  41113. "CC-BY-SA-3.0": [
  41114. "Creative Commons Attribution Share Alike 3.0 Unported",
  41115. false,
  41116. false
  41117. ],
  41118. "CC-BY-SA-4.0": [
  41119. "Creative Commons Attribution Share Alike 4.0 International",
  41120. false,
  41121. false
  41122. ],
  41123. "CC-PDDC": [
  41124. "Creative Commons Public Domain Dedication and Certification",
  41125. false,
  41126. false
  41127. ],
  41128. "CC0-1.0": [
  41129. "Creative Commons Zero v1.0 Universal",
  41130. false,
  41131. false
  41132. ],
  41133. "CDDL-1.0": [
  41134. "Common Development and Distribution License 1.0",
  41135. true,
  41136. false
  41137. ],
  41138. "CDDL-1.1": [
  41139. "Common Development and Distribution License 1.1",
  41140. false,
  41141. false
  41142. ],
  41143. "CDLA-Permissive-1.0": [
  41144. "Community Data License Agreement Permissive 1.0",
  41145. false,
  41146. false
  41147. ],
  41148. "CDLA-Sharing-1.0": [
  41149. "Community Data License Agreement Sharing 1.0",
  41150. false,
  41151. false
  41152. ],
  41153. "CECILL-1.0": [
  41154. "CeCILL Free Software License Agreement v1.0",
  41155. false,
  41156. false
  41157. ],
  41158. "CECILL-1.1": [
  41159. "CeCILL Free Software License Agreement v1.1",
  41160. false,
  41161. false
  41162. ],
  41163. "CECILL-2.0": [
  41164. "CeCILL Free Software License Agreement v2.0",
  41165. false,
  41166. false
  41167. ],
  41168. "CECILL-2.1": [
  41169. "CeCILL Free Software License Agreement v2.1",
  41170. true,
  41171. false
  41172. ],
  41173. "CECILL-B": [
  41174. "CeCILL-B Free Software License Agreement",
  41175. false,
  41176. false
  41177. ],
  41178. "CECILL-C": [
  41179. "CeCILL-C Free Software License Agreement",
  41180. false,
  41181. false
  41182. ],
  41183. "CERN-OHL-1.1": [
  41184. "CERN Open Hardware Licence v1.1",
  41185. false,
  41186. false
  41187. ],
  41188. "CERN-OHL-1.2": [
  41189. "CERN Open Hardware Licence v1.2",
  41190. false,
  41191. false
  41192. ],
  41193. "CERN-OHL-P-2.0": [
  41194. "CERN Open Hardware Licence Version 2 - Permissive",
  41195. false,
  41196. false
  41197. ],
  41198. "CERN-OHL-S-2.0": [
  41199. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  41200. false,
  41201. false
  41202. ],
  41203. "CERN-OHL-W-2.0": [
  41204. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  41205. false,
  41206. false
  41207. ],
  41208. "ClArtistic": [
  41209. "Clarified Artistic License",
  41210. false,
  41211. false
  41212. ],
  41213. "CNRI-Jython": [
  41214. "CNRI Jython License",
  41215. false,
  41216. false
  41217. ],
  41218. "CNRI-Python": [
  41219. "CNRI Python License",
  41220. true,
  41221. false
  41222. ],
  41223. "CNRI-Python-GPL-Compatible": [
  41224. "CNRI Python Open Source GPL Compatible License Agreement",
  41225. false,
  41226. false
  41227. ],
  41228. "Condor-1.1": [
  41229. "Condor Public License v1.1",
  41230. false,
  41231. false
  41232. ],
  41233. "copyleft-next-0.3.0": [
  41234. "copyleft-next 0.3.0",
  41235. false,
  41236. false
  41237. ],
  41238. "copyleft-next-0.3.1": [
  41239. "copyleft-next 0.3.1",
  41240. false,
  41241. false
  41242. ],
  41243. "CPAL-1.0": [
  41244. "Common Public Attribution License 1.0",
  41245. true,
  41246. false
  41247. ],
  41248. "CPL-1.0": [
  41249. "Common Public License 1.0",
  41250. true,
  41251. false
  41252. ],
  41253. "CPOL-1.02": [
  41254. "Code Project Open License 1.02",
  41255. false,
  41256. false
  41257. ],
  41258. "Crossword": [
  41259. "Crossword License",
  41260. false,
  41261. false
  41262. ],
  41263. "CrystalStacker": [
  41264. "CrystalStacker License",
  41265. false,
  41266. false
  41267. ],
  41268. "CUA-OPL-1.0": [
  41269. "CUA Office Public License v1.0",
  41270. true,
  41271. false
  41272. ],
  41273. "Cube": [
  41274. "Cube License",
  41275. false,
  41276. false
  41277. ],
  41278. "curl": [
  41279. "curl License",
  41280. false,
  41281. false
  41282. ],
  41283. "D-FSL-1.0": [
  41284. "Deutsche Freie Software Lizenz",
  41285. false,
  41286. false
  41287. ],
  41288. "diffmark": [
  41289. "diffmark license",
  41290. false,
  41291. false
  41292. ],
  41293. "DOC": [
  41294. "DOC License",
  41295. false,
  41296. false
  41297. ],
  41298. "Dotseqn": [
  41299. "Dotseqn License",
  41300. false,
  41301. false
  41302. ],
  41303. "DSDP": [
  41304. "DSDP License",
  41305. false,
  41306. false
  41307. ],
  41308. "dvipdfm": [
  41309. "dvipdfm License",
  41310. false,
  41311. false
  41312. ],
  41313. "ECL-1.0": [
  41314. "Educational Community License v1.0",
  41315. true,
  41316. false
  41317. ],
  41318. "ECL-2.0": [
  41319. "Educational Community License v2.0",
  41320. true,
  41321. false
  41322. ],
  41323. "eCos-2.0": [
  41324. "eCos license version 2.0",
  41325. false,
  41326. true
  41327. ],
  41328. "EFL-1.0": [
  41329. "Eiffel Forum License v1.0",
  41330. true,
  41331. false
  41332. ],
  41333. "EFL-2.0": [
  41334. "Eiffel Forum License v2.0",
  41335. true,
  41336. false
  41337. ],
  41338. "eGenix": [
  41339. "eGenix.com Public License 1.1.0",
  41340. false,
  41341. false
  41342. ],
  41343. "Entessa": [
  41344. "Entessa Public License v1.0",
  41345. true,
  41346. false
  41347. ],
  41348. "EPL-1.0": [
  41349. "Eclipse Public License 1.0",
  41350. true,
  41351. false
  41352. ],
  41353. "EPL-2.0": [
  41354. "Eclipse Public License 2.0",
  41355. true,
  41356. false
  41357. ],
  41358. "ErlPL-1.1": [
  41359. "Erlang Public License v1.1",
  41360. false,
  41361. false
  41362. ],
  41363. "etalab-2.0": [
  41364. "Etalab Open License 2.0",
  41365. false,
  41366. false
  41367. ],
  41368. "EUDatagrid": [
  41369. "EU DataGrid Software License",
  41370. true,
  41371. false
  41372. ],
  41373. "EUPL-1.0": [
  41374. "European Union Public License 1.0",
  41375. false,
  41376. false
  41377. ],
  41378. "EUPL-1.1": [
  41379. "European Union Public License 1.1",
  41380. true,
  41381. false
  41382. ],
  41383. "EUPL-1.2": [
  41384. "European Union Public License 1.2",
  41385. true,
  41386. false
  41387. ],
  41388. "Eurosym": [
  41389. "Eurosym License",
  41390. false,
  41391. false
  41392. ],
  41393. "Fair": [
  41394. "Fair License",
  41395. true,
  41396. false
  41397. ],
  41398. "Frameworx-1.0": [
  41399. "Frameworx Open License 1.0",
  41400. true,
  41401. false
  41402. ],
  41403. "FreeImage": [
  41404. "FreeImage Public License v1.0",
  41405. false,
  41406. false
  41407. ],
  41408. "FSFAP": [
  41409. "FSF All Permissive License",
  41410. false,
  41411. false
  41412. ],
  41413. "FSFUL": [
  41414. "FSF Unlimited License",
  41415. false,
  41416. false
  41417. ],
  41418. "FSFULLR": [
  41419. "FSF Unlimited License (with License Retention)",
  41420. false,
  41421. false
  41422. ],
  41423. "FTL": [
  41424. "Freetype Project License",
  41425. false,
  41426. false
  41427. ],
  41428. "GFDL-1.1": [
  41429. "GNU Free Documentation License v1.1",
  41430. false,
  41431. true
  41432. ],
  41433. "GFDL-1.1-only": [
  41434. "GNU Free Documentation License v1.1 only",
  41435. false,
  41436. false
  41437. ],
  41438. "GFDL-1.1-or-later": [
  41439. "GNU Free Documentation License v1.1 or later",
  41440. false,
  41441. false
  41442. ],
  41443. "GFDL-1.2": [
  41444. "GNU Free Documentation License v1.2",
  41445. false,
  41446. true
  41447. ],
  41448. "GFDL-1.2-only": [
  41449. "GNU Free Documentation License v1.2 only",
  41450. false,
  41451. false
  41452. ],
  41453. "GFDL-1.2-or-later": [
  41454. "GNU Free Documentation License v1.2 or later",
  41455. false,
  41456. false
  41457. ],
  41458. "GFDL-1.3": [
  41459. "GNU Free Documentation License v1.3",
  41460. false,
  41461. true
  41462. ],
  41463. "GFDL-1.3-only": [
  41464. "GNU Free Documentation License v1.3 only",
  41465. false,
  41466. false
  41467. ],
  41468. "GFDL-1.3-or-later": [
  41469. "GNU Free Documentation License v1.3 or later",
  41470. false,
  41471. false
  41472. ],
  41473. "Giftware": [
  41474. "Giftware License",
  41475. false,
  41476. false
  41477. ],
  41478. "GL2PS": [
  41479. "GL2PS License",
  41480. false,
  41481. false
  41482. ],
  41483. "Glide": [
  41484. "3dfx Glide License",
  41485. false,
  41486. false
  41487. ],
  41488. "Glulxe": [
  41489. "Glulxe License",
  41490. false,
  41491. false
  41492. ],
  41493. "gnuplot": [
  41494. "gnuplot License",
  41495. false,
  41496. false
  41497. ],
  41498. "GPL-1.0": [
  41499. "GNU General Public License v1.0 only",
  41500. false,
  41501. true
  41502. ],
  41503. "GPL-1.0+": [
  41504. "GNU General Public License v1.0 or later",
  41505. false,
  41506. true
  41507. ],
  41508. "GPL-1.0-only": [
  41509. "GNU General Public License v1.0 only",
  41510. false,
  41511. false
  41512. ],
  41513. "GPL-1.0-or-later": [
  41514. "GNU General Public License v1.0 or later",
  41515. false,
  41516. false
  41517. ],
  41518. "GPL-2.0": [
  41519. "GNU General Public License v2.0 only",
  41520. true,
  41521. true
  41522. ],
  41523. "GPL-2.0+": [
  41524. "GNU General Public License v2.0 or later",
  41525. true,
  41526. true
  41527. ],
  41528. "GPL-2.0-only": [
  41529. "GNU General Public License v2.0 only",
  41530. true,
  41531. false
  41532. ],
  41533. "GPL-2.0-or-later": [
  41534. "GNU General Public License v2.0 or later",
  41535. true,
  41536. false
  41537. ],
  41538. "GPL-2.0-with-autoconf-exception": [
  41539. "GNU General Public License v2.0 w/Autoconf exception",
  41540. false,
  41541. true
  41542. ],
  41543. "GPL-2.0-with-bison-exception": [
  41544. "GNU General Public License v2.0 w/Bison exception",
  41545. false,
  41546. true
  41547. ],
  41548. "GPL-2.0-with-classpath-exception": [
  41549. "GNU General Public License v2.0 w/Classpath exception",
  41550. false,
  41551. true
  41552. ],
  41553. "GPL-2.0-with-font-exception": [
  41554. "GNU General Public License v2.0 w/Font exception",
  41555. false,
  41556. true
  41557. ],
  41558. "GPL-2.0-with-GCC-exception": [
  41559. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  41560. false,
  41561. true
  41562. ],
  41563. "GPL-3.0": [
  41564. "GNU General Public License v3.0 only",
  41565. true,
  41566. true
  41567. ],
  41568. "GPL-3.0+": [
  41569. "GNU General Public License v3.0 or later",
  41570. true,
  41571. true
  41572. ],
  41573. "GPL-3.0-only": [
  41574. "GNU General Public License v3.0 only",
  41575. true,
  41576. false
  41577. ],
  41578. "GPL-3.0-or-later": [
  41579. "GNU General Public License v3.0 or later",
  41580. true,
  41581. false
  41582. ],
  41583. "GPL-3.0-with-autoconf-exception": [
  41584. "GNU General Public License v3.0 w/Autoconf exception",
  41585. false,
  41586. true
  41587. ],
  41588. "GPL-3.0-with-GCC-exception": [
  41589. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  41590. true,
  41591. true
  41592. ],
  41593. "gSOAP-1.3b": [
  41594. "gSOAP Public License v1.3b",
  41595. false,
  41596. false
  41597. ],
  41598. "HaskellReport": [
  41599. "Haskell Language Report License",
  41600. false,
  41601. false
  41602. ],
  41603. "Hippocratic-2.1": [
  41604. "Hippocratic License 2.1",
  41605. false,
  41606. false
  41607. ],
  41608. "HPND": [
  41609. "Historical Permission Notice and Disclaimer",
  41610. true,
  41611. false
  41612. ],
  41613. "HPND-sell-variant": [
  41614. "Historical Permission Notice and Disclaimer - sell variant",
  41615. false,
  41616. false
  41617. ],
  41618. "IBM-pibs": [
  41619. "IBM PowerPC Initialization and Boot Software",
  41620. false,
  41621. false
  41622. ],
  41623. "ICU": [
  41624. "ICU License",
  41625. false,
  41626. false
  41627. ],
  41628. "IJG": [
  41629. "Independent JPEG Group License",
  41630. false,
  41631. false
  41632. ],
  41633. "ImageMagick": [
  41634. "ImageMagick License",
  41635. false,
  41636. false
  41637. ],
  41638. "iMatix": [
  41639. "iMatix Standard Function Library Agreement",
  41640. false,
  41641. false
  41642. ],
  41643. "Imlib2": [
  41644. "Imlib2 License",
  41645. false,
  41646. false
  41647. ],
  41648. "Info-ZIP": [
  41649. "Info-ZIP License",
  41650. false,
  41651. false
  41652. ],
  41653. "Intel": [
  41654. "Intel Open Source License",
  41655. true,
  41656. false
  41657. ],
  41658. "Intel-ACPI": [
  41659. "Intel ACPI Software License Agreement",
  41660. false,
  41661. false
  41662. ],
  41663. "Interbase-1.0": [
  41664. "Interbase Public License v1.0",
  41665. false,
  41666. false
  41667. ],
  41668. "IPA": [
  41669. "IPA Font License",
  41670. true,
  41671. false
  41672. ],
  41673. "IPL-1.0": [
  41674. "IBM Public License v1.0",
  41675. true,
  41676. false
  41677. ],
  41678. "ISC": [
  41679. "ISC License",
  41680. true,
  41681. false
  41682. ],
  41683. "JasPer-2.0": [
  41684. "JasPer License",
  41685. false,
  41686. false
  41687. ],
  41688. "JPNIC": [
  41689. "Japan Network Information Center License",
  41690. false,
  41691. false
  41692. ],
  41693. "JSON": [
  41694. "JSON License",
  41695. false,
  41696. false
  41697. ],
  41698. "LAL-1.2": [
  41699. "Licence Art Libre 1.2",
  41700. false,
  41701. false
  41702. ],
  41703. "LAL-1.3": [
  41704. "Licence Art Libre 1.3",
  41705. false,
  41706. false
  41707. ],
  41708. "Latex2e": [
  41709. "Latex2e License",
  41710. false,
  41711. false
  41712. ],
  41713. "Leptonica": [
  41714. "Leptonica License",
  41715. false,
  41716. false
  41717. ],
  41718. "LGPL-2.0": [
  41719. "GNU Library General Public License v2 only",
  41720. true,
  41721. true
  41722. ],
  41723. "LGPL-2.0+": [
  41724. "GNU Library General Public License v2 or later",
  41725. true,
  41726. true
  41727. ],
  41728. "LGPL-2.0-only": [
  41729. "GNU Library General Public License v2 only",
  41730. true,
  41731. false
  41732. ],
  41733. "LGPL-2.0-or-later": [
  41734. "GNU Library General Public License v2 or later",
  41735. true,
  41736. false
  41737. ],
  41738. "LGPL-2.1": [
  41739. "GNU Lesser General Public License v2.1 only",
  41740. true,
  41741. true
  41742. ],
  41743. "LGPL-2.1+": [
  41744. "GNU Library General Public License v2.1 or later",
  41745. true,
  41746. true
  41747. ],
  41748. "LGPL-2.1-only": [
  41749. "GNU Lesser General Public License v2.1 only",
  41750. true,
  41751. false
  41752. ],
  41753. "LGPL-2.1-or-later": [
  41754. "GNU Lesser General Public License v2.1 or later",
  41755. true,
  41756. false
  41757. ],
  41758. "LGPL-3.0": [
  41759. "GNU Lesser General Public License v3.0 only",
  41760. true,
  41761. true
  41762. ],
  41763. "LGPL-3.0+": [
  41764. "GNU Lesser General Public License v3.0 or later",
  41765. true,
  41766. true
  41767. ],
  41768. "LGPL-3.0-only": [
  41769. "GNU Lesser General Public License v3.0 only",
  41770. true,
  41771. false
  41772. ],
  41773. "LGPL-3.0-or-later": [
  41774. "GNU Lesser General Public License v3.0 or later",
  41775. true,
  41776. false
  41777. ],
  41778. "LGPLLR": [
  41779. "Lesser General Public License For Linguistic Resources",
  41780. false,
  41781. false
  41782. ],
  41783. "Libpng": [
  41784. "libpng License",
  41785. false,
  41786. false
  41787. ],
  41788. "libpng-2.0": [
  41789. "PNG Reference Library version 2",
  41790. false,
  41791. false
  41792. ],
  41793. "libselinux-1.0": [
  41794. "libselinux public domain notice",
  41795. false,
  41796. false
  41797. ],
  41798. "libtiff": [
  41799. "libtiff License",
  41800. false,
  41801. false
  41802. ],
  41803. "LiLiQ-P-1.1": [
  41804. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  41805. true,
  41806. false
  41807. ],
  41808. "LiLiQ-R-1.1": [
  41809. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  41810. true,
  41811. false
  41812. ],
  41813. "LiLiQ-Rplus-1.1": [
  41814. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  41815. true,
  41816. false
  41817. ],
  41818. "Linux-OpenIB": [
  41819. "Linux Kernel Variant of OpenIB.org license",
  41820. false,
  41821. false
  41822. ],
  41823. "LPL-1.0": [
  41824. "Lucent Public License Version 1.0",
  41825. true,
  41826. false
  41827. ],
  41828. "LPL-1.02": [
  41829. "Lucent Public License v1.02",
  41830. true,
  41831. false
  41832. ],
  41833. "LPPL-1.0": [
  41834. "LaTeX Project Public License v1.0",
  41835. false,
  41836. false
  41837. ],
  41838. "LPPL-1.1": [
  41839. "LaTeX Project Public License v1.1",
  41840. false,
  41841. false
  41842. ],
  41843. "LPPL-1.2": [
  41844. "LaTeX Project Public License v1.2",
  41845. false,
  41846. false
  41847. ],
  41848. "LPPL-1.3a": [
  41849. "LaTeX Project Public License v1.3a",
  41850. false,
  41851. false
  41852. ],
  41853. "LPPL-1.3c": [
  41854. "LaTeX Project Public License v1.3c",
  41855. true,
  41856. false
  41857. ],
  41858. "MakeIndex": [
  41859. "MakeIndex License",
  41860. false,
  41861. false
  41862. ],
  41863. "MirOS": [
  41864. "The MirOS Licence",
  41865. true,
  41866. false
  41867. ],
  41868. "MIT": [
  41869. "MIT License",
  41870. true,
  41871. false
  41872. ],
  41873. "MIT-0": [
  41874. "MIT No Attribution",
  41875. false,
  41876. false
  41877. ],
  41878. "MIT-advertising": [
  41879. "Enlightenment License (e16)",
  41880. false,
  41881. false
  41882. ],
  41883. "MIT-CMU": [
  41884. "CMU License",
  41885. false,
  41886. false
  41887. ],
  41888. "MIT-enna": [
  41889. "enna License",
  41890. false,
  41891. false
  41892. ],
  41893. "MIT-feh": [
  41894. "feh License",
  41895. false,
  41896. false
  41897. ],
  41898. "MITNFA": [
  41899. "MIT +no-false-attribs license",
  41900. false,
  41901. false
  41902. ],
  41903. "Motosoto": [
  41904. "Motosoto License",
  41905. true,
  41906. false
  41907. ],
  41908. "mpich2": [
  41909. "mpich2 License",
  41910. false,
  41911. false
  41912. ],
  41913. "MPL-1.0": [
  41914. "Mozilla Public License 1.0",
  41915. true,
  41916. false
  41917. ],
  41918. "MPL-1.1": [
  41919. "Mozilla Public License 1.1",
  41920. true,
  41921. false
  41922. ],
  41923. "MPL-2.0": [
  41924. "Mozilla Public License 2.0",
  41925. true,
  41926. false
  41927. ],
  41928. "MPL-2.0-no-copyleft-exception": [
  41929. "Mozilla Public License 2.0 (no copyleft exception)",
  41930. true,
  41931. false
  41932. ],
  41933. "MS-PL": [
  41934. "Microsoft Public License",
  41935. true,
  41936. false
  41937. ],
  41938. "MS-RL": [
  41939. "Microsoft Reciprocal License",
  41940. true,
  41941. false
  41942. ],
  41943. "MTLL": [
  41944. "Matrix Template Library License",
  41945. false,
  41946. false
  41947. ],
  41948. "MulanPSL-1.0": [
  41949. "Mulan Permissive Software License, Version 1",
  41950. false,
  41951. false
  41952. ],
  41953. "MulanPSL-2.0": [
  41954. "Mulan Permissive Software License, Version 2",
  41955. true,
  41956. false
  41957. ],
  41958. "Multics": [
  41959. "Multics License",
  41960. true,
  41961. false
  41962. ],
  41963. "Mup": [
  41964. "Mup License",
  41965. false,
  41966. false
  41967. ],
  41968. "NASA-1.3": [
  41969. "NASA Open Source Agreement 1.3",
  41970. true,
  41971. false
  41972. ],
  41973. "Naumen": [
  41974. "Naumen Public License",
  41975. true,
  41976. false
  41977. ],
  41978. "NBPL-1.0": [
  41979. "Net Boolean Public License v1",
  41980. false,
  41981. false
  41982. ],
  41983. "NCGL-UK-2.0": [
  41984. "Non-Commercial Government Licence",
  41985. false,
  41986. false
  41987. ],
  41988. "NCSA": [
  41989. "University of Illinois/NCSA Open Source License",
  41990. true,
  41991. false
  41992. ],
  41993. "Net-SNMP": [
  41994. "Net-SNMP License",
  41995. false,
  41996. false
  41997. ],
  41998. "NetCDF": [
  41999. "NetCDF license",
  42000. false,
  42001. false
  42002. ],
  42003. "Newsletr": [
  42004. "Newsletr License",
  42005. false,
  42006. false
  42007. ],
  42008. "NGPL": [
  42009. "Nethack General Public License",
  42010. true,
  42011. false
  42012. ],
  42013. "NLOD-1.0": [
  42014. "Norwegian Licence for Open Government Data",
  42015. false,
  42016. false
  42017. ],
  42018. "NLPL": [
  42019. "No Limit Public License",
  42020. false,
  42021. false
  42022. ],
  42023. "Nokia": [
  42024. "Nokia Open Source License",
  42025. true,
  42026. false
  42027. ],
  42028. "NOSL": [
  42029. "Netizen Open Source License",
  42030. false,
  42031. false
  42032. ],
  42033. "Noweb": [
  42034. "Noweb License",
  42035. false,
  42036. false
  42037. ],
  42038. "NPL-1.0": [
  42039. "Netscape Public License v1.0",
  42040. false,
  42041. false
  42042. ],
  42043. "NPL-1.1": [
  42044. "Netscape Public License v1.1",
  42045. false,
  42046. false
  42047. ],
  42048. "NPOSL-3.0": [
  42049. "Non-Profit Open Software License 3.0",
  42050. true,
  42051. false
  42052. ],
  42053. "NRL": [
  42054. "NRL License",
  42055. false,
  42056. false
  42057. ],
  42058. "NTP": [
  42059. "NTP License",
  42060. true,
  42061. false
  42062. ],
  42063. "NTP-0": [
  42064. "NTP No Attribution",
  42065. false,
  42066. false
  42067. ],
  42068. "Nunit": [
  42069. "Nunit License",
  42070. false,
  42071. true
  42072. ],
  42073. "O-UDA-1.0": [
  42074. "Open Use of Data Agreement v1.0",
  42075. false,
  42076. false
  42077. ],
  42078. "OCCT-PL": [
  42079. "Open CASCADE Technology Public License",
  42080. false,
  42081. false
  42082. ],
  42083. "OCLC-2.0": [
  42084. "OCLC Research Public License 2.0",
  42085. true,
  42086. false
  42087. ],
  42088. "ODbL-1.0": [
  42089. "ODC Open Database License v1.0",
  42090. false,
  42091. false
  42092. ],
  42093. "ODC-By-1.0": [
  42094. "Open Data Commons Attribution License v1.0",
  42095. false,
  42096. false
  42097. ],
  42098. "OFL-1.0": [
  42099. "SIL Open Font License 1.0",
  42100. false,
  42101. false
  42102. ],
  42103. "OFL-1.0-no-RFN": [
  42104. "SIL Open Font License 1.0 with no Reserved Font Name",
  42105. false,
  42106. false
  42107. ],
  42108. "OFL-1.0-RFN": [
  42109. "SIL Open Font License 1.0 with Reserved Font Name",
  42110. false,
  42111. false
  42112. ],
  42113. "OFL-1.1": [
  42114. "SIL Open Font License 1.1",
  42115. true,
  42116. false
  42117. ],
  42118. "OFL-1.1-no-RFN": [
  42119. "SIL Open Font License 1.1 with no Reserved Font Name",
  42120. true,
  42121. false
  42122. ],
  42123. "OFL-1.1-RFN": [
  42124. "SIL Open Font License 1.1 with Reserved Font Name",
  42125. true,
  42126. false
  42127. ],
  42128. "OGC-1.0": [
  42129. "OGC Software License, Version 1.0",
  42130. false,
  42131. false
  42132. ],
  42133. "OGL-Canada-2.0": [
  42134. "Open Government Licence - Canada",
  42135. false,
  42136. false
  42137. ],
  42138. "OGL-UK-1.0": [
  42139. "Open Government Licence v1.0",
  42140. false,
  42141. false
  42142. ],
  42143. "OGL-UK-2.0": [
  42144. "Open Government Licence v2.0",
  42145. false,
  42146. false
  42147. ],
  42148. "OGL-UK-3.0": [
  42149. "Open Government Licence v3.0",
  42150. false,
  42151. false
  42152. ],
  42153. "OGTSL": [
  42154. "Open Group Test Suite License",
  42155. true,
  42156. false
  42157. ],
  42158. "OLDAP-1.1": [
  42159. "Open LDAP Public License v1.1",
  42160. false,
  42161. false
  42162. ],
  42163. "OLDAP-1.2": [
  42164. "Open LDAP Public License v1.2",
  42165. false,
  42166. false
  42167. ],
  42168. "OLDAP-1.3": [
  42169. "Open LDAP Public License v1.3",
  42170. false,
  42171. false
  42172. ],
  42173. "OLDAP-1.4": [
  42174. "Open LDAP Public License v1.4",
  42175. false,
  42176. false
  42177. ],
  42178. "OLDAP-2.0": [
  42179. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  42180. false,
  42181. false
  42182. ],
  42183. "OLDAP-2.0.1": [
  42184. "Open LDAP Public License v2.0.1",
  42185. false,
  42186. false
  42187. ],
  42188. "OLDAP-2.1": [
  42189. "Open LDAP Public License v2.1",
  42190. false,
  42191. false
  42192. ],
  42193. "OLDAP-2.2": [
  42194. "Open LDAP Public License v2.2",
  42195. false,
  42196. false
  42197. ],
  42198. "OLDAP-2.2.1": [
  42199. "Open LDAP Public License v2.2.1",
  42200. false,
  42201. false
  42202. ],
  42203. "OLDAP-2.2.2": [
  42204. "Open LDAP Public License 2.2.2",
  42205. false,
  42206. false
  42207. ],
  42208. "OLDAP-2.3": [
  42209. "Open LDAP Public License v2.3",
  42210. false,
  42211. false
  42212. ],
  42213. "OLDAP-2.4": [
  42214. "Open LDAP Public License v2.4",
  42215. false,
  42216. false
  42217. ],
  42218. "OLDAP-2.5": [
  42219. "Open LDAP Public License v2.5",
  42220. false,
  42221. false
  42222. ],
  42223. "OLDAP-2.6": [
  42224. "Open LDAP Public License v2.6",
  42225. false,
  42226. false
  42227. ],
  42228. "OLDAP-2.7": [
  42229. "Open LDAP Public License v2.7",
  42230. false,
  42231. false
  42232. ],
  42233. "OLDAP-2.8": [
  42234. "Open LDAP Public License v2.8",
  42235. false,
  42236. false
  42237. ],
  42238. "OML": [
  42239. "Open Market License",
  42240. false,
  42241. false
  42242. ],
  42243. "OpenSSL": [
  42244. "OpenSSL License",
  42245. false,
  42246. false
  42247. ],
  42248. "OPL-1.0": [
  42249. "Open Public License v1.0",
  42250. false,
  42251. false
  42252. ],
  42253. "OSET-PL-2.1": [
  42254. "OSET Public License version 2.1",
  42255. true,
  42256. false
  42257. ],
  42258. "OSL-1.0": [
  42259. "Open Software License 1.0",
  42260. true,
  42261. false
  42262. ],
  42263. "OSL-1.1": [
  42264. "Open Software License 1.1",
  42265. false,
  42266. false
  42267. ],
  42268. "OSL-2.0": [
  42269. "Open Software License 2.0",
  42270. true,
  42271. false
  42272. ],
  42273. "OSL-2.1": [
  42274. "Open Software License 2.1",
  42275. true,
  42276. false
  42277. ],
  42278. "OSL-3.0": [
  42279. "Open Software License 3.0",
  42280. true,
  42281. false
  42282. ],
  42283. "Parity-6.0.0": [
  42284. "The Parity Public License 6.0.0",
  42285. false,
  42286. false
  42287. ],
  42288. "Parity-7.0.0": [
  42289. "The Parity Public License 7.0.0",
  42290. false,
  42291. false
  42292. ],
  42293. "PDDL-1.0": [
  42294. "ODC Public Domain Dedication & License 1.0",
  42295. false,
  42296. false
  42297. ],
  42298. "PHP-3.0": [
  42299. "PHP License v3.0",
  42300. true,
  42301. false
  42302. ],
  42303. "PHP-3.01": [
  42304. "PHP License v3.01",
  42305. false,
  42306. false
  42307. ],
  42308. "Plexus": [
  42309. "Plexus Classworlds License",
  42310. false,
  42311. false
  42312. ],
  42313. "PolyForm-Noncommercial-1.0.0": [
  42314. "PolyForm Noncommercial License 1.0.0",
  42315. false,
  42316. false
  42317. ],
  42318. "PolyForm-Small-Business-1.0.0": [
  42319. "PolyForm Small Business License 1.0.0",
  42320. false,
  42321. false
  42322. ],
  42323. "PostgreSQL": [
  42324. "PostgreSQL License",
  42325. true,
  42326. false
  42327. ],
  42328. "PSF-2.0": [
  42329. "Python Software Foundation License 2.0",
  42330. false,
  42331. false
  42332. ],
  42333. "psfrag": [
  42334. "psfrag License",
  42335. false,
  42336. false
  42337. ],
  42338. "psutils": [
  42339. "psutils License",
  42340. false,
  42341. false
  42342. ],
  42343. "Python-2.0": [
  42344. "Python License 2.0",
  42345. true,
  42346. false
  42347. ],
  42348. "Qhull": [
  42349. "Qhull License",
  42350. false,
  42351. false
  42352. ],
  42353. "QPL-1.0": [
  42354. "Q Public License 1.0",
  42355. true,
  42356. false
  42357. ],
  42358. "Rdisc": [
  42359. "Rdisc License",
  42360. false,
  42361. false
  42362. ],
  42363. "RHeCos-1.1": [
  42364. "Red Hat eCos Public License v1.1",
  42365. false,
  42366. false
  42367. ],
  42368. "RPL-1.1": [
  42369. "Reciprocal Public License 1.1",
  42370. true,
  42371. false
  42372. ],
  42373. "RPL-1.5": [
  42374. "Reciprocal Public License 1.5",
  42375. true,
  42376. false
  42377. ],
  42378. "RPSL-1.0": [
  42379. "RealNetworks Public Source License v1.0",
  42380. true,
  42381. false
  42382. ],
  42383. "RSA-MD": [
  42384. "RSA Message-Digest License",
  42385. false,
  42386. false
  42387. ],
  42388. "RSCPL": [
  42389. "Ricoh Source Code Public License",
  42390. true,
  42391. false
  42392. ],
  42393. "Ruby": [
  42394. "Ruby License",
  42395. false,
  42396. false
  42397. ],
  42398. "SAX-PD": [
  42399. "Sax Public Domain Notice",
  42400. false,
  42401. false
  42402. ],
  42403. "Saxpath": [
  42404. "Saxpath License",
  42405. false,
  42406. false
  42407. ],
  42408. "SCEA": [
  42409. "SCEA Shared Source License",
  42410. false,
  42411. false
  42412. ],
  42413. "Sendmail": [
  42414. "Sendmail License",
  42415. false,
  42416. false
  42417. ],
  42418. "Sendmail-8.23": [
  42419. "Sendmail License 8.23",
  42420. false,
  42421. false
  42422. ],
  42423. "SGI-B-1.0": [
  42424. "SGI Free Software License B v1.0",
  42425. false,
  42426. false
  42427. ],
  42428. "SGI-B-1.1": [
  42429. "SGI Free Software License B v1.1",
  42430. false,
  42431. false
  42432. ],
  42433. "SGI-B-2.0": [
  42434. "SGI Free Software License B v2.0",
  42435. false,
  42436. false
  42437. ],
  42438. "SHL-0.5": [
  42439. "Solderpad Hardware License v0.5",
  42440. false,
  42441. false
  42442. ],
  42443. "SHL-0.51": [
  42444. "Solderpad Hardware License, Version 0.51",
  42445. false,
  42446. false
  42447. ],
  42448. "SimPL-2.0": [
  42449. "Simple Public License 2.0",
  42450. true,
  42451. false
  42452. ],
  42453. "SISSL": [
  42454. "Sun Industry Standards Source License v1.1",
  42455. true,
  42456. false
  42457. ],
  42458. "SISSL-1.2": [
  42459. "Sun Industry Standards Source License v1.2",
  42460. false,
  42461. false
  42462. ],
  42463. "Sleepycat": [
  42464. "Sleepycat License",
  42465. true,
  42466. false
  42467. ],
  42468. "SMLNJ": [
  42469. "Standard ML of New Jersey License",
  42470. false,
  42471. false
  42472. ],
  42473. "SMPPL": [
  42474. "Secure Messaging Protocol Public License",
  42475. false,
  42476. false
  42477. ],
  42478. "SNIA": [
  42479. "SNIA Public License 1.1",
  42480. false,
  42481. false
  42482. ],
  42483. "Spencer-86": [
  42484. "Spencer License 86",
  42485. false,
  42486. false
  42487. ],
  42488. "Spencer-94": [
  42489. "Spencer License 94",
  42490. false,
  42491. false
  42492. ],
  42493. "Spencer-99": [
  42494. "Spencer License 99",
  42495. false,
  42496. false
  42497. ],
  42498. "SPL-1.0": [
  42499. "Sun Public License v1.0",
  42500. true,
  42501. false
  42502. ],
  42503. "SSH-OpenSSH": [
  42504. "SSH OpenSSH license",
  42505. false,
  42506. false
  42507. ],
  42508. "SSH-short": [
  42509. "SSH short notice",
  42510. false,
  42511. false
  42512. ],
  42513. "SSPL-1.0": [
  42514. "Server Side Public License, v 1",
  42515. false,
  42516. false
  42517. ],
  42518. "StandardML-NJ": [
  42519. "Standard ML of New Jersey License",
  42520. false,
  42521. true
  42522. ],
  42523. "SugarCRM-1.1.3": [
  42524. "SugarCRM Public License v1.1.3",
  42525. false,
  42526. false
  42527. ],
  42528. "SWL": [
  42529. "Scheme Widget Library (SWL) Software License Agreement",
  42530. false,
  42531. false
  42532. ],
  42533. "TAPR-OHL-1.0": [
  42534. "TAPR Open Hardware License v1.0",
  42535. false,
  42536. false
  42537. ],
  42538. "TCL": [
  42539. "TCL/TK License",
  42540. false,
  42541. false
  42542. ],
  42543. "TCP-wrappers": [
  42544. "TCP Wrappers License",
  42545. false,
  42546. false
  42547. ],
  42548. "TMate": [
  42549. "TMate Open Source License",
  42550. false,
  42551. false
  42552. ],
  42553. "TORQUE-1.1": [
  42554. "TORQUE v2.5+ Software License v1.1",
  42555. false,
  42556. false
  42557. ],
  42558. "TOSL": [
  42559. "Trusster Open Source License",
  42560. false,
  42561. false
  42562. ],
  42563. "TU-Berlin-1.0": [
  42564. "Technische Universitaet Berlin License 1.0",
  42565. false,
  42566. false
  42567. ],
  42568. "TU-Berlin-2.0": [
  42569. "Technische Universitaet Berlin License 2.0",
  42570. false,
  42571. false
  42572. ],
  42573. "UCL-1.0": [
  42574. "Upstream Compatibility License v1.0",
  42575. true,
  42576. false
  42577. ],
  42578. "Unicode-DFS-2015": [
  42579. "Unicode License Agreement - Data Files and Software (2015)",
  42580. false,
  42581. false
  42582. ],
  42583. "Unicode-DFS-2016": [
  42584. "Unicode License Agreement - Data Files and Software (2016)",
  42585. false,
  42586. false
  42587. ],
  42588. "Unicode-TOU": [
  42589. "Unicode Terms of Use",
  42590. false,
  42591. false
  42592. ],
  42593. "Unlicense": [
  42594. "The Unlicense",
  42595. false,
  42596. false
  42597. ],
  42598. "UPL-1.0": [
  42599. "Universal Permissive License v1.0",
  42600. true,
  42601. false
  42602. ],
  42603. "Vim": [
  42604. "Vim License",
  42605. false,
  42606. false
  42607. ],
  42608. "VOSTROM": [
  42609. "VOSTROM Public License for Open Source",
  42610. false,
  42611. false
  42612. ],
  42613. "VSL-1.0": [
  42614. "Vovida Software License v1.0",
  42615. true,
  42616. false
  42617. ],
  42618. "W3C": [
  42619. "W3C Software Notice and License (2002-12-31)",
  42620. true,
  42621. false
  42622. ],
  42623. "W3C-19980720": [
  42624. "W3C Software Notice and License (1998-07-20)",
  42625. false,
  42626. false
  42627. ],
  42628. "W3C-20150513": [
  42629. "W3C Software Notice and Document License (2015-05-13)",
  42630. false,
  42631. false
  42632. ],
  42633. "Watcom-1.0": [
  42634. "Sybase Open Watcom Public License 1.0",
  42635. true,
  42636. false
  42637. ],
  42638. "Wsuipa": [
  42639. "Wsuipa License",
  42640. false,
  42641. false
  42642. ],
  42643. "WTFPL": [
  42644. "Do What The F*ck You Want To Public License",
  42645. false,
  42646. false
  42647. ],
  42648. "wxWindows": [
  42649. "wxWindows Library License",
  42650. false,
  42651. true
  42652. ],
  42653. "X11": [
  42654. "X11 License",
  42655. false,
  42656. false
  42657. ],
  42658. "Xerox": [
  42659. "Xerox License",
  42660. false,
  42661. false
  42662. ],
  42663. "XFree86-1.1": [
  42664. "XFree86 License 1.1",
  42665. false,
  42666. false
  42667. ],
  42668. "xinetd": [
  42669. "xinetd License",
  42670. false,
  42671. false
  42672. ],
  42673. "Xnet": [
  42674. "X.Net License",
  42675. true,
  42676. false
  42677. ],
  42678. "xpp": [
  42679. "XPP License",
  42680. false,
  42681. false
  42682. ],
  42683. "XSkat": [
  42684. "XSkat License",
  42685. false,
  42686. false
  42687. ],
  42688. "YPL-1.0": [
  42689. "Yahoo! Public License v1.0",
  42690. false,
  42691. false
  42692. ],
  42693. "YPL-1.1": [
  42694. "Yahoo! Public License v1.1",
  42695. false,
  42696. false
  42697. ],
  42698. "Zed": [
  42699. "Zed License",
  42700. false,
  42701. false
  42702. ],
  42703. "Zend-2.0": [
  42704. "Zend License v2.0",
  42705. false,
  42706. false
  42707. ],
  42708. "Zimbra-1.3": [
  42709. "Zimbra Public License v1.3",
  42710. false,
  42711. false
  42712. ],
  42713. "Zimbra-1.4": [
  42714. "Zimbra Public License v1.4",
  42715. false,
  42716. false
  42717. ],
  42718. "Zlib": [
  42719. "zlib License",
  42720. true,
  42721. false
  42722. ],
  42723. "zlib-acknowledgement": [
  42724. "zlib/libpng License with Acknowledgement",
  42725. false,
  42726. false
  42727. ],
  42728. "ZPL-1.1": [
  42729. "Zope Public License 1.1",
  42730. false,
  42731. false
  42732. ],
  42733. "ZPL-2.0": [
  42734. "Zope Public License 2.0",
  42735. true,
  42736. false
  42737. ],
  42738. "ZPL-2.1": [
  42739. "Zope Public License 2.1",
  42740. false,
  42741. false
  42742. ]
  42743. }<?php
  42744. namespace Composer\Spdx;
  42745. class SpdxLicenses
  42746. {
  42747. const LICENSES_FILE = 'spdx-licenses.json';
  42748. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  42749. private $licenses;
  42750. private $licensesExpression;
  42751. private $exceptions;
  42752. private $exceptionsExpression;
  42753. public function __construct()
  42754. {
  42755. $this->loadLicenses();
  42756. $this->loadExceptions();
  42757. }
  42758. public function getLicenseByIdentifier($identifier)
  42759. {
  42760. $key = strtolower($identifier);
  42761. if (!isset($this->licenses[$key])) {
  42762. return;
  42763. }
  42764. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  42765. return array(
  42766. $name,
  42767. $isOsiApproved,
  42768. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  42769. $isDeprecatedLicenseId,
  42770. );
  42771. }
  42772. public function getLicenses()
  42773. {
  42774. return $this->licenses;
  42775. }
  42776. public function getExceptionByIdentifier($identifier)
  42777. {
  42778. $key = strtolower($identifier);
  42779. if (!isset($this->exceptions[$key])) {
  42780. return;
  42781. }
  42782. list($identifier, $name) = $this->exceptions[$key];
  42783. return array(
  42784. $name,
  42785. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  42786. );
  42787. }
  42788. public function getIdentifierByName($name)
  42789. {
  42790. foreach ($this->licenses as $licenseData) {
  42791. if ($licenseData[1] === $name) {
  42792. return $licenseData[0];
  42793. }
  42794. }
  42795. foreach ($this->exceptions as $licenseData) {
  42796. if ($licenseData[1] === $name) {
  42797. return $licenseData[0];
  42798. }
  42799. }
  42800. }
  42801. public function isOsiApprovedByIdentifier($identifier)
  42802. {
  42803. return $this->licenses[strtolower($identifier)][2];
  42804. }
  42805. public function isDeprecatedByIdentifier($identifier)
  42806. {
  42807. return $this->licenses[strtolower($identifier)][3];
  42808. }
  42809. public function validate($license)
  42810. {
  42811. if (is_array($license)) {
  42812. $count = count($license);
  42813. if ($count !== count(array_filter($license, 'is_string'))) {
  42814. throw new \InvalidArgumentException('Array of strings expected.');
  42815. }
  42816. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  42817. }
  42818. if (!is_string($license)) {
  42819. throw new \InvalidArgumentException(sprintf(
  42820. 'Array or String expected, %s given.',
  42821. gettype($license)
  42822. ));
  42823. }
  42824. return $this->isValidLicenseString($license);
  42825. }
  42826. public static function getResourcesDir()
  42827. {
  42828. return dirname(__DIR__) . '/res';
  42829. }
  42830. private function loadLicenses()
  42831. {
  42832. if (null !== $this->licenses) {
  42833. return;
  42834. }
  42835. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  42836. $this->licenses = array();
  42837. foreach (json_decode($json, true) as $identifier => $license) {
  42838. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  42839. }
  42840. }
  42841. private function loadExceptions()
  42842. {
  42843. if (null !== $this->exceptions) {
  42844. return;
  42845. }
  42846. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  42847. $this->exceptions = array();
  42848. foreach (json_decode($json, true) as $identifier => $exception) {
  42849. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  42850. }
  42851. }
  42852. private function getLicensesExpression()
  42853. {
  42854. if (null === $this->licensesExpression) {
  42855. $licenses = array_map('preg_quote', array_keys($this->licenses));
  42856. rsort($licenses);
  42857. $licenses = implode('|', $licenses);
  42858. $this->licensesExpression = $licenses;
  42859. }
  42860. return $this->licensesExpression;
  42861. }
  42862. private function getExceptionsExpression()
  42863. {
  42864. if (null === $this->exceptionsExpression) {
  42865. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  42866. rsort($exceptions);
  42867. $exceptions = implode('|', $exceptions);
  42868. $this->exceptionsExpression = $exceptions;
  42869. }
  42870. return $this->exceptionsExpression;
  42871. }
  42872. private function isValidLicenseString($license)
  42873. {
  42874. if (isset($this->licenses[strtolower($license)])) {
  42875. return true;
  42876. }
  42877. $licenses = $this->getLicensesExpression();
  42878. $exceptions = $this->getExceptionsExpression();
  42879. $regex = <<<REGEX
  42880. {
  42881. (?(DEFINE)
  42882. # idstring: 1*( ALPHA / DIGIT / - / . )
  42883. (?<idstring>[\pL\pN.-]{1,})
  42884. # license-id: taken from list
  42885. (?<licenseid>${licenses})
  42886. # license-exception-id: taken from list
  42887. (?<licenseexceptionid>${exceptions})
  42888. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  42889. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  42890. # simple-expresssion: license-id / license-id+ / license-ref
  42891. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  42892. # compound-expression: 1*(
  42893. # simple-expression /
  42894. # simple-expression WITH license-exception-id /
  42895. # compound-expression AND compound-expression /
  42896. # compound-expression OR compound-expression
  42897. # ) / ( compound-expression ) )
  42898. (?<compound_head>
  42899. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  42900. | \( \s* (?&compound_expression) \s* \)
  42901. )
  42902. (?<compound_expression>
  42903. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  42904. )
  42905. # license-expression: 1*1(simple-expression / compound-expression)
  42906. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  42907. ) # end of define
  42908. ^(NONE | NOASSERTION | (?&license_expression))$
  42909. }xi
  42910. REGEX;
  42911. $match = preg_match($regex, $license);
  42912. if (0 === $match) {
  42913. return false;
  42914. }
  42915. if (false === $match) {
  42916. throw new \RuntimeException('Regex failed to compile/run.');
  42917. }
  42918. return true;
  42919. }
  42920. }
  42921. MIT License
  42922. Copyright (c) 2017 Composer
  42923. Permission is hereby granted, free of charge, to any person obtaining a copy
  42924. of this software and associated documentation files (the "Software"), to deal
  42925. in the Software without restriction, including without limitation the rights
  42926. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  42927. copies of the Software, and to permit persons to whom the Software is
  42928. furnished to do so, subject to the following conditions:
  42929. The above copyright notice and this permission notice shall be included in all
  42930. copies or substantial portions of the Software.
  42931. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  42932. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  42933. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  42934. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  42935. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  42936. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  42937. SOFTWARE.
  42938. <?php
  42939. namespace Composer\XdebugHandler;
  42940. class PhpConfig
  42941. {
  42942. public function useOriginal()
  42943. {
  42944. $this->getDataAndReset();
  42945. return array();
  42946. }
  42947. public function useStandard()
  42948. {
  42949. if ($data = $this->getDataAndReset()) {
  42950. return array('-n', '-c', $data['tmpIni']);
  42951. }
  42952. return array();
  42953. }
  42954. public function usePersistent()
  42955. {
  42956. if ($data = $this->getDataAndReset()) {
  42957. Process::setEnv('PHPRC', $data['tmpIni']);
  42958. Process::setEnv('PHP_INI_SCAN_DIR', '');
  42959. }
  42960. return array();
  42961. }
  42962. private function getDataAndReset()
  42963. {
  42964. if ($data = XdebugHandler::getRestartSettings()) {
  42965. Process::setEnv('PHPRC', $data['phprc']);
  42966. Process::setEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  42967. }
  42968. return $data;
  42969. }
  42970. }
  42971. <?php
  42972. namespace Composer\XdebugHandler;
  42973. class Process
  42974. {
  42975. public static function addColorOption(array $args, $colorOption)
  42976. {
  42977. if (!$colorOption
  42978. || in_array($colorOption, $args)
  42979. || !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
  42980. return $args;
  42981. }
  42982. if (isset($matches[2])) {
  42983. if (false !== ($index = array_search($matches[2].'auto', $args))) {
  42984. $args[$index] = $colorOption;
  42985. return $args;
  42986. } elseif (preg_grep('/^'.$matches[2].'/', $args)) {
  42987. return $args;
  42988. }
  42989. } elseif (in_array('--no-'.$matches[1], $args)) {
  42990. return $args;
  42991. }
  42992. if (false !== getenv('NO_COLOR')) {
  42993. return $args;
  42994. }
  42995. if (false !== ($index = array_search('--', $args))) {
  42996. array_splice($args, $index, 0, $colorOption);
  42997. } else {
  42998. $args[] = $colorOption;
  42999. }
  43000. return $args;
  43001. }
  43002. public static function escape($arg, $meta = true, $module = false)
  43003. {
  43004. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  43005. return "'".str_replace("'", "'\\''", $arg)."'";
  43006. }
  43007. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  43008. $arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  43009. if ($meta) {
  43010. $meta = $dquotes || preg_match('/%[^%]+%/', $arg);
  43011. if (!$meta) {
  43012. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  43013. } elseif ($module && !$dquotes && $quote) {
  43014. $meta = false;
  43015. }
  43016. }
  43017. if ($quote) {
  43018. $arg = '"'.preg_replace('/(\\\\*)$/', '$1$1', $arg).'"';
  43019. }
  43020. if ($meta) {
  43021. $arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
  43022. }
  43023. return $arg;
  43024. }
  43025. public static function supportsColor($output)
  43026. {
  43027. if ('Hyper' === getenv('TERM_PROGRAM')) {
  43028. return true;
  43029. }
  43030. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  43031. return (function_exists('sapi_windows_vt100_support')
  43032. && sapi_windows_vt100_support($output))
  43033. || false !== getenv('ANSICON')
  43034. || 'ON' === getenv('ConEmuANSI')
  43035. || 'xterm' === getenv('TERM');
  43036. }
  43037. if (function_exists('stream_isatty')) {
  43038. return stream_isatty($output);
  43039. }
  43040. if (function_exists('posix_isatty')) {
  43041. return posix_isatty($output);
  43042. }
  43043. $stat = fstat($output);
  43044. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  43045. }
  43046. public static function setEnv($name, $value = false)
  43047. {
  43048. $unset = false === $value;
  43049. if (!putenv($unset ? $name : $name.'='.$value)) {
  43050. return false;
  43051. }
  43052. if ($unset) {
  43053. unset($_SERVER[$name]);
  43054. } else {
  43055. $_SERVER[$name] = $value;
  43056. }
  43057. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  43058. if ($unset) {
  43059. unset($_ENV[$name]);
  43060. } else {
  43061. $_ENV[$name] = $value;
  43062. }
  43063. }
  43064. return true;
  43065. }
  43066. }
  43067. <?php
  43068. namespace Composer\XdebugHandler;
  43069. use Psr\Log\LoggerInterface;
  43070. use Psr\Log\LogLevel;
  43071. class Status
  43072. {
  43073. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  43074. const CHECK = 'Check';
  43075. const ERROR = 'Error';
  43076. const INFO = 'Info';
  43077. const NORESTART = 'NoRestart';
  43078. const RESTART = 'Restart';
  43079. const RESTARTING = 'Restarting';
  43080. const RESTARTED = 'Restarted';
  43081. private $debug;
  43082. private $envAllowXdebug;
  43083. private $loaded;
  43084. private $logger;
  43085. private $time;
  43086. public function __construct($envAllowXdebug, $debug)
  43087. {
  43088. $start = getenv(self::ENV_RESTART);
  43089. Process::setEnv(self::ENV_RESTART);
  43090. $this->time = $start ? round((microtime(true) - $start) * 1000) : 0;
  43091. $this->envAllowXdebug = $envAllowXdebug;
  43092. $this->debug = $debug && defined('STDERR');
  43093. }
  43094. public function setLogger(LoggerInterface $logger)
  43095. {
  43096. $this->logger = $logger;
  43097. }
  43098. public function report($op, $data)
  43099. {
  43100. if ($this->logger || $this->debug) {
  43101. call_user_func(array($this, 'report'.$op), $data);
  43102. }
  43103. }
  43104. private function output($text, $level = null)
  43105. {
  43106. if ($this->logger) {
  43107. $this->logger->log($level ?: LogLevel::DEBUG, $text);
  43108. }
  43109. if ($this->debug) {
  43110. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  43111. }
  43112. }
  43113. private function reportCheck($loaded)
  43114. {
  43115. $this->loaded = $loaded;
  43116. $this->output('Checking '.$this->envAllowXdebug);
  43117. }
  43118. private function reportError($error)
  43119. {
  43120. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  43121. }
  43122. private function reportInfo($info)
  43123. {
  43124. $this->output($info);
  43125. }
  43126. private function reportNoRestart()
  43127. {
  43128. $this->output($this->getLoadedMessage());
  43129. if ($this->loaded) {
  43130. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  43131. if (!getenv($this->envAllowXdebug)) {
  43132. $text .= ' Allowed by application';
  43133. }
  43134. $this->output($text);
  43135. }
  43136. }
  43137. private function reportRestart()
  43138. {
  43139. $this->output($this->getLoadedMessage());
  43140. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  43141. }
  43142. private function reportRestarted()
  43143. {
  43144. $loaded = $this->getLoadedMessage();
  43145. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  43146. $level = $this->loaded ? LogLevel::WARNING : null;
  43147. $this->output($text, $level);
  43148. }
  43149. private function reportRestarting($command)
  43150. {
  43151. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  43152. $this->output($text);
  43153. $text = 'Running '.$command;
  43154. $this->output($text);
  43155. }
  43156. private function getEnvAllow()
  43157. {
  43158. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  43159. }
  43160. private function getLoadedMessage()
  43161. {
  43162. $loaded = $this->loaded ? sprintf('loaded (%s)', $this->loaded) : 'not loaded';
  43163. return 'The Xdebug extension is '.$loaded;
  43164. }
  43165. }
  43166. <?php
  43167. namespace Composer\XdebugHandler;
  43168. use Psr\Log\LoggerInterface;
  43169. class XdebugHandler
  43170. {
  43171. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  43172. const SUFFIX_INIS = '_ORIGINAL_INIS';
  43173. const RESTART_ID = 'internal';
  43174. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  43175. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  43176. protected $tmpIni;
  43177. private static $inRestart;
  43178. private static $name;
  43179. private static $skipped;
  43180. private $cli;
  43181. private $colorOption;
  43182. private $debug;
  43183. private $envAllowXdebug;
  43184. private $envOriginalInis;
  43185. private $loaded;
  43186. private $persistent;
  43187. private $script;
  43188. private $statusWriter;
  43189. public function __construct($envPrefix, $colorOption = '')
  43190. {
  43191. if (!is_string($envPrefix) || empty($envPrefix) || !is_string($colorOption)) {
  43192. throw new \RuntimeException('Invalid constructor parameter');
  43193. }
  43194. self::$name = strtoupper($envPrefix);
  43195. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  43196. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  43197. $this->colorOption = $colorOption;
  43198. if (extension_loaded('xdebug')) {
  43199. $ext = new \ReflectionExtension('xdebug');
  43200. $this->loaded = $ext->getVersion() ?: 'unknown';
  43201. }
  43202. if ($this->cli = PHP_SAPI === 'cli') {
  43203. $this->debug = getenv(self::DEBUG);
  43204. }
  43205. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  43206. }
  43207. public function setLogger(LoggerInterface $logger)
  43208. {
  43209. $this->statusWriter->setLogger($logger);
  43210. return $this;
  43211. }
  43212. public function setMainScript($script)
  43213. {
  43214. $this->script = $script;
  43215. return $this;
  43216. }
  43217. public function setPersistent()
  43218. {
  43219. $this->persistent = true;
  43220. return $this;
  43221. }
  43222. public function check()
  43223. {
  43224. $this->notify(Status::CHECK, $this->loaded);
  43225. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  43226. if (empty($envArgs[0]) && $this->requiresRestart((bool) $this->loaded)) {
  43227. $this->notify(Status::RESTART);
  43228. if ($this->prepareRestart()) {
  43229. $command = $this->getCommand();
  43230. $this->restart($command);
  43231. }
  43232. return;
  43233. }
  43234. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  43235. $this->notify(Status::RESTARTED);
  43236. Process::setEnv($this->envAllowXdebug);
  43237. self::$inRestart = true;
  43238. if (!$this->loaded) {
  43239. self::$skipped = $envArgs[1];
  43240. }
  43241. $this->tryEnableSignals();
  43242. $this->setEnvRestartSettings($envArgs);
  43243. return;
  43244. }
  43245. $this->notify(Status::NORESTART);
  43246. if ($settings = self::getRestartSettings()) {
  43247. $this->syncSettings($settings);
  43248. }
  43249. }
  43250. public static function getAllIniFiles()
  43251. {
  43252. if (!empty(self::$name)) {
  43253. $env = getenv(self::$name.self::SUFFIX_INIS);
  43254. if (false !== $env) {
  43255. return explode(PATH_SEPARATOR, $env);
  43256. }
  43257. }
  43258. $paths = array((string) php_ini_loaded_file());
  43259. if ($scanned = php_ini_scanned_files()) {
  43260. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  43261. }
  43262. return $paths;
  43263. }
  43264. public static function getRestartSettings()
  43265. {
  43266. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  43267. if (count($envArgs) !== 6
  43268. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  43269. return;
  43270. }
  43271. return array(
  43272. 'tmpIni' => $envArgs[0],
  43273. 'scannedInis' => (bool) $envArgs[1],
  43274. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  43275. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  43276. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  43277. 'skipped' => $envArgs[5],
  43278. );
  43279. }
  43280. public static function getSkippedVersion()
  43281. {
  43282. return (string) self::$skipped;
  43283. }
  43284. protected function requiresRestart($isLoaded)
  43285. {
  43286. return $isLoaded;
  43287. }
  43288. protected function restart($command)
  43289. {
  43290. $this->doRestart($command);
  43291. }
  43292. private function doRestart($command)
  43293. {
  43294. $this->tryEnableSignals();
  43295. $this->notify(Status::RESTARTING, $command);
  43296. if (function_exists('proc_open')) {
  43297. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 80000) {
  43298. $command = '"'.$command.'"';
  43299. }
  43300. $process = proc_open($command, array(), $pipes);
  43301. if (is_resource($process)) {
  43302. $exitCode = proc_close($process);
  43303. }
  43304. } else {
  43305. passthru($command, $exitCode);
  43306. }
  43307. if (!isset($exitCode)) {
  43308. $this->notify(Status::ERROR, 'Unable to restart process');
  43309. $exitCode = -1;
  43310. } else {
  43311. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  43312. }
  43313. if ($this->debug === '2') {
  43314. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  43315. } else {
  43316. @unlink($this->tmpIni);
  43317. }
  43318. exit($exitCode);
  43319. }
  43320. private function prepareRestart()
  43321. {
  43322. $error = '';
  43323. $iniFiles = self::getAllIniFiles();
  43324. $scannedInis = count($iniFiles) > 1;
  43325. $tmpDir = sys_get_temp_dir();
  43326. if (!$this->cli) {
  43327. $error = 'Unsupported SAPI: '.PHP_SAPI;
  43328. } elseif (!defined('PHP_BINARY')) {
  43329. $error = 'PHP version is too old: '.PHP_VERSION;
  43330. } elseif (!$this->checkConfiguration($info)) {
  43331. $error = $info;
  43332. } elseif (!$this->checkScanDirConfig()) {
  43333. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  43334. } elseif (!$this->checkMainScript()) {
  43335. $error = 'Unable to access main script: '.$this->script;
  43336. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  43337. $error = $error ?: 'Unable to create temp ini file at: '.$tmpDir;
  43338. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  43339. $error = 'Unable to set environment variables';
  43340. }
  43341. if ($error) {
  43342. $this->notify(Status::ERROR, $error);
  43343. }
  43344. return empty($error);
  43345. }
  43346. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  43347. {
  43348. if (!$this->tmpIni = @tempnam($tmpDir, '')) {
  43349. return false;
  43350. }
  43351. if (empty($iniFiles[0])) {
  43352. array_shift($iniFiles);
  43353. }
  43354. $content = '';
  43355. $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  43356. foreach ($iniFiles as $file) {
  43357. if (($data = @file_get_contents($file)) === false) {
  43358. $error = 'Unable to read ini: '.$file;
  43359. return false;
  43360. }
  43361. $content .= preg_replace($regex, ';$1', $data).PHP_EOL;
  43362. }
  43363. if ($config = parse_ini_string($content)) {
  43364. $loaded = ini_get_all(null, false);
  43365. $content .= $this->mergeLoadedConfig($loaded, $config);
  43366. }
  43367. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  43368. return @file_put_contents($this->tmpIni, $content);
  43369. }
  43370. private function getCommand()
  43371. {
  43372. $php = array(PHP_BINARY);
  43373. $args = array_slice($_SERVER['argv'], 1);
  43374. if (!$this->persistent) {
  43375. array_push($php, '-n', '-c', $this->tmpIni);
  43376. }
  43377. if (defined('STDOUT') && Process::supportsColor(STDOUT)) {
  43378. $args = Process::addColorOption($args, $this->colorOption);
  43379. }
  43380. $args = array_merge($php, array($this->script), $args);
  43381. $cmd = Process::escape(array_shift($args), true, true);
  43382. foreach ($args as $arg) {
  43383. $cmd .= ' '.Process::escape($arg);
  43384. }
  43385. return $cmd;
  43386. }
  43387. private function setEnvironment($scannedInis, array $iniFiles)
  43388. {
  43389. $scanDir = getenv('PHP_INI_SCAN_DIR');
  43390. $phprc = getenv('PHPRC');
  43391. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  43392. return false;
  43393. }
  43394. if ($this->persistent) {
  43395. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  43396. return false;
  43397. }
  43398. }
  43399. $envArgs = array(
  43400. self::RESTART_ID,
  43401. $this->loaded,
  43402. (int) $scannedInis,
  43403. false === $scanDir ? '*' : $scanDir,
  43404. false === $phprc ? '*' : $phprc,
  43405. );
  43406. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  43407. }
  43408. private function notify($op, $data = null)
  43409. {
  43410. $this->statusWriter->report($op, $data);
  43411. }
  43412. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  43413. {
  43414. $content = '';
  43415. foreach ($loadedConfig as $name => $value) {
  43416. if (!is_string($value)
  43417. || strpos($name, 'xdebug') === 0
  43418. || $name === 'apc.mmap_file_mask') {
  43419. continue;
  43420. }
  43421. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  43422. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  43423. }
  43424. }
  43425. return $content;
  43426. }
  43427. private function checkMainScript()
  43428. {
  43429. if (null !== $this->script) {
  43430. return file_exists($this->script) || '--' === $this->script;
  43431. }
  43432. if (file_exists($this->script = $_SERVER['argv'][0])) {
  43433. return true;
  43434. }
  43435. $options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false;
  43436. $trace = debug_backtrace($options);
  43437. if (($main = end($trace)) && isset($main['file'])) {
  43438. return file_exists($this->script = $main['file']);
  43439. }
  43440. return false;
  43441. }
  43442. private function setEnvRestartSettings($envArgs)
  43443. {
  43444. $settings = array(
  43445. php_ini_loaded_file(),
  43446. $envArgs[2],
  43447. $envArgs[3],
  43448. $envArgs[4],
  43449. getenv($this->envOriginalInis),
  43450. self::$skipped,
  43451. );
  43452. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  43453. }
  43454. private function syncSettings(array $settings)
  43455. {
  43456. if (false === getenv($this->envOriginalInis)) {
  43457. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  43458. }
  43459. self::$skipped = $settings['skipped'];
  43460. $this->notify(Status::INFO, 'Process called with existing restart settings');
  43461. }
  43462. private function checkScanDirConfig()
  43463. {
  43464. return !(getenv('PHP_INI_SCAN_DIR')
  43465. && !PHP_CONFIG_FILE_SCAN_DIR
  43466. && (PHP_VERSION_ID < 70113
  43467. || PHP_VERSION_ID === 70200));
  43468. }
  43469. private function checkConfiguration(&$info)
  43470. {
  43471. if (false !== strpos(ini_get('disable_functions'), 'passthru')) {
  43472. $info = 'passthru function is disabled';
  43473. return false;
  43474. }
  43475. if (extension_loaded('uopz') && !ini_get('uopz.disable')) {
  43476. if (function_exists('uopz_allow_exit')) {
  43477. @uopz_allow_exit(true);
  43478. } else {
  43479. $info = 'uopz extension is not compatible';
  43480. return false;
  43481. }
  43482. }
  43483. return true;
  43484. }
  43485. private function tryEnableSignals()
  43486. {
  43487. if (!function_exists('pcntl_async_signals') || !function_exists('pcntl_signal')) {
  43488. return;
  43489. }
  43490. pcntl_async_signals(true);
  43491. $message = 'Async signals enabled';
  43492. if (!self::$inRestart) {
  43493. pcntl_signal(SIGINT, SIG_IGN);
  43494. $message .= ' (SIGINT = SIG_IGN)';
  43495. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  43496. pcntl_signal(SIGINT, SIG_DFL);
  43497. $message .= ' (SIGINT = SIG_DFL)';
  43498. }
  43499. $this->notify(Status::INFO, $message);
  43500. }
  43501. }
  43502. MIT License
  43503. Copyright (c) 2016
  43504. Permission is hereby granted, free of charge, to any person obtaining a copy
  43505. of this software and associated documentation files (the "Software"), to deal
  43506. in the Software without restriction, including without limitation the rights
  43507. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  43508. copies of the Software, and to permit persons to whom the Software is
  43509. furnished to do so, subject to the following conditions:
  43510. The above copyright notice and this permission notice shall be included in all
  43511. copies or substantial portions of the Software.
  43512. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  43513. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  43514. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  43515. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  43516. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  43517. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  43518. SOFTWARE.
  43519. <?php
  43520. namespace JsonSchema\Constraints;
  43521. use JsonSchema\Entity\JsonPointer;
  43522. use JsonSchema\Exception\InvalidArgumentException;
  43523. use JsonSchema\Exception\ValidationException;
  43524. use JsonSchema\Validator;
  43525. class BaseConstraint
  43526. {
  43527. protected $errors = array();
  43528. protected $errorMask = Validator::ERROR_NONE;
  43529. protected $factory;
  43530. public function __construct(Factory $factory = null)
  43531. {
  43532. $this->factory = $factory ?: new Factory();
  43533. }
  43534. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  43535. {
  43536. $error = array(
  43537. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  43538. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  43539. 'message' => $message,
  43540. 'constraint' => $constraint,
  43541. 'context' => $this->factory->getErrorContext(),
  43542. );
  43543. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  43544. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  43545. }
  43546. if (is_array($more) && count($more) > 0) {
  43547. $error += $more;
  43548. }
  43549. $this->errors[] = $error;
  43550. $this->errorMask |= $error['context'];
  43551. }
  43552. public function addErrors(array $errors)
  43553. {
  43554. if ($errors) {
  43555. $this->errors = array_merge($this->errors, $errors);
  43556. $errorMask = &$this->errorMask;
  43557. array_walk($errors, function ($error) use (&$errorMask) {
  43558. if (isset($error['context'])) {
  43559. $errorMask |= $error['context'];
  43560. }
  43561. });
  43562. }
  43563. }
  43564. public function getErrors($errorContext = Validator::ERROR_ALL)
  43565. {
  43566. if ($errorContext === Validator::ERROR_ALL) {
  43567. return $this->errors;
  43568. }
  43569. return array_filter($this->errors, function ($error) use ($errorContext) {
  43570. if ($errorContext & $error['context']) {
  43571. return true;
  43572. }
  43573. });
  43574. }
  43575. public function numErrors($errorContext = Validator::ERROR_ALL)
  43576. {
  43577. if ($errorContext === Validator::ERROR_ALL) {
  43578. return count($this->errors);
  43579. }
  43580. return count($this->getErrors($errorContext));
  43581. }
  43582. public function isValid()
  43583. {
  43584. return !$this->getErrors();
  43585. }
  43586. public function reset()
  43587. {
  43588. $this->errors = array();
  43589. $this->errorMask = Validator::ERROR_NONE;
  43590. }
  43591. public function getErrorMask()
  43592. {
  43593. return $this->errorMask;
  43594. }
  43595. public static function arrayToObjectRecursive($array)
  43596. {
  43597. $json = json_encode($array);
  43598. if (json_last_error() !== \JSON_ERROR_NONE) {
  43599. $message = 'Unable to encode schema array as JSON';
  43600. if (function_exists('json_last_error_msg')) {
  43601. $message .= ': ' . json_last_error_msg();
  43602. }
  43603. throw new InvalidArgumentException($message);
  43604. }
  43605. return (object) json_decode($json);
  43606. }
  43607. }
  43608. <?php
  43609. namespace JsonSchema\Constraints;
  43610. use JsonSchema\Entity\JsonPointer;
  43611. class CollectionConstraint extends Constraint
  43612. {
  43613. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  43614. {
  43615. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  43616. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  43617. }
  43618. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  43619. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  43620. }
  43621. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  43622. $unique = $value;
  43623. if (is_array($value) && count($value)) {
  43624. $unique = array_map(function ($e) {
  43625. return var_export($e, true);
  43626. }, $value);
  43627. }
  43628. if (count(array_unique($unique)) != count($value)) {
  43629. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  43630. }
  43631. }
  43632. if (isset($schema->items)) {
  43633. $this->validateItems($value, $schema, $path, $i);
  43634. }
  43635. }
  43636. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  43637. {
  43638. if (is_object($schema->items)) {
  43639. foreach ($value as $k => &$v) {
  43640. $initErrors = $this->getErrors();
  43641. $this->checkUndefined($v, $schema->items, $path, $k);
  43642. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  43643. $secondErrors = $this->getErrors();
  43644. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  43645. }
  43646. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  43647. $this->errors = $secondErrors;
  43648. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  43649. $this->errors = $initErrors;
  43650. }
  43651. }
  43652. unset($v);
  43653. } else {
  43654. foreach ($value as $k => &$v) {
  43655. if (array_key_exists($k, $schema->items)) {
  43656. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  43657. } else {
  43658. if (property_exists($schema, 'additionalItems')) {
  43659. if ($schema->additionalItems !== false) {
  43660. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  43661. } else {
  43662. $this->addError(
  43663. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  43664. }
  43665. } else {
  43666. $this->checkUndefined($v, new \stdClass(), $path, $k);
  43667. }
  43668. }
  43669. }
  43670. unset($v);
  43671. if (count($value) > 0) {
  43672. for ($k = count($value); $k < count($schema->items); $k++) {
  43673. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  43674. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  43675. }
  43676. }
  43677. }
  43678. }
  43679. }
  43680. <?php
  43681. namespace JsonSchema\Constraints;
  43682. use JsonSchema\Entity\JsonPointer;
  43683. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  43684. {
  43685. protected $inlineSchemaProperty = '$schema';
  43686. const CHECK_MODE_NONE = 0x00000000;
  43687. const CHECK_MODE_NORMAL = 0x00000001;
  43688. const CHECK_MODE_TYPE_CAST = 0x00000002;
  43689. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  43690. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  43691. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  43692. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  43693. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  43694. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  43695. protected function incrementPath(JsonPointer $path = null, $i)
  43696. {
  43697. $path = $path ?: new JsonPointer('');
  43698. $path = $path->withPropertyPaths(
  43699. array_merge(
  43700. $path->getPropertyPaths(),
  43701. array_filter(array($i), 'strlen')
  43702. )
  43703. );
  43704. return $path;
  43705. }
  43706. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  43707. {
  43708. $validator = $this->factory->createInstanceFor('collection');
  43709. $validator->check($value, $schema, $path, $i);
  43710. $this->addErrors($validator->getErrors());
  43711. }
  43712. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  43713. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  43714. {
  43715. $validator = $this->factory->createInstanceFor('object');
  43716. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  43717. $this->addErrors($validator->getErrors());
  43718. }
  43719. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  43720. {
  43721. $validator = $this->factory->createInstanceFor('type');
  43722. $validator->check($value, $schema, $path, $i);
  43723. $this->addErrors($validator->getErrors());
  43724. }
  43725. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  43726. {
  43727. $validator = $this->factory->createInstanceFor('undefined');
  43728. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  43729. $this->addErrors($validator->getErrors());
  43730. }
  43731. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  43732. {
  43733. $validator = $this->factory->createInstanceFor('string');
  43734. $validator->check($value, $schema, $path, $i);
  43735. $this->addErrors($validator->getErrors());
  43736. }
  43737. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  43738. {
  43739. $validator = $this->factory->createInstanceFor('number');
  43740. $validator->check($value, $schema, $path, $i);
  43741. $this->addErrors($validator->getErrors());
  43742. }
  43743. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  43744. {
  43745. $validator = $this->factory->createInstanceFor('enum');
  43746. $validator->check($value, $schema, $path, $i);
  43747. $this->addErrors($validator->getErrors());
  43748. }
  43749. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  43750. {
  43751. $validator = $this->factory->createInstanceFor('format');
  43752. $validator->check($value, $schema, $path, $i);
  43753. $this->addErrors($validator->getErrors());
  43754. }
  43755. protected function getTypeCheck()
  43756. {
  43757. return $this->factory->getTypeCheck();
  43758. }
  43759. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  43760. {
  43761. $result = array_map(
  43762. function ($path) {
  43763. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  43764. },
  43765. $pointer->getPropertyPaths()
  43766. );
  43767. return trim(implode('', $result), '.');
  43768. }
  43769. }
  43770. <?php
  43771. namespace JsonSchema\Constraints;
  43772. use JsonSchema\Entity\JsonPointer;
  43773. interface ConstraintInterface
  43774. {
  43775. public function getErrors();
  43776. public function addErrors(array $errors);
  43777. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  43778. public function isValid();
  43779. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  43780. }
  43781. <?php
  43782. namespace JsonSchema\Constraints;
  43783. use JsonSchema\Entity\JsonPointer;
  43784. class EnumConstraint extends Constraint
  43785. {
  43786. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  43787. {
  43788. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  43789. return;
  43790. }
  43791. $type = gettype($element);
  43792. foreach ($schema->enum as $enum) {
  43793. $enumType = gettype($enum);
  43794. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  43795. if ((object) $element == $enum) {
  43796. return;
  43797. }
  43798. }
  43799. if ($type === gettype($enum)) {
  43800. if ($type == 'object') {
  43801. if ($element == $enum) {
  43802. return;
  43803. }
  43804. } elseif ($element === $enum) {
  43805. return;
  43806. }
  43807. }
  43808. }
  43809. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  43810. }
  43811. }
  43812. <?php
  43813. namespace JsonSchema\Constraints;
  43814. use JsonSchema\Exception\InvalidArgumentException;
  43815. use JsonSchema\SchemaStorage;
  43816. use JsonSchema\SchemaStorageInterface;
  43817. use JsonSchema\Uri\UriRetriever;
  43818. use JsonSchema\UriRetrieverInterface;
  43819. use JsonSchema\Validator;
  43820. class Factory
  43821. {
  43822. protected $schemaStorage;
  43823. protected $uriRetriever;
  43824. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  43825. private $typeCheck = array();
  43826. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  43827. protected $constraintMap = array(
  43828. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  43829. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  43830. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  43831. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  43832. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  43833. 'string' => 'JsonSchema\Constraints\StringConstraint',
  43834. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  43835. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  43836. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  43837. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  43838. 'validator' => 'JsonSchema\Validator'
  43839. );
  43840. private $instanceCache = array();
  43841. public function __construct(
  43842. SchemaStorageInterface $schemaStorage = null,
  43843. UriRetrieverInterface $uriRetriever = null,
  43844. $checkMode = Constraint::CHECK_MODE_NORMAL
  43845. ) {
  43846. $this->setConfig($checkMode);
  43847. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  43848. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  43849. }
  43850. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  43851. {
  43852. $this->checkMode = $checkMode;
  43853. }
  43854. public function addConfig($options)
  43855. {
  43856. $this->checkMode |= $options;
  43857. }
  43858. public function removeConfig($options)
  43859. {
  43860. $this->checkMode &= ~$options;
  43861. }
  43862. public function getConfig($options = null)
  43863. {
  43864. if ($options === null) {
  43865. return $this->checkMode;
  43866. }
  43867. return $this->checkMode & $options;
  43868. }
  43869. public function getUriRetriever()
  43870. {
  43871. return $this->uriRetriever;
  43872. }
  43873. public function getSchemaStorage()
  43874. {
  43875. return $this->schemaStorage;
  43876. }
  43877. public function getTypeCheck()
  43878. {
  43879. if (!isset($this->typeCheck[$this->checkMode])) {
  43880. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  43881. ? new TypeCheck\LooseTypeCheck()
  43882. : new TypeCheck\StrictTypeCheck();
  43883. }
  43884. return $this->typeCheck[$this->checkMode];
  43885. }
  43886. public function setConstraintClass($name, $class)
  43887. {
  43888. if (!class_exists($class)) {
  43889. throw new InvalidArgumentException('Unknown constraint ' . $name);
  43890. }
  43891. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  43892. throw new InvalidArgumentException('Invalid class ' . $name);
  43893. }
  43894. $this->constraintMap[$name] = $class;
  43895. return $this;
  43896. }
  43897. public function createInstanceFor($constraintName)
  43898. {
  43899. if (!isset($this->constraintMap[$constraintName])) {
  43900. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  43901. }
  43902. if (!isset($this->instanceCache[$constraintName])) {
  43903. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  43904. }
  43905. return clone $this->instanceCache[$constraintName];
  43906. }
  43907. public function getErrorContext()
  43908. {
  43909. return $this->errorContext;
  43910. }
  43911. public function setErrorContext($errorContext)
  43912. {
  43913. $this->errorContext = $errorContext;
  43914. }
  43915. }
  43916. <?php
  43917. namespace JsonSchema\Constraints;
  43918. use JsonSchema\Entity\JsonPointer;
  43919. use JsonSchema\Rfc3339;
  43920. class FormatConstraint extends Constraint
  43921. {
  43922. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  43923. {
  43924. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  43925. return;
  43926. }
  43927. switch ($schema->format) {
  43928. case 'date':
  43929. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  43930. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  43931. }
  43932. break;
  43933. case 'time':
  43934. if (!$this->validateDateTime($element, 'H:i:s')) {
  43935. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  43936. }
  43937. break;
  43938. case 'date-time':
  43939. if (null === Rfc3339::createFromString($element)) {
  43940. $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));
  43941. }
  43942. break;
  43943. case 'utc-millisec':
  43944. if (!$this->validateDateTime($element, 'U')) {
  43945. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  43946. }
  43947. break;
  43948. case 'regex':
  43949. if (!$this->validateRegex($element)) {
  43950. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  43951. }
  43952. break;
  43953. case 'color':
  43954. if (!$this->validateColor($element)) {
  43955. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  43956. }
  43957. break;
  43958. case 'style':
  43959. if (!$this->validateStyle($element)) {
  43960. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  43961. }
  43962. break;
  43963. case 'phone':
  43964. if (!$this->validatePhone($element)) {
  43965. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  43966. }
  43967. break;
  43968. case 'uri':
  43969. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  43970. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  43971. }
  43972. break;
  43973. case 'uriref':
  43974. case 'uri-reference':
  43975. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  43976. if (substr($element, 0, 2) === '//') {
  43977. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  43978. } elseif (substr($element, 0, 1) === '/') {
  43979. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  43980. } elseif (strlen($element)) {
  43981. $pathParts = explode('/', $element, 2);
  43982. if (strpos($pathParts[0], ':') !== false) {
  43983. $validURL = null;
  43984. } else {
  43985. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  43986. }
  43987. } else {
  43988. $validURL = null;
  43989. }
  43990. if ($validURL === null) {
  43991. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  43992. }
  43993. }
  43994. break;
  43995. case 'email':
  43996. $filterFlags = FILTER_NULL_ON_FAILURE;
  43997. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  43998. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  43999. }
  44000. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  44001. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  44002. }
  44003. break;
  44004. case 'ip-address':
  44005. case 'ipv4':
  44006. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  44007. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44008. }
  44009. break;
  44010. case 'ipv6':
  44011. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  44012. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44013. }
  44014. break;
  44015. case 'host-name':
  44016. case 'hostname':
  44017. if (!$this->validateHostname($element)) {
  44018. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  44019. }
  44020. break;
  44021. default:
  44022. break;
  44023. }
  44024. }
  44025. protected function validateDateTime($datetime, $format)
  44026. {
  44027. $dt = \DateTime::createFromFormat($format, $datetime);
  44028. if (!$dt) {
  44029. return false;
  44030. }
  44031. if ($datetime === $dt->format($format)) {
  44032. return true;
  44033. }
  44034. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  44035. return true;
  44036. }
  44037. return false;
  44038. }
  44039. protected function validateRegex($regex)
  44040. {
  44041. return false !== @preg_match('/' . $regex . '/u', '');
  44042. }
  44043. protected function validateColor($color)
  44044. {
  44045. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  44046. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  44047. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  44048. return true;
  44049. }
  44050. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  44051. }
  44052. protected function validateStyle($style)
  44053. {
  44054. $properties = explode(';', rtrim($style, ';'));
  44055. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  44056. return empty($invalidEntries);
  44057. }
  44058. protected function validatePhone($phone)
  44059. {
  44060. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  44061. }
  44062. protected function validateHostname($host)
  44063. {
  44064. $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';
  44065. return preg_match($hostnameRegex, $host);
  44066. }
  44067. }
  44068. <?php
  44069. namespace JsonSchema\Constraints;
  44070. use JsonSchema\Entity\JsonPointer;
  44071. class NumberConstraint extends Constraint
  44072. {
  44073. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44074. {
  44075. if (isset($schema->exclusiveMinimum)) {
  44076. if (isset($schema->minimum)) {
  44077. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  44078. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  44079. } elseif ($element < $schema->minimum) {
  44080. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44081. }
  44082. } else {
  44083. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  44084. }
  44085. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  44086. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44087. }
  44088. if (isset($schema->exclusiveMaximum)) {
  44089. if (isset($schema->maximum)) {
  44090. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  44091. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  44092. } elseif ($element > $schema->maximum) {
  44093. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44094. }
  44095. } else {
  44096. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  44097. }
  44098. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  44099. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44100. }
  44101. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  44102. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  44103. }
  44104. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  44105. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  44106. }
  44107. $this->checkFormat($element, $schema, $path, $i);
  44108. }
  44109. private function fmod($number1, $number2)
  44110. {
  44111. $modulus = ($number1 - round($number1 / $number2) * $number2);
  44112. $precision = 0.0000000001;
  44113. if (-$precision < $modulus && $modulus < $precision) {
  44114. return 0.0;
  44115. }
  44116. return $modulus;
  44117. }
  44118. }
  44119. <?php
  44120. namespace JsonSchema\Constraints;
  44121. use JsonSchema\Entity\JsonPointer;
  44122. class ObjectConstraint extends Constraint
  44123. {
  44124. protected $appliedDefaults = array();
  44125. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  44126. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  44127. {
  44128. if ($element instanceof UndefinedConstraint) {
  44129. return;
  44130. }
  44131. $this->appliedDefaults = $appliedDefaults;
  44132. $matches = array();
  44133. if ($patternProperties) {
  44134. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  44135. }
  44136. if ($properties) {
  44137. $this->validateProperties($element, $properties, $path);
  44138. }
  44139. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  44140. }
  44141. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  44142. {
  44143. $try = array('/', '#', '+', '~', '%');
  44144. $matches = array();
  44145. foreach ($patternProperties as $pregex => $schema) {
  44146. $delimiter = '/';
  44147. foreach ($try as $delimiter) {
  44148. if (strpos($pregex, $delimiter) === false) {
  44149. break;
  44150. }
  44151. }
  44152. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  44153. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  44154. continue;
  44155. }
  44156. foreach ($element as $i => $value) {
  44157. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  44158. $matches[] = $i;
  44159. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  44160. }
  44161. }
  44162. }
  44163. return $matches;
  44164. }
  44165. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  44166. $properties = null, $additionalProp = null)
  44167. {
  44168. $this->validateMinMaxConstraint($element, $schema, $path);
  44169. foreach ($element as $i => $value) {
  44170. $definition = $this->getProperty($properties, $i);
  44171. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  44172. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  44173. }
  44174. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  44175. if ($additionalProp === true) {
  44176. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  44177. } else {
  44178. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  44179. }
  44180. }
  44181. $require = $this->getProperty($definition, 'requires');
  44182. if ($require && !$this->getProperty($element, $require)) {
  44183. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  44184. }
  44185. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  44186. if (is_object($property)) {
  44187. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  44188. }
  44189. }
  44190. }
  44191. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  44192. {
  44193. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  44194. foreach ($properties as $i => $value) {
  44195. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  44196. $definition = $this->getProperty($properties, $i);
  44197. if (is_object($definition)) {
  44198. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  44199. }
  44200. }
  44201. }
  44202. protected function &getProperty(&$element, $property, $fallback = null)
  44203. {
  44204. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  44205. return $element[$property];
  44206. } elseif (is_object($element) && property_exists($element, $property)) {
  44207. return $element->$property;
  44208. }
  44209. return $fallback;
  44210. }
  44211. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  44212. {
  44213. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  44214. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  44215. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  44216. }
  44217. }
  44218. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  44219. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  44220. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  44221. }
  44222. }
  44223. }
  44224. }
  44225. <?php
  44226. namespace JsonSchema\Constraints;
  44227. use JsonSchema\Entity\JsonPointer;
  44228. use JsonSchema\Exception\InvalidArgumentException;
  44229. use JsonSchema\Exception\InvalidSchemaException;
  44230. use JsonSchema\Exception\RuntimeException;
  44231. use JsonSchema\Validator;
  44232. class SchemaConstraint extends Constraint
  44233. {
  44234. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  44235. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44236. {
  44237. if ($schema !== null) {
  44238. $validationSchema = $schema;
  44239. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  44240. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  44241. } else {
  44242. throw new InvalidArgumentException('no schema found to verify against');
  44243. }
  44244. if (is_array($validationSchema)) {
  44245. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  44246. }
  44247. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  44248. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  44249. throw new RuntimeException('Cannot validate the schema of a non-object');
  44250. }
  44251. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  44252. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  44253. } else {
  44254. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  44255. }
  44256. $schemaStorage = $this->factory->getSchemaStorage();
  44257. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  44258. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  44259. }
  44260. $initialErrorCount = $this->numErrors();
  44261. $initialConfig = $this->factory->getConfig();
  44262. $initialContext = $this->factory->getErrorContext();
  44263. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  44264. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  44265. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  44266. try {
  44267. $this->check($validationSchema, $schemaSpec);
  44268. } catch (\Exception $e) {
  44269. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  44270. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  44271. }
  44272. }
  44273. if ($this->numErrors() > $initialErrorCount) {
  44274. $this->addError($path, 'Schema is not valid', 'schema');
  44275. }
  44276. $this->factory->setConfig($initialConfig);
  44277. $this->factory->setErrorContext($initialContext);
  44278. }
  44279. $this->checkUndefined($element, $validationSchema, $path, $i);
  44280. }
  44281. }
  44282. <?php
  44283. namespace JsonSchema\Constraints;
  44284. use JsonSchema\Entity\JsonPointer;
  44285. class StringConstraint extends Constraint
  44286. {
  44287. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44288. {
  44289. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  44290. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  44291. 'maxLength' => $schema->maxLength,
  44292. ));
  44293. }
  44294. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  44295. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  44296. 'minLength' => $schema->minLength,
  44297. ));
  44298. }
  44299. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  44300. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  44301. 'pattern' => $schema->pattern,
  44302. ));
  44303. }
  44304. $this->checkFormat($element, $schema, $path, $i);
  44305. }
  44306. private function strlen($string)
  44307. {
  44308. if (extension_loaded('mbstring')) {
  44309. return mb_strlen($string, mb_detect_encoding($string));
  44310. }
  44311. return strlen($string);
  44312. }
  44313. }
  44314. <?php
  44315. namespace JsonSchema\Constraints\TypeCheck;
  44316. class LooseTypeCheck implements TypeCheckInterface
  44317. {
  44318. public static function isObject($value)
  44319. {
  44320. return
  44321. is_object($value) ||
  44322. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  44323. }
  44324. public static function isArray($value)
  44325. {
  44326. return
  44327. is_array($value) &&
  44328. (count($value) == 0 || !self::isAssociativeArray($value));
  44329. }
  44330. public static function propertyGet($value, $property)
  44331. {
  44332. if (is_object($value)) {
  44333. return $value->{$property};
  44334. }
  44335. return $value[$property];
  44336. }
  44337. public static function propertySet(&$value, $property, $data)
  44338. {
  44339. if (is_object($value)) {
  44340. $value->{$property} = $data;
  44341. } else {
  44342. $value[$property] = $data;
  44343. }
  44344. }
  44345. public static function propertyExists($value, $property)
  44346. {
  44347. if (is_object($value)) {
  44348. return property_exists($value, $property);
  44349. }
  44350. return array_key_exists($property, $value);
  44351. }
  44352. public static function propertyCount($value)
  44353. {
  44354. if (is_object($value)) {
  44355. return count(get_object_vars($value));
  44356. }
  44357. return count($value);
  44358. }
  44359. private static function isAssociativeArray($arr)
  44360. {
  44361. return array_keys($arr) !== range(0, count($arr) - 1);
  44362. }
  44363. }
  44364. <?php
  44365. namespace JsonSchema\Constraints\TypeCheck;
  44366. class StrictTypeCheck implements TypeCheckInterface
  44367. {
  44368. public static function isObject($value)
  44369. {
  44370. return is_object($value);
  44371. }
  44372. public static function isArray($value)
  44373. {
  44374. return is_array($value);
  44375. }
  44376. public static function propertyGet($value, $property)
  44377. {
  44378. return $value->{$property};
  44379. }
  44380. public static function propertySet(&$value, $property, $data)
  44381. {
  44382. $value->{$property} = $data;
  44383. }
  44384. public static function propertyExists($value, $property)
  44385. {
  44386. return property_exists($value, $property);
  44387. }
  44388. public static function propertyCount($value)
  44389. {
  44390. if (!is_object($value)) {
  44391. return 0;
  44392. }
  44393. return count(get_object_vars($value));
  44394. }
  44395. }
  44396. <?php
  44397. namespace JsonSchema\Constraints\TypeCheck;
  44398. interface TypeCheckInterface
  44399. {
  44400. public static function isObject($value);
  44401. public static function isArray($value);
  44402. public static function propertyGet($value, $property);
  44403. public static function propertySet(&$value, $property, $data);
  44404. public static function propertyExists($value, $property);
  44405. public static function propertyCount($value);
  44406. }
  44407. <?php
  44408. namespace JsonSchema\Constraints;
  44409. use JsonSchema\Entity\JsonPointer;
  44410. use JsonSchema\Exception\InvalidArgumentException;
  44411. use UnexpectedValueException as StandardUnexpectedValueException;
  44412. class TypeConstraint extends Constraint
  44413. {
  44414. public static $wording = array(
  44415. 'integer' => 'an integer',
  44416. 'number' => 'a number',
  44417. 'boolean' => 'a boolean',
  44418. 'object' => 'an object',
  44419. 'array' => 'an array',
  44420. 'string' => 'a string',
  44421. 'null' => 'a null',
  44422. 'any' => null,
  44423. 0 => null,
  44424. );
  44425. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  44426. {
  44427. $type = isset($schema->type) ? $schema->type : null;
  44428. $isValid = false;
  44429. $wording = array();
  44430. if (is_array($type)) {
  44431. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  44432. } elseif (is_object($type)) {
  44433. $this->checkUndefined($value, $type, $path);
  44434. return;
  44435. } else {
  44436. $isValid = $this->validateType($value, $type);
  44437. }
  44438. if ($isValid === false) {
  44439. if (!is_array($type)) {
  44440. $this->validateTypeNameWording($type);
  44441. $wording[] = self::$wording[$type];
  44442. }
  44443. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  44444. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  44445. }
  44446. }
  44447. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  44448. {
  44449. foreach ($type as $tp) {
  44450. if (is_object($tp)) {
  44451. if (!$isValid) {
  44452. $validator = $this->factory->createInstanceFor('type');
  44453. $subSchema = new \stdClass();
  44454. $subSchema->type = $tp;
  44455. $validator->check($value, $subSchema, $path, null);
  44456. $error = $validator->getErrors();
  44457. $isValid = !(bool) $error;
  44458. $validTypesWording[] = self::$wording['object'];
  44459. }
  44460. } else {
  44461. $this->validateTypeNameWording($tp);
  44462. $validTypesWording[] = self::$wording[$tp];
  44463. if (!$isValid) {
  44464. $isValid = $this->validateType($value, $tp);
  44465. }
  44466. }
  44467. }
  44468. }
  44469. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  44470. {
  44471. if ($listEnd === false || !isset($elements[1])) {
  44472. return implode($delimiter, $elements);
  44473. }
  44474. $lastElement = array_slice($elements, -1);
  44475. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  44476. $implodedElements = array_merge(array($firsElements), $lastElement);
  44477. return join(" $listEnd ", $implodedElements);
  44478. }
  44479. protected function validateTypeNameWording($type)
  44480. {
  44481. if (!isset(self::$wording[$type])) {
  44482. throw new StandardUnexpectedValueException(
  44483. sprintf(
  44484. 'No wording for %s available, expected wordings are: [%s]',
  44485. var_export($type, true),
  44486. implode(', ', array_filter(self::$wording)))
  44487. );
  44488. }
  44489. }
  44490. protected function validateType(&$value, $type)
  44491. {
  44492. if (!$type) {
  44493. return true;
  44494. }
  44495. if ('any' === $type) {
  44496. return true;
  44497. }
  44498. if ('object' === $type) {
  44499. return $this->getTypeCheck()->isObject($value);
  44500. }
  44501. if ('array' === $type) {
  44502. return $this->getTypeCheck()->isArray($value);
  44503. }
  44504. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  44505. if ('integer' === $type) {
  44506. if ($coerce) {
  44507. $value = $this->toInteger($value);
  44508. }
  44509. return is_int($value);
  44510. }
  44511. if ('number' === $type) {
  44512. if ($coerce) {
  44513. $value = $this->toNumber($value);
  44514. }
  44515. return is_numeric($value) && !is_string($value);
  44516. }
  44517. if ('boolean' === $type) {
  44518. if ($coerce) {
  44519. $value = $this->toBoolean($value);
  44520. }
  44521. return is_bool($value);
  44522. }
  44523. if ('string' === $type) {
  44524. return is_string($value);
  44525. }
  44526. if ('email' === $type) {
  44527. return is_string($value);
  44528. }
  44529. if ('null' === $type) {
  44530. return is_null($value);
  44531. }
  44532. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  44533. }
  44534. protected function toBoolean($value)
  44535. {
  44536. if ($value === 'true') {
  44537. return true;
  44538. }
  44539. if ($value === 'false') {
  44540. return false;
  44541. }
  44542. return $value;
  44543. }
  44544. protected function toNumber($value)
  44545. {
  44546. if (is_numeric($value)) {
  44547. return $value + 0;
  44548. }
  44549. return $value;
  44550. }
  44551. protected function toInteger($value)
  44552. {
  44553. if (is_numeric($value) && (int) $value == $value) {
  44554. return (int) $value;
  44555. }
  44556. return $value;
  44557. }
  44558. }
  44559. <?php
  44560. namespace JsonSchema\Constraints;
  44561. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  44562. use JsonSchema\Entity\JsonPointer;
  44563. use JsonSchema\Exception\ValidationException;
  44564. use JsonSchema\Uri\UriResolver;
  44565. class UndefinedConstraint extends Constraint
  44566. {
  44567. protected $appliedDefaults = array();
  44568. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  44569. {
  44570. if (is_null($schema) || !is_object($schema)) {
  44571. return;
  44572. }
  44573. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  44574. if ($fromDefault) {
  44575. $path->setFromDefault();
  44576. }
  44577. $this->validateCommonProperties($value, $schema, $path, $i);
  44578. $this->validateOfProperties($value, $schema, $path, '');
  44579. $this->validateTypes($value, $schema, $path, $i);
  44580. }
  44581. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  44582. {
  44583. if ($this->getTypeCheck()->isArray($value)) {
  44584. $this->checkArray($value, $schema, $path, $i);
  44585. }
  44586. if (LooseTypeCheck::isObject($value)) {
  44587. $this->checkObject(
  44588. $value,
  44589. $schema,
  44590. $path,
  44591. isset($schema->properties) ? $schema->properties : null,
  44592. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  44593. isset($schema->patternProperties) ? $schema->patternProperties : null,
  44594. $this->appliedDefaults
  44595. );
  44596. }
  44597. if (is_string($value)) {
  44598. $this->checkString($value, $schema, $path, $i);
  44599. }
  44600. if (is_numeric($value)) {
  44601. $this->checkNumber($value, $schema, $path, $i);
  44602. }
  44603. if (isset($schema->enum)) {
  44604. $this->checkEnum($value, $schema, $path, $i);
  44605. }
  44606. }
  44607. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  44608. {
  44609. if (isset($schema->extends)) {
  44610. if (is_string($schema->extends)) {
  44611. $schema->extends = $this->validateUri($schema, $schema->extends);
  44612. }
  44613. if (is_array($schema->extends)) {
  44614. foreach ($schema->extends as $extends) {
  44615. $this->checkUndefined($value, $extends, $path, $i);
  44616. }
  44617. } else {
  44618. $this->checkUndefined($value, $schema->extends, $path, $i);
  44619. }
  44620. }
  44621. if (!$path->fromDefault()) {
  44622. $this->applyDefaultValues($value, $schema, $path);
  44623. }
  44624. if ($this->getTypeCheck()->isObject($value)) {
  44625. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  44626. foreach ($schema->required as $required) {
  44627. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  44628. $this->addError(
  44629. $this->incrementPath($path ?: new JsonPointer(''), $required),
  44630. 'The property ' . $required . ' is required',
  44631. 'required'
  44632. );
  44633. }
  44634. }
  44635. } elseif (isset($schema->required) && !is_array($schema->required)) {
  44636. if ($schema->required && $value instanceof self) {
  44637. $propertyPaths = $path->getPropertyPaths();
  44638. $propertyName = end($propertyPaths);
  44639. $this->addError(
  44640. $path,
  44641. 'The property ' . $propertyName . ' is required',
  44642. 'required'
  44643. );
  44644. }
  44645. } else {
  44646. if ($value instanceof self) {
  44647. return;
  44648. }
  44649. }
  44650. }
  44651. if (!($value instanceof self)) {
  44652. $this->checkType($value, $schema, $path, $i);
  44653. }
  44654. if (isset($schema->disallow)) {
  44655. $initErrors = $this->getErrors();
  44656. $typeSchema = new \stdClass();
  44657. $typeSchema->type = $schema->disallow;
  44658. $this->checkType($value, $typeSchema, $path);
  44659. if (count($this->getErrors()) == count($initErrors)) {
  44660. $this->addError($path, 'Disallowed value was matched', 'disallow');
  44661. } else {
  44662. $this->errors = $initErrors;
  44663. }
  44664. }
  44665. if (isset($schema->not)) {
  44666. $initErrors = $this->getErrors();
  44667. $this->checkUndefined($value, $schema->not, $path, $i);
  44668. if (count($this->getErrors()) == count($initErrors)) {
  44669. $this->addError($path, 'Matched a schema which it should not', 'not');
  44670. } else {
  44671. $this->errors = $initErrors;
  44672. }
  44673. }
  44674. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  44675. $this->validateDependencies($value, $schema->dependencies, $path);
  44676. }
  44677. }
  44678. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  44679. {
  44680. if (!$requiredOnly) {
  44681. return true;
  44682. }
  44683. if (
  44684. $name !== null
  44685. && isset($parentSchema->required)
  44686. && is_array($parentSchema->required)
  44687. && in_array($name, $parentSchema->required)
  44688. ) {
  44689. return true;
  44690. }
  44691. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  44692. return true;
  44693. }
  44694. return false;
  44695. }
  44696. protected function applyDefaultValues(&$value, $schema, $path)
  44697. {
  44698. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  44699. return;
  44700. }
  44701. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  44702. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  44703. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  44704. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  44705. if (
  44706. !LooseTypeCheck::propertyExists($value, $currentProperty)
  44707. && property_exists($propertyDefinition, 'default')
  44708. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  44709. ) {
  44710. if (is_object($propertyDefinition->default)) {
  44711. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  44712. } else {
  44713. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  44714. }
  44715. $this->appliedDefaults[] = $currentProperty;
  44716. }
  44717. }
  44718. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  44719. $items = array();
  44720. if (LooseTypeCheck::isArray($schema->items)) {
  44721. $items = $schema->items;
  44722. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  44723. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  44724. }
  44725. foreach ($items as $currentItem => $itemDefinition) {
  44726. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  44727. if (
  44728. !array_key_exists($currentItem, $value)
  44729. && property_exists($itemDefinition, 'default')
  44730. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  44731. if (is_object($itemDefinition->default)) {
  44732. $value[$currentItem] = clone $itemDefinition->default;
  44733. } else {
  44734. $value[$currentItem] = $itemDefinition->default;
  44735. }
  44736. }
  44737. $path->setFromDefault();
  44738. }
  44739. } elseif (
  44740. $value instanceof self
  44741. && property_exists($schema, 'default')
  44742. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  44743. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  44744. $path->setFromDefault();
  44745. }
  44746. }
  44747. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  44748. {
  44749. if ($value instanceof self) {
  44750. return;
  44751. }
  44752. if (isset($schema->allOf)) {
  44753. $isValid = true;
  44754. foreach ($schema->allOf as $allOf) {
  44755. $initErrors = $this->getErrors();
  44756. $this->checkUndefined($value, $allOf, $path, $i);
  44757. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  44758. }
  44759. if (!$isValid) {
  44760. $this->addError($path, 'Failed to match all schemas', 'allOf');
  44761. }
  44762. }
  44763. if (isset($schema->anyOf)) {
  44764. $isValid = false;
  44765. $startErrors = $this->getErrors();
  44766. $caughtException = null;
  44767. foreach ($schema->anyOf as $anyOf) {
  44768. $initErrors = $this->getErrors();
  44769. try {
  44770. $this->checkUndefined($value, $anyOf, $path, $i);
  44771. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  44772. break;
  44773. }
  44774. } catch (ValidationException $e) {
  44775. $isValid = false;
  44776. }
  44777. }
  44778. if (!$isValid) {
  44779. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  44780. } else {
  44781. $this->errors = $startErrors;
  44782. }
  44783. }
  44784. if (isset($schema->oneOf)) {
  44785. $allErrors = array();
  44786. $matchedSchemas = 0;
  44787. $startErrors = $this->getErrors();
  44788. foreach ($schema->oneOf as $oneOf) {
  44789. try {
  44790. $this->errors = array();
  44791. $this->checkUndefined($value, $oneOf, $path, $i);
  44792. if (count($this->getErrors()) == 0) {
  44793. $matchedSchemas++;
  44794. }
  44795. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  44796. } catch (ValidationException $e) {
  44797. }
  44798. }
  44799. if ($matchedSchemas !== 1) {
  44800. $this->addErrors(array_merge($allErrors, $startErrors));
  44801. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  44802. } else {
  44803. $this->errors = $startErrors;
  44804. }
  44805. }
  44806. }
  44807. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  44808. {
  44809. foreach ($dependencies as $key => $dependency) {
  44810. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  44811. if (is_string($dependency)) {
  44812. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  44813. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  44814. }
  44815. } elseif (is_array($dependency)) {
  44816. foreach ($dependency as $d) {
  44817. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  44818. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  44819. }
  44820. }
  44821. } elseif (is_object($dependency)) {
  44822. $this->checkUndefined($value, $dependency, $path, $i);
  44823. }
  44824. }
  44825. }
  44826. }
  44827. protected function validateUri($schema, $schemaUri = null)
  44828. {
  44829. $resolver = new UriResolver();
  44830. $retriever = $this->factory->getUriRetriever();
  44831. $jsonSchema = null;
  44832. if ($resolver->isValid($schemaUri)) {
  44833. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  44834. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  44835. }
  44836. return $jsonSchema;
  44837. }
  44838. }
  44839. <?php
  44840. namespace JsonSchema\Entity;
  44841. use JsonSchema\Exception\InvalidArgumentException;
  44842. class JsonPointer
  44843. {
  44844. private $filename;
  44845. private $propertyPaths = array();
  44846. private $fromDefault = false;
  44847. public function __construct($value)
  44848. {
  44849. if (!is_string($value)) {
  44850. throw new InvalidArgumentException('Ref value must be a string');
  44851. }
  44852. $splitRef = explode('#', $value, 2);
  44853. $this->filename = $splitRef[0];
  44854. if (array_key_exists(1, $splitRef)) {
  44855. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  44856. }
  44857. }
  44858. private function decodePropertyPaths($propertyPathString)
  44859. {
  44860. $paths = array();
  44861. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  44862. $path = $this->decodePath($path);
  44863. if (is_string($path) && '' !== $path) {
  44864. $paths[] = $path;
  44865. }
  44866. }
  44867. return $paths;
  44868. }
  44869. private function encodePropertyPaths()
  44870. {
  44871. return array_map(
  44872. array($this, 'encodePath'),
  44873. $this->getPropertyPaths()
  44874. );
  44875. }
  44876. private function decodePath($path)
  44877. {
  44878. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  44879. }
  44880. private function encodePath($path)
  44881. {
  44882. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  44883. }
  44884. public function getFilename()
  44885. {
  44886. return $this->filename;
  44887. }
  44888. public function getPropertyPaths()
  44889. {
  44890. return $this->propertyPaths;
  44891. }
  44892. public function withPropertyPaths(array $propertyPaths)
  44893. {
  44894. $new = clone $this;
  44895. $new->propertyPaths = $propertyPaths;
  44896. return $new;
  44897. }
  44898. public function getPropertyPathAsString()
  44899. {
  44900. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  44901. }
  44902. public function __toString()
  44903. {
  44904. return $this->getFilename() . $this->getPropertyPathAsString();
  44905. }
  44906. public function setFromDefault()
  44907. {
  44908. $this->fromDefault = true;
  44909. }
  44910. public function fromDefault()
  44911. {
  44912. return $this->fromDefault;
  44913. }
  44914. }
  44915. <?php
  44916. namespace JsonSchema\Exception;
  44917. interface ExceptionInterface
  44918. {
  44919. }
  44920. <?php
  44921. namespace JsonSchema\Exception;
  44922. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  44923. {
  44924. }
  44925. <?php
  44926. namespace JsonSchema\Exception;
  44927. class InvalidConfigException extends RuntimeException
  44928. {
  44929. }
  44930. <?php
  44931. namespace JsonSchema\Exception;
  44932. class InvalidSchemaException extends RuntimeException
  44933. {
  44934. }
  44935. <?php
  44936. namespace JsonSchema\Exception;
  44937. class InvalidSchemaMediaTypeException extends RuntimeException
  44938. {
  44939. }
  44940. <?php
  44941. namespace JsonSchema\Exception;
  44942. class InvalidSourceUriException extends InvalidArgumentException
  44943. {
  44944. }
  44945. <?php
  44946. namespace JsonSchema\Exception;
  44947. class JsonDecodingException extends RuntimeException
  44948. {
  44949. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  44950. {
  44951. switch ($code) {
  44952. case JSON_ERROR_DEPTH:
  44953. $message = 'The maximum stack depth has been exceeded';
  44954. break;
  44955. case JSON_ERROR_STATE_MISMATCH:
  44956. $message = 'Invalid or malformed JSON';
  44957. break;
  44958. case JSON_ERROR_CTRL_CHAR:
  44959. $message = 'Control character error, possibly incorrectly encoded';
  44960. break;
  44961. case JSON_ERROR_UTF8:
  44962. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  44963. break;
  44964. case JSON_ERROR_SYNTAX:
  44965. $message = 'JSON syntax is malformed';
  44966. break;
  44967. default:
  44968. $message = 'Syntax error';
  44969. }
  44970. parent::__construct($message, $code, $previous);
  44971. }
  44972. }
  44973. <?php
  44974. namespace JsonSchema\Exception;
  44975. class ResourceNotFoundException extends RuntimeException
  44976. {
  44977. }
  44978. <?php
  44979. namespace JsonSchema\Exception;
  44980. class RuntimeException extends \RuntimeException implements ExceptionInterface
  44981. {
  44982. }
  44983. <?php
  44984. namespace JsonSchema\Exception;
  44985. class UnresolvableJsonPointerException extends InvalidArgumentException
  44986. {
  44987. }
  44988. <?php
  44989. namespace JsonSchema\Exception;
  44990. class UriResolverException extends RuntimeException
  44991. {
  44992. }
  44993. <?php
  44994. namespace JsonSchema\Exception;
  44995. class ValidationException extends RuntimeException
  44996. {
  44997. }
  44998. <?php
  44999. namespace JsonSchema\Iterator;
  45000. class ObjectIterator implements \Iterator, \Countable
  45001. {
  45002. private $object;
  45003. private $position = 0;
  45004. private $data = array();
  45005. private $initialized = false;
  45006. public function __construct($object)
  45007. {
  45008. $this->object = $object;
  45009. }
  45010. public function current()
  45011. {
  45012. $this->initialize();
  45013. return $this->data[$this->position];
  45014. }
  45015. public function next()
  45016. {
  45017. $this->initialize();
  45018. $this->position++;
  45019. }
  45020. public function key()
  45021. {
  45022. $this->initialize();
  45023. return $this->position;
  45024. }
  45025. public function valid()
  45026. {
  45027. $this->initialize();
  45028. return isset($this->data[$this->position]);
  45029. }
  45030. public function rewind()
  45031. {
  45032. $this->initialize();
  45033. $this->position = 0;
  45034. }
  45035. public function count()
  45036. {
  45037. $this->initialize();
  45038. return count($this->data);
  45039. }
  45040. private function initialize()
  45041. {
  45042. if (!$this->initialized) {
  45043. $this->data = $this->buildDataFromObject($this->object);
  45044. $this->initialized = true;
  45045. }
  45046. }
  45047. private function buildDataFromObject($object)
  45048. {
  45049. $result = array();
  45050. $stack = new \SplStack();
  45051. $stack->push($object);
  45052. while (!$stack->isEmpty()) {
  45053. $current = $stack->pop();
  45054. if (is_object($current)) {
  45055. array_push($result, $current);
  45056. }
  45057. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  45058. if (is_object($propertyValue) || is_array($propertyValue)) {
  45059. $stack->push($propertyValue);
  45060. }
  45061. }
  45062. }
  45063. return $result;
  45064. }
  45065. private function getDataFromItem($item)
  45066. {
  45067. if (!is_object($item) && !is_array($item)) {
  45068. return array();
  45069. }
  45070. return is_object($item) ? get_object_vars($item) : $item;
  45071. }
  45072. }
  45073. <?php
  45074. namespace JsonSchema;
  45075. class Rfc3339
  45076. {
  45077. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  45078. public static function createFromString($string)
  45079. {
  45080. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  45081. return null;
  45082. }
  45083. $dateAndTime = $matches[1];
  45084. $microseconds = $matches[2] ?: '.000000';
  45085. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  45086. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  45087. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  45088. return $dateTime ?: null;
  45089. }
  45090. }
  45091. <?php
  45092. namespace JsonSchema;
  45093. use JsonSchema\Constraints\BaseConstraint;
  45094. use JsonSchema\Entity\JsonPointer;
  45095. use JsonSchema\Exception\UnresolvableJsonPointerException;
  45096. use JsonSchema\Uri\UriResolver;
  45097. use JsonSchema\Uri\UriRetriever;
  45098. class SchemaStorage implements SchemaStorageInterface
  45099. {
  45100. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  45101. protected $uriRetriever;
  45102. protected $uriResolver;
  45103. protected $schemas = array();
  45104. public function __construct(
  45105. UriRetrieverInterface $uriRetriever = null,
  45106. UriResolverInterface $uriResolver = null
  45107. ) {
  45108. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  45109. $this->uriResolver = $uriResolver ?: new UriResolver();
  45110. }
  45111. public function getUriRetriever()
  45112. {
  45113. return $this->uriRetriever;
  45114. }
  45115. public function getUriResolver()
  45116. {
  45117. return $this->uriResolver;
  45118. }
  45119. public function addSchema($id, $schema = null)
  45120. {
  45121. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  45122. $schema = $this->uriRetriever->retrieve($id);
  45123. }
  45124. if (is_array($schema)) {
  45125. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  45126. }
  45127. if (is_object($schema) && property_exists($schema, 'id')) {
  45128. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  45129. $schema->properties->id->format = 'uri-reference';
  45130. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  45131. $schema->properties->id->format = 'uri-reference';
  45132. $schema->properties->{'$ref'}->format = 'uri-reference';
  45133. }
  45134. }
  45135. $this->expandRefs($schema, $id);
  45136. $this->schemas[$id] = $schema;
  45137. }
  45138. private function expandRefs(&$schema, $base = null)
  45139. {
  45140. if (!is_object($schema)) {
  45141. if (is_array($schema)) {
  45142. foreach ($schema as &$member) {
  45143. $this->expandRefs($member, $base);
  45144. }
  45145. }
  45146. return;
  45147. }
  45148. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  45149. $base = $this->uriResolver->resolve($schema->id, $base);
  45150. }
  45151. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  45152. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  45153. $schema->{'$ref'} = (string) $refPointer;
  45154. }
  45155. foreach ($schema as &$member) {
  45156. $this->expandRefs($member, $base);
  45157. }
  45158. }
  45159. public function getSchema($id)
  45160. {
  45161. if (!array_key_exists($id, $this->schemas)) {
  45162. $this->addSchema($id);
  45163. }
  45164. return $this->schemas[$id];
  45165. }
  45166. public function resolveRef($ref)
  45167. {
  45168. $jsonPointer = new JsonPointer($ref);
  45169. $fileName = $jsonPointer->getFilename();
  45170. if (!strlen($fileName)) {
  45171. throw new UnresolvableJsonPointerException(sprintf(
  45172. "Could not resolve fragment '%s': no file is defined",
  45173. $jsonPointer->getPropertyPathAsString()
  45174. ));
  45175. }
  45176. $refSchema = $this->getSchema($fileName);
  45177. foreach ($jsonPointer->getPropertyPaths() as $path) {
  45178. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  45179. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  45180. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  45181. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  45182. } else {
  45183. throw new UnresolvableJsonPointerException(sprintf(
  45184. 'File: %s is found, but could not resolve fragment: %s',
  45185. $jsonPointer->getFilename(),
  45186. $jsonPointer->getPropertyPathAsString()
  45187. ));
  45188. }
  45189. }
  45190. return $refSchema;
  45191. }
  45192. public function resolveRefSchema($refSchema)
  45193. {
  45194. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  45195. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  45196. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  45197. unset($refSchema->{'$ref'});
  45198. }
  45199. return $refSchema;
  45200. }
  45201. }
  45202. <?php
  45203. namespace JsonSchema;
  45204. interface SchemaStorageInterface
  45205. {
  45206. public function addSchema($id, $schema = null);
  45207. public function getSchema($id);
  45208. public function resolveRef($ref);
  45209. public function resolveRefSchema($refSchema);
  45210. }
  45211. <?php
  45212. namespace JsonSchema\Uri\Retrievers;
  45213. abstract class AbstractRetriever implements UriRetrieverInterface
  45214. {
  45215. protected $contentType;
  45216. public function getContentType()
  45217. {
  45218. return $this->contentType;
  45219. }
  45220. }
  45221. <?php
  45222. namespace JsonSchema\Uri\Retrievers;
  45223. use JsonSchema\Exception\RuntimeException;
  45224. use JsonSchema\Validator;
  45225. class Curl extends AbstractRetriever
  45226. {
  45227. protected $messageBody;
  45228. public function __construct()
  45229. {
  45230. if (!function_exists('curl_init')) {
  45231. throw new RuntimeException('cURL not installed');
  45232. }
  45233. }
  45234. public function retrieve($uri)
  45235. {
  45236. $ch = curl_init();
  45237. curl_setopt($ch, CURLOPT_URL, $uri);
  45238. curl_setopt($ch, CURLOPT_HEADER, true);
  45239. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  45240. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  45241. $response = curl_exec($ch);
  45242. if (false === $response) {
  45243. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  45244. }
  45245. $this->fetchMessageBody($response);
  45246. $this->fetchContentType($response);
  45247. curl_close($ch);
  45248. return $this->messageBody;
  45249. }
  45250. private function fetchMessageBody($response)
  45251. {
  45252. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  45253. $this->messageBody = $match[1];
  45254. }
  45255. protected function fetchContentType($response)
  45256. {
  45257. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  45258. $this->contentType = trim($match[1]);
  45259. return true;
  45260. }
  45261. return false;
  45262. }
  45263. }
  45264. <?php
  45265. namespace JsonSchema\Uri\Retrievers;
  45266. use JsonSchema\Exception\ResourceNotFoundException;
  45267. class FileGetContents extends AbstractRetriever
  45268. {
  45269. protected $messageBody;
  45270. public function retrieve($uri)
  45271. {
  45272. $errorMessage = null;
  45273. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  45274. $errorMessage = $errstr;
  45275. });
  45276. $response = file_get_contents($uri);
  45277. restore_error_handler();
  45278. if ($errorMessage) {
  45279. throw new ResourceNotFoundException($errorMessage);
  45280. }
  45281. if (false === $response) {
  45282. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45283. }
  45284. if ($response == ''
  45285. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  45286. ) {
  45287. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45288. }
  45289. $this->messageBody = $response;
  45290. if (!empty($http_response_header)) {
  45291. $this->fetchContentType($http_response_header);
  45292. } else {
  45293. $this->contentType = null;
  45294. }
  45295. return $this->messageBody;
  45296. }
  45297. private function fetchContentType(array $headers)
  45298. {
  45299. foreach ($headers as $header) {
  45300. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  45301. return true;
  45302. }
  45303. }
  45304. return false;
  45305. }
  45306. protected static function getContentTypeMatchInHeader($header)
  45307. {
  45308. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  45309. return trim($match[1]);
  45310. }
  45311. return null;
  45312. }
  45313. }
  45314. <?php
  45315. namespace JsonSchema\Uri\Retrievers;
  45316. use JsonSchema\Validator;
  45317. class PredefinedArray extends AbstractRetriever
  45318. {
  45319. private $schemas;
  45320. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  45321. {
  45322. $this->schemas = $schemas;
  45323. $this->contentType = $contentType;
  45324. }
  45325. public function retrieve($uri)
  45326. {
  45327. if (!array_key_exists($uri, $this->schemas)) {
  45328. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  45329. 'The JSON schema "%s" was not found.',
  45330. $uri
  45331. ));
  45332. }
  45333. return $this->schemas[$uri];
  45334. }
  45335. }
  45336. <?php
  45337. namespace JsonSchema\Uri\Retrievers;
  45338. interface UriRetrieverInterface
  45339. {
  45340. public function retrieve($uri);
  45341. public function getContentType();
  45342. }
  45343. <?php
  45344. namespace JsonSchema\Uri;
  45345. use JsonSchema\Exception\UriResolverException;
  45346. use JsonSchema\UriResolverInterface;
  45347. class UriResolver implements UriResolverInterface
  45348. {
  45349. public function parse($uri)
  45350. {
  45351. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  45352. $components = array();
  45353. if (5 < count($match)) {
  45354. $components = array(
  45355. 'scheme' => $match[2],
  45356. 'authority' => $match[4],
  45357. 'path' => $match[5]
  45358. );
  45359. }
  45360. if (7 < count($match)) {
  45361. $components['query'] = $match[7];
  45362. }
  45363. if (9 < count($match)) {
  45364. $components['fragment'] = $match[9];
  45365. }
  45366. return $components;
  45367. }
  45368. public function generate(array $components)
  45369. {
  45370. $uri = $components['scheme'] . '://'
  45371. . $components['authority']
  45372. . $components['path'];
  45373. if (array_key_exists('query', $components) && strlen($components['query'])) {
  45374. $uri .= '?' . $components['query'];
  45375. }
  45376. if (array_key_exists('fragment', $components)) {
  45377. $uri .= '#' . $components['fragment'];
  45378. }
  45379. return $uri;
  45380. }
  45381. public function resolve($uri, $baseUri = null)
  45382. {
  45383. if (
  45384. !is_null($baseUri) &&
  45385. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  45386. !preg_match('|^[^/]+://|u', $baseUri)
  45387. ) {
  45388. if (is_file($baseUri)) {
  45389. $baseUri = 'file://' . realpath($baseUri);
  45390. } elseif (is_dir($baseUri)) {
  45391. $baseUri = 'file://' . realpath($baseUri) . '/';
  45392. } else {
  45393. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  45394. }
  45395. }
  45396. if ($uri == '') {
  45397. return $baseUri;
  45398. }
  45399. $components = $this->parse($uri);
  45400. $path = $components['path'];
  45401. if (!empty($components['scheme'])) {
  45402. return $uri;
  45403. }
  45404. $baseComponents = $this->parse($baseUri);
  45405. $basePath = $baseComponents['path'];
  45406. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  45407. if (isset($components['fragment'])) {
  45408. $baseComponents['fragment'] = $components['fragment'];
  45409. }
  45410. return $this->generate($baseComponents);
  45411. }
  45412. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  45413. {
  45414. $relativePath = self::normalizePath($relativePath);
  45415. if ($relativePath == '') {
  45416. return $basePath;
  45417. }
  45418. if ($relativePath[0] == '/') {
  45419. return $relativePath;
  45420. }
  45421. $basePathSegments = explode('/', $basePath);
  45422. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  45423. $numLevelUp = strlen($match[0]) /3 + 1;
  45424. if ($numLevelUp >= count($basePathSegments)) {
  45425. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  45426. }
  45427. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  45428. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  45429. return implode('/', $basePathSegments) . '/' . $path;
  45430. }
  45431. private static function normalizePath($path)
  45432. {
  45433. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  45434. $path = preg_replace('|//|', '/', $path);
  45435. return $path;
  45436. }
  45437. public function isValid($uri)
  45438. {
  45439. $components = $this->parse($uri);
  45440. return !empty($components);
  45441. }
  45442. }
  45443. <?php
  45444. namespace JsonSchema\Uri;
  45445. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  45446. use JsonSchema\Exception\JsonDecodingException;
  45447. use JsonSchema\Exception\ResourceNotFoundException;
  45448. use JsonSchema\Uri\Retrievers\FileGetContents;
  45449. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  45450. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  45451. use JsonSchema\Validator;
  45452. class UriRetriever implements BaseUriRetrieverInterface
  45453. {
  45454. protected $translationMap = array(
  45455. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  45456. );
  45457. protected $allowedInvalidContentTypeEndpoints = array(
  45458. 'http://json-schema.org/',
  45459. 'https://json-schema.org/'
  45460. );
  45461. protected $uriRetriever = null;
  45462. private $schemaCache = array();
  45463. public function addInvalidContentTypeEndpoint($endpoint)
  45464. {
  45465. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  45466. }
  45467. public function confirmMediaType($uriRetriever, $uri)
  45468. {
  45469. $contentType = $uriRetriever->getContentType();
  45470. if (is_null($contentType)) {
  45471. return;
  45472. }
  45473. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  45474. return;
  45475. }
  45476. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  45477. if (strpos($uri, $endpoint) === 0) {
  45478. return true;
  45479. }
  45480. }
  45481. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  45482. }
  45483. public function getUriRetriever()
  45484. {
  45485. if (is_null($this->uriRetriever)) {
  45486. $this->setUriRetriever(new FileGetContents());
  45487. }
  45488. return $this->uriRetriever;
  45489. }
  45490. public function resolvePointer($jsonSchema, $uri)
  45491. {
  45492. $resolver = new UriResolver();
  45493. $parsed = $resolver->parse($uri);
  45494. if (empty($parsed['fragment'])) {
  45495. return $jsonSchema;
  45496. }
  45497. $path = explode('/', $parsed['fragment']);
  45498. while ($path) {
  45499. $pathElement = array_shift($path);
  45500. if (!empty($pathElement)) {
  45501. $pathElement = str_replace('~1', '/', $pathElement);
  45502. $pathElement = str_replace('~0', '~', $pathElement);
  45503. if (!empty($jsonSchema->$pathElement)) {
  45504. $jsonSchema = $jsonSchema->$pathElement;
  45505. } else {
  45506. throw new ResourceNotFoundException(
  45507. 'Fragment "' . $parsed['fragment'] . '" not found'
  45508. . ' in ' . $uri
  45509. );
  45510. }
  45511. if (!is_object($jsonSchema)) {
  45512. throw new ResourceNotFoundException(
  45513. 'Fragment part "' . $pathElement . '" is no object '
  45514. . ' in ' . $uri
  45515. );
  45516. }
  45517. }
  45518. }
  45519. return $jsonSchema;
  45520. }
  45521. public function retrieve($uri, $baseUri = null, $translate = true)
  45522. {
  45523. $resolver = new UriResolver();
  45524. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  45525. $arParts = $resolver->parse($resolvedUri);
  45526. if (isset($arParts['fragment'])) {
  45527. unset($arParts['fragment']);
  45528. $fetchUri = $resolver->generate($arParts);
  45529. }
  45530. if ($translate) {
  45531. $fetchUri = $this->translate($fetchUri);
  45532. }
  45533. $jsonSchema = $this->loadSchema($fetchUri);
  45534. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  45535. if ($jsonSchema instanceof \stdClass) {
  45536. $jsonSchema->id = $resolvedUri;
  45537. }
  45538. return $jsonSchema;
  45539. }
  45540. protected function loadSchema($fetchUri)
  45541. {
  45542. if (isset($this->schemaCache[$fetchUri])) {
  45543. return $this->schemaCache[$fetchUri];
  45544. }
  45545. $uriRetriever = $this->getUriRetriever();
  45546. $contents = $this->uriRetriever->retrieve($fetchUri);
  45547. $this->confirmMediaType($uriRetriever, $fetchUri);
  45548. $jsonSchema = json_decode($contents);
  45549. if (JSON_ERROR_NONE < $error = json_last_error()) {
  45550. throw new JsonDecodingException($error);
  45551. }
  45552. $this->schemaCache[$fetchUri] = $jsonSchema;
  45553. return $jsonSchema;
  45554. }
  45555. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  45556. {
  45557. $this->uriRetriever = $uriRetriever;
  45558. return $this;
  45559. }
  45560. public function parse($uri)
  45561. {
  45562. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  45563. $components = array();
  45564. if (5 < count($match)) {
  45565. $components = array(
  45566. 'scheme' => $match[2],
  45567. 'authority' => $match[4],
  45568. 'path' => $match[5]
  45569. );
  45570. }
  45571. if (7 < count($match)) {
  45572. $components['query'] = $match[7];
  45573. }
  45574. if (9 < count($match)) {
  45575. $components['fragment'] = $match[9];
  45576. }
  45577. return $components;
  45578. }
  45579. public function generate(array $components)
  45580. {
  45581. $uri = $components['scheme'] . '://'
  45582. . $components['authority']
  45583. . $components['path'];
  45584. if (array_key_exists('query', $components)) {
  45585. $uri .= $components['query'];
  45586. }
  45587. if (array_key_exists('fragment', $components)) {
  45588. $uri .= $components['fragment'];
  45589. }
  45590. return $uri;
  45591. }
  45592. public function resolve($uri, $baseUri = null)
  45593. {
  45594. $components = $this->parse($uri);
  45595. $path = $components['path'];
  45596. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  45597. return $uri;
  45598. }
  45599. $baseComponents = $this->parse($baseUri);
  45600. $basePath = $baseComponents['path'];
  45601. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  45602. return $this->generate($baseComponents);
  45603. }
  45604. public function isValid($uri)
  45605. {
  45606. $components = $this->parse($uri);
  45607. return !empty($components);
  45608. }
  45609. public function setTranslation($from, $to)
  45610. {
  45611. $this->translationMap[$from] = $to;
  45612. }
  45613. public function translate($uri)
  45614. {
  45615. foreach ($this->translationMap as $from => $to) {
  45616. $uri = preg_replace($from, $to, $uri);
  45617. }
  45618. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  45619. return $uri;
  45620. }
  45621. }
  45622. <?php
  45623. namespace JsonSchema;
  45624. interface UriResolverInterface
  45625. {
  45626. public function resolve($uri, $baseUri = null);
  45627. }
  45628. <?php
  45629. namespace JsonSchema;
  45630. interface UriRetrieverInterface
  45631. {
  45632. public function retrieve($uri, $baseUri = null);
  45633. }
  45634. <?php
  45635. namespace JsonSchema;
  45636. use JsonSchema\Constraints\BaseConstraint;
  45637. use JsonSchema\Constraints\Constraint;
  45638. class Validator extends BaseConstraint
  45639. {
  45640. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  45641. const ERROR_NONE = 0x00000000;
  45642. const ERROR_ALL = 0xFFFFFFFF;
  45643. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  45644. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  45645. public function validate(&$value, $schema = null, $checkMode = null)
  45646. {
  45647. if (is_array($schema)) {
  45648. $schema = self::arrayToObjectRecursive($schema);
  45649. }
  45650. $initialCheckMode = $this->factory->getConfig();
  45651. if ($checkMode !== null) {
  45652. $this->factory->setConfig($checkMode);
  45653. }
  45654. if (is_object($schema) && property_exists($schema, 'id')) {
  45655. $schemaURI = $schema->id;
  45656. } else {
  45657. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  45658. }
  45659. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  45660. $validator = $this->factory->createInstanceFor('schema');
  45661. $validator->check(
  45662. $value,
  45663. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  45664. );
  45665. $this->factory->setConfig($initialCheckMode);
  45666. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  45667. return $validator->getErrorMask();
  45668. }
  45669. public function check($value, $schema)
  45670. {
  45671. return $this->validate($value, $schema);
  45672. }
  45673. public function coerce(&$value, $schema)
  45674. {
  45675. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  45676. }
  45677. }
  45678. Copyright (c) 2012 PHP Framework Interoperability Group
  45679. Permission is hereby granted, free of charge, to any person obtaining a copy
  45680. of this software and associated documentation files (the "Software"), to deal
  45681. in the Software without restriction, including without limitation the rights
  45682. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  45683. copies of the Software, and to permit persons to whom the Software is
  45684. furnished to do so, subject to the following conditions:
  45685. The above copyright notice and this permission notice shall be included in
  45686. all copies or substantial portions of the Software.
  45687. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45688. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  45689. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  45690. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  45691. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  45692. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  45693. THE SOFTWARE.
  45694. <?php
  45695. namespace Psr\Log;
  45696. abstract class AbstractLogger implements LoggerInterface
  45697. {
  45698. public function emergency($message, array $context = array())
  45699. {
  45700. $this->log(LogLevel::EMERGENCY, $message, $context);
  45701. }
  45702. public function alert($message, array $context = array())
  45703. {
  45704. $this->log(LogLevel::ALERT, $message, $context);
  45705. }
  45706. public function critical($message, array $context = array())
  45707. {
  45708. $this->log(LogLevel::CRITICAL, $message, $context);
  45709. }
  45710. public function error($message, array $context = array())
  45711. {
  45712. $this->log(LogLevel::ERROR, $message, $context);
  45713. }
  45714. public function warning($message, array $context = array())
  45715. {
  45716. $this->log(LogLevel::WARNING, $message, $context);
  45717. }
  45718. public function notice($message, array $context = array())
  45719. {
  45720. $this->log(LogLevel::NOTICE, $message, $context);
  45721. }
  45722. public function info($message, array $context = array())
  45723. {
  45724. $this->log(LogLevel::INFO, $message, $context);
  45725. }
  45726. public function debug($message, array $context = array())
  45727. {
  45728. $this->log(LogLevel::DEBUG, $message, $context);
  45729. }
  45730. }
  45731. <?php
  45732. namespace Psr\Log;
  45733. class InvalidArgumentException extends \InvalidArgumentException
  45734. {
  45735. }
  45736. <?php
  45737. namespace Psr\Log;
  45738. class LogLevel
  45739. {
  45740. const EMERGENCY = 'emergency';
  45741. const ALERT = 'alert';
  45742. const CRITICAL = 'critical';
  45743. const ERROR = 'error';
  45744. const WARNING = 'warning';
  45745. const NOTICE = 'notice';
  45746. const INFO = 'info';
  45747. const DEBUG = 'debug';
  45748. }
  45749. <?php
  45750. namespace Psr\Log;
  45751. interface LoggerAwareInterface
  45752. {
  45753. public function setLogger(LoggerInterface $logger);
  45754. }
  45755. <?php
  45756. namespace Psr\Log;
  45757. trait LoggerAwareTrait
  45758. {
  45759. protected $logger;
  45760. public function setLogger(LoggerInterface $logger)
  45761. {
  45762. $this->logger = $logger;
  45763. }
  45764. }
  45765. <?php
  45766. namespace Psr\Log;
  45767. interface LoggerInterface
  45768. {
  45769. public function emergency($message, array $context = array());
  45770. public function alert($message, array $context = array());
  45771. public function critical($message, array $context = array());
  45772. public function error($message, array $context = array());
  45773. public function warning($message, array $context = array());
  45774. public function notice($message, array $context = array());
  45775. public function info($message, array $context = array());
  45776. public function debug($message, array $context = array());
  45777. public function log($level, $message, array $context = array());
  45778. }
  45779. <?php
  45780. namespace Psr\Log;
  45781. trait LoggerTrait
  45782. {
  45783. public function emergency($message, array $context = array())
  45784. {
  45785. $this->log(LogLevel::EMERGENCY, $message, $context);
  45786. }
  45787. public function alert($message, array $context = array())
  45788. {
  45789. $this->log(LogLevel::ALERT, $message, $context);
  45790. }
  45791. public function critical($message, array $context = array())
  45792. {
  45793. $this->log(LogLevel::CRITICAL, $message, $context);
  45794. }
  45795. public function error($message, array $context = array())
  45796. {
  45797. $this->log(LogLevel::ERROR, $message, $context);
  45798. }
  45799. public function warning($message, array $context = array())
  45800. {
  45801. $this->log(LogLevel::WARNING, $message, $context);
  45802. }
  45803. public function notice($message, array $context = array())
  45804. {
  45805. $this->log(LogLevel::NOTICE, $message, $context);
  45806. }
  45807. public function info($message, array $context = array())
  45808. {
  45809. $this->log(LogLevel::INFO, $message, $context);
  45810. }
  45811. public function debug($message, array $context = array())
  45812. {
  45813. $this->log(LogLevel::DEBUG, $message, $context);
  45814. }
  45815. abstract public function log($level, $message, array $context = array());
  45816. }
  45817. <?php
  45818. namespace Psr\Log;
  45819. class NullLogger extends AbstractLogger
  45820. {
  45821. public function log($level, $message, array $context = array())
  45822. {
  45823. }
  45824. }
  45825. <?php
  45826. namespace Psr\Log\Test;
  45827. class DummyTest
  45828. {
  45829. public function __toString()
  45830. {
  45831. return 'DummyTest';
  45832. }
  45833. }
  45834. <?php
  45835. namespace Psr\Log\Test;
  45836. use Psr\Log\LoggerInterface;
  45837. use Psr\Log\LogLevel;
  45838. use PHPUnit\Framework\TestCase;
  45839. abstract class LoggerInterfaceTest extends TestCase
  45840. {
  45841. abstract public function getLogger();
  45842. abstract public function getLogs();
  45843. public function testImplements()
  45844. {
  45845. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  45846. }
  45847. public function testLogsAtAllLevels($level, $message)
  45848. {
  45849. $logger = $this->getLogger();
  45850. $logger->{$level}($message, array('user' => 'Bob'));
  45851. $logger->log($level, $message, array('user' => 'Bob'));
  45852. $expected = array(
  45853. $level.' message of level '.$level.' with context: Bob',
  45854. $level.' message of level '.$level.' with context: Bob',
  45855. );
  45856. $this->assertEquals($expected, $this->getLogs());
  45857. }
  45858. public function provideLevelsAndMessages()
  45859. {
  45860. return array(
  45861. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  45862. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  45863. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  45864. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  45865. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  45866. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  45867. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  45868. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  45869. );
  45870. }
  45871. public function testThrowsOnInvalidLevel()
  45872. {
  45873. $logger = $this->getLogger();
  45874. $logger->log('invalid level', 'Foo');
  45875. }
  45876. public function testContextReplacement()
  45877. {
  45878. $logger = $this->getLogger();
  45879. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  45880. $expected = array('info {Message {nothing} Bob Bar a}');
  45881. $this->assertEquals($expected, $this->getLogs());
  45882. }
  45883. public function testObjectCastToString()
  45884. {
  45885. if (method_exists($this, 'createPartialMock')) {
  45886. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  45887. } else {
  45888. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  45889. }
  45890. $dummy->expects($this->once())
  45891. ->method('__toString')
  45892. ->will($this->returnValue('DUMMY'));
  45893. $this->getLogger()->warning($dummy);
  45894. $expected = array('warning DUMMY');
  45895. $this->assertEquals($expected, $this->getLogs());
  45896. }
  45897. public function testContextCanContainAnything()
  45898. {
  45899. $closed = fopen('php://memory', 'r');
  45900. fclose($closed);
  45901. $context = array(
  45902. 'bool' => true,
  45903. 'null' => null,
  45904. 'string' => 'Foo',
  45905. 'int' => 0,
  45906. 'float' => 0.5,
  45907. 'nested' => array('with object' => new DummyTest),
  45908. 'object' => new \DateTime,
  45909. 'resource' => fopen('php://memory', 'r'),
  45910. 'closed' => $closed,
  45911. );
  45912. $this->getLogger()->warning('Crazy context data', $context);
  45913. $expected = array('warning Crazy context data');
  45914. $this->assertEquals($expected, $this->getLogs());
  45915. }
  45916. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  45917. {
  45918. $logger = $this->getLogger();
  45919. $logger->warning('Random message', array('exception' => 'oops'));
  45920. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  45921. $expected = array(
  45922. 'warning Random message',
  45923. 'critical Uncaught Exception!'
  45924. );
  45925. $this->assertEquals($expected, $this->getLogs());
  45926. }
  45927. }
  45928. <?php
  45929. namespace Psr\Log\Test;
  45930. use Psr\Log\AbstractLogger;
  45931. class TestLogger extends AbstractLogger
  45932. {
  45933. public $records = [];
  45934. public $recordsByLevel = [];
  45935. public function log($level, $message, array $context = [])
  45936. {
  45937. $record = [
  45938. 'level' => $level,
  45939. 'message' => $message,
  45940. 'context' => $context,
  45941. ];
  45942. $this->recordsByLevel[$record['level']][] = $record;
  45943. $this->records[] = $record;
  45944. }
  45945. public function hasRecords($level)
  45946. {
  45947. return isset($this->recordsByLevel[$level]);
  45948. }
  45949. public function hasRecord($record, $level)
  45950. {
  45951. if (is_string($record)) {
  45952. $record = ['message' => $record];
  45953. }
  45954. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  45955. if ($rec['message'] !== $record['message']) {
  45956. return false;
  45957. }
  45958. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  45959. return false;
  45960. }
  45961. return true;
  45962. }, $level);
  45963. }
  45964. public function hasRecordThatContains($message, $level)
  45965. {
  45966. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  45967. return strpos($rec['message'], $message) !== false;
  45968. }, $level);
  45969. }
  45970. public function hasRecordThatMatches($regex, $level)
  45971. {
  45972. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  45973. return preg_match($regex, $rec['message']) > 0;
  45974. }, $level);
  45975. }
  45976. public function hasRecordThatPasses(callable $predicate, $level)
  45977. {
  45978. if (!isset($this->recordsByLevel[$level])) {
  45979. return false;
  45980. }
  45981. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  45982. if (call_user_func($predicate, $rec, $i)) {
  45983. return true;
  45984. }
  45985. }
  45986. return false;
  45987. }
  45988. public function __call($method, $args)
  45989. {
  45990. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  45991. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  45992. $level = strtolower($matches[2]);
  45993. if (method_exists($this, $genericMethod)) {
  45994. $args[] = $level;
  45995. return call_user_func_array([$this, $genericMethod], $args);
  45996. }
  45997. }
  45998. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  45999. }
  46000. public function reset()
  46001. {
  46002. $this->records = [];
  46003. $this->recordsByLevel = [];
  46004. }
  46005. }
  46006. Copyright (c) 2012-2016 Jan Sorgalla
  46007. Permission is hereby granted, free of charge, to any person
  46008. obtaining a copy of this software and associated documentation
  46009. files (the "Software"), to deal in the Software without
  46010. restriction, including without limitation the rights to use,
  46011. copy, modify, merge, publish, distribute, sublicense, and/or sell
  46012. copies of the Software, and to permit persons to whom the
  46013. Software is furnished to do so, subject to the following
  46014. conditions:
  46015. The above copyright notice and this permission notice shall be
  46016. included in all copies or substantial portions of the Software.
  46017. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  46018. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  46019. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  46020. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  46021. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  46022. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  46023. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  46024. OTHER DEALINGS IN THE SOFTWARE.
  46025. <?php
  46026. namespace React\Promise;
  46027. interface CancellablePromiseInterface extends PromiseInterface
  46028. {
  46029. public function cancel();
  46030. }
  46031. <?php
  46032. namespace React\Promise;
  46033. class Deferred implements PromiseInterface, ResolverInterface, PromisorInterface, CancellablePromiseInterface
  46034. {
  46035. private $completed;
  46036. private $promise;
  46037. private $resolver;
  46038. private $handlers = array();
  46039. private $progressHandlers = array();
  46040. private $canceller;
  46041. private $requiredCancelRequests = 0;
  46042. private $cancelRequests = 0;
  46043. public function __construct($canceller = null)
  46044. {
  46045. if ($canceller !== null && !is_callable($canceller)) {
  46046. throw new \InvalidArgumentException(
  46047. sprintf(
  46048. 'The canceller argument must be null or of type callable, %s given.',
  46049. gettype($canceller)
  46050. )
  46051. );
  46052. }
  46053. $this->canceller = $canceller;
  46054. }
  46055. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46056. {
  46057. if (null !== $this->completed) {
  46058. return $this->completed->then($fulfilledHandler, $errorHandler, $progressHandler);
  46059. }
  46060. $canceller = null;
  46061. if ($this->canceller !== null) {
  46062. $this->requiredCancelRequests++;
  46063. $that = $this;
  46064. $current =& $this->cancelRequests;
  46065. $required =& $this->requiredCancelRequests;
  46066. $canceller = function () use ($that, &$current, &$required) {
  46067. if (++$current < $required) {
  46068. return;
  46069. }
  46070. $that->cancel();
  46071. };
  46072. }
  46073. $deferred = new static($canceller);
  46074. if (is_callable($progressHandler)) {
  46075. $progHandler = function ($update) use ($deferred, $progressHandler) {
  46076. try {
  46077. $deferred->progress(call_user_func($progressHandler, $update));
  46078. } catch (\Exception $e) {
  46079. $deferred->progress($e);
  46080. }
  46081. };
  46082. } else {
  46083. if (null !== $progressHandler) {
  46084. trigger_error('Invalid $progressHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46085. }
  46086. $progHandler = array($deferred, 'progress');
  46087. }
  46088. $this->handlers[] = function ($promise) use ($fulfilledHandler, $errorHandler, $deferred, $progHandler) {
  46089. $promise
  46090. ->then($fulfilledHandler, $errorHandler)
  46091. ->then(
  46092. array($deferred, 'resolve'),
  46093. array($deferred, 'reject'),
  46094. $progHandler
  46095. );
  46096. };
  46097. $this->progressHandlers[] = $progHandler;
  46098. return $deferred->promise();
  46099. }
  46100. public function resolve($result = null)
  46101. {
  46102. if (null !== $this->completed) {
  46103. return resolve($result);
  46104. }
  46105. $this->completed = resolve($result);
  46106. $this->processQueue($this->handlers, $this->completed);
  46107. $this->progressHandlers = $this->handlers = array();
  46108. return $this->completed;
  46109. }
  46110. public function reject($reason = null)
  46111. {
  46112. return $this->resolve(reject($reason));
  46113. }
  46114. public function progress($update = null)
  46115. {
  46116. if (null !== $this->completed) {
  46117. return;
  46118. }
  46119. $this->processQueue($this->progressHandlers, $update);
  46120. }
  46121. public function promise()
  46122. {
  46123. if (null === $this->promise) {
  46124. $this->promise = new DeferredPromise($this);
  46125. }
  46126. return $this->promise;
  46127. }
  46128. public function resolver()
  46129. {
  46130. if (null === $this->resolver) {
  46131. $this->resolver = new DeferredResolver($this);
  46132. }
  46133. return $this->resolver;
  46134. }
  46135. public function cancel()
  46136. {
  46137. if (null === $this->canceller || null !== $this->completed) {
  46138. return;
  46139. }
  46140. $canceller = $this->canceller;
  46141. $this->canceller = null;
  46142. try {
  46143. $that = $this;
  46144. call_user_func(
  46145. $canceller,
  46146. function ($value = null) use ($that) {
  46147. $that->resolve($value);
  46148. },
  46149. function ($reason = null) use ($that) {
  46150. $that->reject($reason);
  46151. },
  46152. function ($update = null) use ($that) {
  46153. $that->progress($update);
  46154. }
  46155. );
  46156. } catch (\Exception $e) {
  46157. $this->reject($e);
  46158. }
  46159. }
  46160. protected function processQueue($queue, $value)
  46161. {
  46162. foreach ($queue as $handler) {
  46163. call_user_func($handler, $value);
  46164. }
  46165. }
  46166. }
  46167. <?php
  46168. namespace React\Promise;
  46169. class DeferredPromise implements PromiseInterface, CancellablePromiseInterface
  46170. {
  46171. private $deferred;
  46172. public function __construct(Deferred $deferred)
  46173. {
  46174. $this->deferred = $deferred;
  46175. }
  46176. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46177. {
  46178. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46179. }
  46180. public function cancel()
  46181. {
  46182. $this->deferred->cancel();
  46183. }
  46184. }
  46185. <?php
  46186. namespace React\Promise;
  46187. class DeferredResolver implements ResolverInterface
  46188. {
  46189. private $deferred;
  46190. public function __construct(Deferred $deferred)
  46191. {
  46192. $this->deferred = $deferred;
  46193. }
  46194. public function resolve($result = null)
  46195. {
  46196. return $this->deferred->resolve($result);
  46197. }
  46198. public function reject($reason = null)
  46199. {
  46200. return $this->deferred->reject($reason);
  46201. }
  46202. public function progress($update = null)
  46203. {
  46204. return $this->deferred->progress($update);
  46205. }
  46206. }
  46207. <?php
  46208. namespace React\Promise;
  46209. class FulfilledPromise implements PromiseInterface, CancellablePromiseInterface
  46210. {
  46211. private $result;
  46212. public function __construct($result = null)
  46213. {
  46214. $this->result = $result;
  46215. }
  46216. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46217. {
  46218. try {
  46219. $result = $this->result;
  46220. if (is_callable($fulfilledHandler)) {
  46221. $result = call_user_func($fulfilledHandler, $result);
  46222. } elseif (null !== $fulfilledHandler) {
  46223. trigger_error('Invalid $fulfilledHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46224. }
  46225. return resolve($result);
  46226. } catch (\Exception $exception) {
  46227. return new RejectedPromise($exception);
  46228. }
  46229. }
  46230. public function cancel()
  46231. {
  46232. }
  46233. }
  46234. <?php
  46235. namespace React\Promise;
  46236. class LazyPromise implements PromiseInterface, CancellablePromiseInterface
  46237. {
  46238. private $factory;
  46239. private $promise;
  46240. public function __construct($factory)
  46241. {
  46242. $this->factory = $factory;
  46243. }
  46244. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46245. {
  46246. return $this->promise()->then($fulfilledHandler, $errorHandler, $progressHandler);
  46247. }
  46248. public function cancel()
  46249. {
  46250. $promise = $this->promise();
  46251. if ($promise instanceof CancellablePromiseInterface) {
  46252. $promise->cancel();
  46253. }
  46254. }
  46255. private function promise()
  46256. {
  46257. if (null === $this->promise) {
  46258. try {
  46259. $this->promise = resolve(call_user_func($this->factory));
  46260. } catch (\Exception $exception) {
  46261. $this->promise = new RejectedPromise($exception);
  46262. }
  46263. }
  46264. return $this->promise;
  46265. }
  46266. }
  46267. <?php
  46268. namespace React\Promise;
  46269. class Promise implements PromiseInterface, CancellablePromiseInterface
  46270. {
  46271. private $deferred;
  46272. public function __construct($resolver, $canceller = null)
  46273. {
  46274. if (!is_callable($resolver)) {
  46275. throw new \InvalidArgumentException(
  46276. sprintf(
  46277. 'The resolver argument must be of type callable, %s given.',
  46278. gettype($resolver)
  46279. )
  46280. );
  46281. }
  46282. $this->deferred = new Deferred($canceller);
  46283. $this->call($resolver);
  46284. }
  46285. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46286. {
  46287. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46288. }
  46289. public function cancel()
  46290. {
  46291. $this->deferred->cancel();
  46292. }
  46293. private function call($callback)
  46294. {
  46295. $deferred = $this->deferred;
  46296. try {
  46297. call_user_func(
  46298. $callback,
  46299. function ($result = null) use ($deferred) {
  46300. $deferred->resolve($result);
  46301. },
  46302. function ($reason = null) use ($deferred) {
  46303. $deferred->reject($reason);
  46304. },
  46305. function ($update = null) use ($deferred) {
  46306. $deferred->progress($update);
  46307. }
  46308. );
  46309. } catch (\Exception $e) {
  46310. $this->deferred->reject($e);
  46311. }
  46312. }
  46313. }
  46314. <?php
  46315. namespace React\Promise;
  46316. interface PromiseInterface
  46317. {
  46318. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
  46319. }
  46320. <?php
  46321. namespace React\Promise;
  46322. interface PromisorInterface
  46323. {
  46324. public function promise();
  46325. }
  46326. <?php
  46327. namespace React\Promise;
  46328. class RejectedPromise implements PromiseInterface, CancellablePromiseInterface
  46329. {
  46330. private $reason;
  46331. public function __construct($reason = null)
  46332. {
  46333. $this->reason = $reason;
  46334. }
  46335. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46336. {
  46337. try {
  46338. if (!is_callable($errorHandler)) {
  46339. if (null !== $errorHandler) {
  46340. trigger_error('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46341. }
  46342. return new RejectedPromise($this->reason);
  46343. }
  46344. return resolve(call_user_func($errorHandler, $this->reason));
  46345. } catch (\Exception $exception) {
  46346. return new RejectedPromise($exception);
  46347. }
  46348. }
  46349. public function cancel()
  46350. {
  46351. }
  46352. }
  46353. <?php
  46354. namespace React\Promise;
  46355. interface ResolverInterface
  46356. {
  46357. public function resolve($result = null);
  46358. public function reject($reason = null);
  46359. public function progress($update = null);
  46360. }
  46361. <?php
  46362. namespace React\Promise;
  46363. class Util
  46364. {
  46365. public static function promiseFor($promiseOrValue)
  46366. {
  46367. return resolve($promiseOrValue);
  46368. }
  46369. public static function rejectedPromiseFor($promiseOrValue)
  46370. {
  46371. return reject($promiseOrValue);
  46372. }
  46373. }
  46374. <?php
  46375. namespace React\Promise;
  46376. class When
  46377. {
  46378. public static function resolve($promiseOrValue = null)
  46379. {
  46380. return resolve($promiseOrValue);
  46381. }
  46382. public static function reject($promiseOrValue = null)
  46383. {
  46384. return reject($promiseOrValue);
  46385. }
  46386. public static function lazy($factory)
  46387. {
  46388. return new LazyPromise($factory);
  46389. }
  46390. public static function all($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46391. {
  46392. return all($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46393. }
  46394. public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46395. {
  46396. return any($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46397. }
  46398. public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46399. {
  46400. return some($promisesOrValues, $howMany)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46401. }
  46402. public static function map($promisesOrValues, $mapFunc)
  46403. {
  46404. return map($promisesOrValues, $mapFunc);
  46405. }
  46406. public static function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  46407. {
  46408. return reduce($promisesOrValues, $reduceFunc, $initialValue);
  46409. }
  46410. }
  46411. <?php
  46412. namespace React\Promise;
  46413. function resolve($promiseOrValue = null)
  46414. {
  46415. if ($promiseOrValue instanceof PromiseInterface) {
  46416. return $promiseOrValue;
  46417. }
  46418. return new FulfilledPromise($promiseOrValue);
  46419. }
  46420. function reject($promiseOrValue = null)
  46421. {
  46422. if ($promiseOrValue instanceof PromiseInterface) {
  46423. return $promiseOrValue->then(function ($value) {
  46424. return new RejectedPromise($value);
  46425. });
  46426. }
  46427. return new RejectedPromise($promiseOrValue);
  46428. }
  46429. function all($promisesOrValues)
  46430. {
  46431. return map($promisesOrValues, function ($val) {
  46432. return $val;
  46433. });
  46434. }
  46435. function any($promisesOrValues)
  46436. {
  46437. return some($promisesOrValues, 1)->then(function($val) {
  46438. return array_shift($val);
  46439. });
  46440. }
  46441. function some($promisesOrValues, $howMany)
  46442. {
  46443. return resolve($promisesOrValues)->then(function ($array) use ($howMany) {
  46444. if (!is_array($array)) {
  46445. $array = array();
  46446. }
  46447. $len = count($array);
  46448. $toResolve = max(0, min($howMany, $len));
  46449. $values = array();
  46450. $deferred = new Deferred();
  46451. if (!$toResolve) {
  46452. $deferred->resolve($values);
  46453. } else {
  46454. $toReject = ($len - $toResolve) + 1;
  46455. $reasons = array();
  46456. $progress = array($deferred, 'progress');
  46457. $fulfillOne = function ($val, $i) use (&$values, &$toResolve, $deferred) {
  46458. $values[$i] = $val;
  46459. if (0 === --$toResolve) {
  46460. $deferred->resolve($values);
  46461. return true;
  46462. }
  46463. };
  46464. $rejectOne = function ($reason, $i) use (&$reasons, &$toReject, $deferred) {
  46465. $reasons[$i] = $reason;
  46466. if (0 === --$toReject) {
  46467. $deferred->reject($reasons);
  46468. return true;
  46469. }
  46470. };
  46471. foreach ($array as $i => $promiseOrValue) {
  46472. $fulfiller = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  46473. $reset = $fulfillOne($val, $i);
  46474. if (true === $reset) {
  46475. $fulfillOne = $rejectOne = function () {};
  46476. }
  46477. };
  46478. $rejecter = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  46479. $reset = $rejectOne($val, $i);
  46480. if (true === $reset) {
  46481. $fulfillOne = $rejectOne = function () {};
  46482. }
  46483. };
  46484. resolve($promiseOrValue)->then($fulfiller, $rejecter, $progress);
  46485. }
  46486. }
  46487. return $deferred->promise();
  46488. });
  46489. }
  46490. function map($promisesOrValues, $mapFunc)
  46491. {
  46492. return resolve($promisesOrValues)->then(function ($array) use ($mapFunc) {
  46493. if (!is_array($array)) {
  46494. $array = array();
  46495. }
  46496. $toResolve = count($array);
  46497. $results = array();
  46498. $deferred = new Deferred();
  46499. if (!$toResolve) {
  46500. $deferred->resolve($results);
  46501. } else {
  46502. $resolve = function ($item, $i) use ($mapFunc, &$results, &$toResolve, $deferred) {
  46503. resolve($item)
  46504. ->then($mapFunc)
  46505. ->then(
  46506. function ($mapped) use (&$results, $i, &$toResolve, $deferred) {
  46507. $results[$i] = $mapped;
  46508. if (0 === --$toResolve) {
  46509. $deferred->resolve($results);
  46510. }
  46511. },
  46512. array($deferred, 'reject')
  46513. );
  46514. };
  46515. foreach ($array as $i => $item) {
  46516. $resolve($item, $i);
  46517. }
  46518. }
  46519. return $deferred->promise();
  46520. });
  46521. }
  46522. function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  46523. {
  46524. return resolve($promisesOrValues)->then(function ($array) use ($reduceFunc, $initialValue) {
  46525. if (!is_array($array)) {
  46526. $array = array();
  46527. }
  46528. $total = count($array);
  46529. $i = 0;
  46530. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $total, &$i) {
  46531. return resolve($current)->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  46532. return resolve($val)->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  46533. return call_user_func($reduceFunc, $c, $value, $i++, $total);
  46534. });
  46535. });
  46536. };
  46537. return array_reduce($array, $wrappedReduceFunc, $initialValue);
  46538. });
  46539. }
  46540. <?php
  46541. if (!function_exists('React\Promise\resolve')) {
  46542. require __DIR__.'/functions.php';
  46543. }
  46544. Copyright (c) 2011 Jordi Boggiano
  46545. Permission is hereby granted, free of charge, to any person obtaining a copy
  46546. of this software and associated documentation files (the "Software"), to deal
  46547. in the Software without restriction, including without limitation the rights
  46548. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46549. copies of the Software, and to permit persons to whom the Software is furnished
  46550. to do so, subject to the following conditions:
  46551. The above copyright notice and this permission notice shall be included in all
  46552. copies or substantial portions of the Software.
  46553. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46554. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46555. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46556. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46557. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46558. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  46559. THE SOFTWARE.
  46560. <?php
  46561. namespace Seld\JsonLint;
  46562. class DuplicateKeyException extends ParsingException
  46563. {
  46564. public function __construct($message, $key, array $details = array())
  46565. {
  46566. $details['key'] = $key;
  46567. parent::__construct($message, $details);
  46568. }
  46569. public function getKey()
  46570. {
  46571. return $this->details['key'];
  46572. }
  46573. public function getDetails()
  46574. {
  46575. return $this->details;
  46576. }
  46577. }
  46578. <?php
  46579. namespace Seld\JsonLint;
  46580. use stdClass;
  46581. class JsonParser
  46582. {
  46583. const DETECT_KEY_CONFLICTS = 1;
  46584. const ALLOW_DUPLICATE_KEYS = 2;
  46585. const PARSE_TO_ASSOC = 4;
  46586. private $lexer;
  46587. private $flags;
  46588. private $stack;
  46589. private $vstack;
  46590. private $lstack;
  46591. private $symbols = array(
  46592. 'error' => 2,
  46593. 'JSONString' => 3,
  46594. 'STRING' => 4,
  46595. 'JSONNumber' => 5,
  46596. 'NUMBER' => 6,
  46597. 'JSONNullLiteral' => 7,
  46598. 'NULL' => 8,
  46599. 'JSONBooleanLiteral' => 9,
  46600. 'TRUE' => 10,
  46601. 'FALSE' => 11,
  46602. 'JSONText' => 12,
  46603. 'JSONValue' => 13,
  46604. 'EOF' => 14,
  46605. 'JSONObject' => 15,
  46606. 'JSONArray' => 16,
  46607. '{' => 17,
  46608. '}' => 18,
  46609. 'JSONMemberList' => 19,
  46610. 'JSONMember' => 20,
  46611. ':' => 21,
  46612. ',' => 22,
  46613. '[' => 23,
  46614. ']' => 24,
  46615. 'JSONElementList' => 25,
  46616. '$accept' => 0,
  46617. '$end' => 1,
  46618. );
  46619. private $terminals_ = array(
  46620. 2 => "error",
  46621. 4 => "STRING",
  46622. 6 => "NUMBER",
  46623. 8 => "NULL",
  46624. 10 => "TRUE",
  46625. 11 => "FALSE",
  46626. 14 => "EOF",
  46627. 17 => "{",
  46628. 18 => "}",
  46629. 21 => ":",
  46630. 22 => ",",
  46631. 23 => "[",
  46632. 24 => "]",
  46633. );
  46634. private $productions_ = array(
  46635. 0,
  46636. array(3, 1),
  46637. array(5, 1),
  46638. array(7, 1),
  46639. array(9, 1),
  46640. array(9, 1),
  46641. array(12, 2),
  46642. array(13, 1),
  46643. array(13, 1),
  46644. array(13, 1),
  46645. array(13, 1),
  46646. array(13, 1),
  46647. array(13, 1),
  46648. array(15, 2),
  46649. array(15, 3),
  46650. array(20, 3),
  46651. array(19, 1),
  46652. array(19, 3),
  46653. array(16, 2),
  46654. array(16, 3),
  46655. array(25, 1),
  46656. array(25, 3)
  46657. );
  46658. 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)),
  46659. );
  46660. private $defaultActions = array(
  46661. 16 => array(2, 6)
  46662. );
  46663. public function lint($input, $flags = 0)
  46664. {
  46665. try {
  46666. $this->parse($input, $flags);
  46667. } catch (ParsingException $e) {
  46668. return $e;
  46669. }
  46670. return null;
  46671. }
  46672. public function parse($input, $flags = 0)
  46673. {
  46674. $this->failOnBOM($input);
  46675. $this->flags = $flags;
  46676. $this->stack = array(0);
  46677. $this->vstack = array(null);
  46678. $this->lstack = array();
  46679. $yytext = '';
  46680. $yylineno = 0;
  46681. $yyleng = 0;
  46682. $recovering = 0;
  46683. $TERROR = 2;
  46684. $EOF = 1;
  46685. $this->lexer = new Lexer();
  46686. $this->lexer->setInput($input);
  46687. $yyloc = $this->lexer->yylloc;
  46688. $this->lstack[] = $yyloc;
  46689. $symbol = null;
  46690. $preErrorSymbol = null;
  46691. $state = null;
  46692. $action = null;
  46693. $a = null;
  46694. $r = null;
  46695. $yyval = new stdClass;
  46696. $p = null;
  46697. $len = null;
  46698. $newState = null;
  46699. $expected = null;
  46700. $errStr = null;
  46701. while (true) {
  46702. $state = $this->stack[\count($this->stack)-1];
  46703. if (isset($this->defaultActions[$state])) {
  46704. $action = $this->defaultActions[$state];
  46705. } else {
  46706. if ($symbol == null) {
  46707. $symbol = $this->lex();
  46708. }
  46709. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  46710. }
  46711. if (!$action || !$action[0]) {
  46712. if (!$recovering) {
  46713. $expected = array();
  46714. foreach ($this->table[$state] as $p => $ignore) {
  46715. if (isset($this->terminals_[$p]) && $p > 2) {
  46716. $expected[] = "'" . $this->terminals_[$p] . "'";
  46717. }
  46718. }
  46719. $message = null;
  46720. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  46721. $message = "Invalid string";
  46722. if ("'" === substr($this->lexer->match, 0, 1)) {
  46723. $message .= ", it appears you used single quotes instead of double quotes";
  46724. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  46725. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  46726. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  46727. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  46728. }
  46729. }
  46730. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  46731. $errStr .= $this->lexer->showPosition() . "\n";
  46732. if ($message) {
  46733. $errStr .= $message;
  46734. } else {
  46735. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  46736. $errStr .= implode(', ', $expected);
  46737. }
  46738. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  46739. $errStr .= " - It appears you have an extra trailing comma";
  46740. }
  46741. $this->parseError($errStr, array(
  46742. 'text' => $this->lexer->match,
  46743. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  46744. 'line' => $this->lexer->yylineno,
  46745. 'loc' => $yyloc,
  46746. 'expected' => $expected,
  46747. ));
  46748. }
  46749. if ($recovering == 3) {
  46750. if ($symbol == $EOF) {
  46751. throw new ParsingException($errStr ?: 'Parsing halted.');
  46752. }
  46753. $yyleng = $this->lexer->yyleng;
  46754. $yytext = $this->lexer->yytext;
  46755. $yylineno = $this->lexer->yylineno;
  46756. $yyloc = $this->lexer->yylloc;
  46757. $symbol = $this->lex();
  46758. }
  46759. while (true) {
  46760. if (\array_key_exists($TERROR, $this->table[$state])) {
  46761. break;
  46762. }
  46763. if ($state == 0) {
  46764. throw new ParsingException($errStr ?: 'Parsing halted.');
  46765. }
  46766. $this->popStack(1);
  46767. $state = $this->stack[\count($this->stack)-1];
  46768. }
  46769. $preErrorSymbol = $symbol;
  46770. $symbol = $TERROR;
  46771. $state = $this->stack[\count($this->stack)-1];
  46772. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  46773. $recovering = 3;
  46774. }
  46775. if (\is_array($action[0]) && \count($action) > 1) {
  46776. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  46777. }
  46778. switch ($action[0]) {
  46779. case 1:
  46780. $this->stack[] = $symbol;
  46781. $this->vstack[] = $this->lexer->yytext;
  46782. $this->lstack[] = $this->lexer->yylloc;
  46783. $this->stack[] = $action[1];
  46784. $symbol = null;
  46785. if (!$preErrorSymbol) {
  46786. $yyleng = $this->lexer->yyleng;
  46787. $yytext = $this->lexer->yytext;
  46788. $yylineno = $this->lexer->yylineno;
  46789. $yyloc = $this->lexer->yylloc;
  46790. if ($recovering > 0) {
  46791. $recovering--;
  46792. }
  46793. } else {
  46794. $symbol = $preErrorSymbol;
  46795. $preErrorSymbol = null;
  46796. }
  46797. break;
  46798. case 2:
  46799. $len = $this->productions_[$action[1]][1];
  46800. $yyval->token = $this->vstack[\count($this->vstack) - $len];
  46801. $yyval->store = array(
  46802. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  46803. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  46804. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  46805. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  46806. );
  46807. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
  46808. if (!$r instanceof Undefined) {
  46809. return $r;
  46810. }
  46811. if ($len) {
  46812. $this->popStack($len);
  46813. }
  46814. $this->stack[] = $this->productions_[$action[1]][0];
  46815. $this->vstack[] = $yyval->token;
  46816. $this->lstack[] = $yyval->store;
  46817. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  46818. $this->stack[] = $newState;
  46819. break;
  46820. case 3:
  46821. return true;
  46822. }
  46823. }
  46824. }
  46825. protected function parseError($str, $hash)
  46826. {
  46827. throw new ParsingException($str, $hash);
  46828. }
  46829. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  46830. {
  46831. $len = \count($tokens) - 1;
  46832. switch ($yystate) {
  46833. case 1:
  46834. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  46835. $yyval->token = $yytext;
  46836. break;
  46837. case 2:
  46838. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  46839. $yyval->token = \floatval($yytext);
  46840. } else {
  46841. $yyval->token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  46842. }
  46843. break;
  46844. case 3:
  46845. $yyval->token = null;
  46846. break;
  46847. case 4:
  46848. $yyval->token = true;
  46849. break;
  46850. case 5:
  46851. $yyval->token = false;
  46852. break;
  46853. case 6:
  46854. return $yyval->token = $tokens[$len-1];
  46855. case 13:
  46856. if ($this->flags & self::PARSE_TO_ASSOC) {
  46857. $yyval->token = array();
  46858. } else {
  46859. $yyval->token = new stdClass;
  46860. }
  46861. break;
  46862. case 14:
  46863. $yyval->token = $tokens[$len-1];
  46864. break;
  46865. case 15:
  46866. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  46867. break;
  46868. case 16:
  46869. if (PHP_VERSION_ID < 70100) {
  46870. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  46871. } else {
  46872. $property = $tokens[$len][0];
  46873. }
  46874. if ($this->flags & self::PARSE_TO_ASSOC) {
  46875. $yyval->token = array();
  46876. $yyval->token[$property] = $tokens[$len][1];
  46877. } else {
  46878. $yyval->token = new stdClass;
  46879. $yyval->token->$property = $tokens[$len][1];
  46880. }
  46881. break;
  46882. case 17:
  46883. if ($this->flags & self::PARSE_TO_ASSOC) {
  46884. $yyval->token =& $tokens[$len-2];
  46885. $key = $tokens[$len][0];
  46886. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  46887. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  46888. $errStr .= $this->lexer->showPosition() . "\n";
  46889. $errStr .= "Duplicate key: ".$tokens[$len][0];
  46890. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  46891. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  46892. $duplicateCount = 1;
  46893. do {
  46894. $duplicateKey = $key . '.' . $duplicateCount++;
  46895. } while (isset($tokens[$len-2][$duplicateKey]));
  46896. $key = $duplicateKey;
  46897. }
  46898. $tokens[$len-2][$key] = $tokens[$len][1];
  46899. } else {
  46900. $yyval->token = $tokens[$len-2];
  46901. if (PHP_VERSION_ID < 70100) {
  46902. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  46903. } else {
  46904. $key = $tokens[$len][0];
  46905. }
  46906. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  46907. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  46908. $errStr .= $this->lexer->showPosition() . "\n";
  46909. $errStr .= "Duplicate key: ".$tokens[$len][0];
  46910. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  46911. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  46912. $duplicateCount = 1;
  46913. do {
  46914. $duplicateKey = $key . '.' . $duplicateCount++;
  46915. } while (isset($tokens[$len-2]->$duplicateKey));
  46916. $key = $duplicateKey;
  46917. }
  46918. $tokens[$len-2]->$key = $tokens[$len][1];
  46919. }
  46920. break;
  46921. case 18:
  46922. $yyval->token = array();
  46923. break;
  46924. case 19:
  46925. $yyval->token = $tokens[$len-1];
  46926. break;
  46927. case 20:
  46928. $yyval->token = array($tokens[$len]);
  46929. break;
  46930. case 21:
  46931. $tokens[$len-2][] = $tokens[$len];
  46932. $yyval->token = $tokens[$len-2];
  46933. break;
  46934. }
  46935. return new Undefined();
  46936. }
  46937. private function stringInterpolation($match)
  46938. {
  46939. switch ($match[0]) {
  46940. case '\\\\':
  46941. return '\\';
  46942. case '\"':
  46943. return '"';
  46944. case '\b':
  46945. return \chr(8);
  46946. case '\f':
  46947. return \chr(12);
  46948. case '\n':
  46949. return "\n";
  46950. case '\r':
  46951. return "\r";
  46952. case '\t':
  46953. return "\t";
  46954. case '\/':
  46955. return "/";
  46956. default:
  46957. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  46958. }
  46959. }
  46960. private function popStack($n)
  46961. {
  46962. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  46963. $this->vstack = \array_slice($this->vstack, 0, - $n);
  46964. $this->lstack = \array_slice($this->lstack, 0, - $n);
  46965. }
  46966. private function lex()
  46967. {
  46968. $token = $this->lexer->lex() ?: 1;
  46969. if (!is_numeric($token)) {
  46970. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  46971. }
  46972. return $token;
  46973. }
  46974. private function failOnBOM($input)
  46975. {
  46976. $bom = "\xEF\xBB\xBF";
  46977. if (substr($input, 0, 3) === $bom) {
  46978. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  46979. }
  46980. }
  46981. }
  46982. <?php
  46983. namespace Seld\JsonLint;
  46984. class Lexer
  46985. {
  46986. private $EOF = 1;
  46987. private $rules = array(
  46988. 0 => '/\G\s+/',
  46989. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  46990. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  46991. 3 => '/\G\{/',
  46992. 4 => '/\G\}/',
  46993. 5 => '/\G\[/',
  46994. 6 => '/\G\]/',
  46995. 7 => '/\G,/',
  46996. 8 => '/\G:/',
  46997. 9 => '/\Gtrue\b/',
  46998. 10 => '/\Gfalse\b/',
  46999. 11 => '/\Gnull\b/',
  47000. 12 => '/\G$/',
  47001. 13 => '/\G./',
  47002. );
  47003. private $conditions = array(
  47004. "INITIAL" => array(
  47005. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  47006. "inclusive" => true,
  47007. ),
  47008. );
  47009. private $conditionStack;
  47010. private $input;
  47011. private $more;
  47012. private $done;
  47013. private $offset;
  47014. public $match;
  47015. public $yylineno;
  47016. public $yyleng;
  47017. public $yytext;
  47018. public $yylloc;
  47019. public function lex()
  47020. {
  47021. $r = $this->next();
  47022. if (!$r instanceof Undefined) {
  47023. return $r;
  47024. }
  47025. return $this->lex();
  47026. }
  47027. public function setInput($input)
  47028. {
  47029. $this->input = $input;
  47030. $this->more = false;
  47031. $this->done = false;
  47032. $this->offset = 0;
  47033. $this->yylineno = $this->yyleng = 0;
  47034. $this->yytext = $this->match = '';
  47035. $this->conditionStack = array('INITIAL');
  47036. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  47037. return $this;
  47038. }
  47039. public function showPosition()
  47040. {
  47041. $pre = str_replace("\n", '', $this->getPastInput());
  47042. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  47043. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  47044. }
  47045. public function getPastInput()
  47046. {
  47047. $pastLength = $this->offset - \strlen($this->match);
  47048. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  47049. }
  47050. public function getUpcomingInput()
  47051. {
  47052. $next = $this->match;
  47053. if (\strlen($next) < 20) {
  47054. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47055. }
  47056. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  47057. }
  47058. public function getFullUpcomingInput()
  47059. {
  47060. $next = $this->match;
  47061. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  47062. $len = \strlen($this->input);
  47063. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  47064. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  47065. } elseif (\strlen($next) < 20) {
  47066. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47067. }
  47068. return $next;
  47069. }
  47070. protected function parseError($str, $hash)
  47071. {
  47072. throw new \Exception($str);
  47073. }
  47074. private function next()
  47075. {
  47076. if ($this->done) {
  47077. return $this->EOF;
  47078. }
  47079. if ($this->offset === \strlen($this->input)) {
  47080. $this->done = true;
  47081. }
  47082. $token = null;
  47083. $match = null;
  47084. $col = null;
  47085. $lines = null;
  47086. if (!$this->more) {
  47087. $this->yytext = '';
  47088. $this->match = '';
  47089. }
  47090. $rules = $this->getCurrentRules();
  47091. $rulesLen = \count($rules);
  47092. for ($i=0; $i < $rulesLen; $i++) {
  47093. if (preg_match($this->rules[$rules[$i]], $this->input, $match, 0, $this->offset)) {
  47094. preg_match_all('/\n.*/', $match[0], $lines);
  47095. $lines = $lines[0];
  47096. if ($lines) {
  47097. $this->yylineno += \count($lines);
  47098. }
  47099. $this->yylloc = array(
  47100. 'first_line' => $this->yylloc['last_line'],
  47101. 'last_line' => $this->yylineno+1,
  47102. 'first_column' => $this->yylloc['last_column'],
  47103. 'last_column' => $lines ? \strlen($lines[\count($lines) - 1]) - 1 : $this->yylloc['last_column'] + \strlen($match[0]),
  47104. );
  47105. $this->yytext .= $match[0];
  47106. $this->match .= $match[0];
  47107. $this->yyleng = \strlen($this->yytext);
  47108. $this->more = false;
  47109. $this->offset += \strlen($match[0]);
  47110. $token = $this->performAction($rules[$i], $this->conditionStack[\count($this->conditionStack)-1]);
  47111. if ($token) {
  47112. return $token;
  47113. }
  47114. return new Undefined();
  47115. }
  47116. }
  47117. if ($this->offset === \strlen($this->input)) {
  47118. return $this->EOF;
  47119. }
  47120. $this->parseError(
  47121. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  47122. array(
  47123. 'text' => "",
  47124. 'token' => null,
  47125. 'line' => $this->yylineno,
  47126. )
  47127. );
  47128. }
  47129. private function getCurrentRules()
  47130. {
  47131. return $this->conditions[$this->conditionStack[\count($this->conditionStack)-1]]['rules'];
  47132. }
  47133. private function performAction($avoiding_name_collisions, $YY_START)
  47134. {
  47135. switch ($avoiding_name_collisions) {
  47136. case 0:
  47137. break;
  47138. case 1:
  47139. return 6;
  47140. case 2:
  47141. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  47142. return 4;
  47143. case 3:
  47144. return 17;
  47145. case 4:
  47146. return 18;
  47147. case 5:
  47148. return 23;
  47149. case 6:
  47150. return 24;
  47151. case 7:
  47152. return 22;
  47153. case 8:
  47154. return 21;
  47155. case 9:
  47156. return 10;
  47157. case 10:
  47158. return 11;
  47159. case 11:
  47160. return 8;
  47161. case 12:
  47162. return 14;
  47163. case 13:
  47164. return 'INVALID';
  47165. }
  47166. }
  47167. }
  47168. <?php
  47169. namespace Seld\JsonLint;
  47170. class ParsingException extends \Exception
  47171. {
  47172. protected $details;
  47173. public function __construct($message, $details = array())
  47174. {
  47175. $this->details = $details;
  47176. parent::__construct($message);
  47177. }
  47178. public function getDetails()
  47179. {
  47180. return $this->details;
  47181. }
  47182. }
  47183. <?php
  47184. namespace Seld\JsonLint;
  47185. class Undefined
  47186. {
  47187. }
  47188. Copyright (c) 2015 Jordi Boggiano
  47189. Permission is hereby granted, free of charge, to any person obtaining a copy
  47190. of this software and associated documentation files (the "Software"), to deal
  47191. in the Software without restriction, including without limitation the rights
  47192. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47193. copies of the Software, and to permit persons to whom the Software is furnished
  47194. to do so, subject to the following conditions:
  47195. The above copyright notice and this permission notice shall be included in all
  47196. copies or substantial portions of the Software.
  47197. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47198. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47199. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47200. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47201. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47202. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47203. THE SOFTWARE.
  47204. <?php
  47205. namespace Seld\PharUtils;
  47206. class Linter
  47207. {
  47208. public static function lint($path)
  47209. {
  47210. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  47211. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  47212. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  47213. if (!$tmpFile || !is_writable($tmpFile)) {
  47214. throw new \RuntimeException('Unable to create temp file');
  47215. }
  47216. $php = self::escapeWindowsPath($php);
  47217. $tmpFile = self::escapeWindowsPath($tmpFile);
  47218. if (PHP_VERSION_ID >= 80000) {
  47219. $format = '%s -l %s';
  47220. } else {
  47221. $format = '"%s -l %s"';
  47222. }
  47223. $command = sprintf($format, $php, $tmpFile);
  47224. } else {
  47225. $command = "'".$php."' -l";
  47226. }
  47227. $descriptorspec = array(
  47228. 0 => array('pipe', 'r'),
  47229. 1 => array('pipe', 'w'),
  47230. 2 => array('pipe', 'w')
  47231. );
  47232. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  47233. if ($file->isDir()) {
  47234. continue;
  47235. }
  47236. if (substr($file, -4) === '.php') {
  47237. $filename = (string) $file;
  47238. if ($isWindows) {
  47239. file_put_contents($tmpFile, file_get_contents($filename));
  47240. }
  47241. $process = proc_open($command, $descriptorspec, $pipes);
  47242. if (is_resource($process)) {
  47243. if (!$isWindows) {
  47244. fwrite($pipes[0], file_get_contents($filename));
  47245. }
  47246. fclose($pipes[0]);
  47247. $stdout = stream_get_contents($pipes[1]);
  47248. fclose($pipes[1]);
  47249. $stderr = stream_get_contents($pipes[2]);
  47250. fclose($pipes[2]);
  47251. $exitCode = proc_close($process);
  47252. if ($exitCode !== 0) {
  47253. if ($isWindows) {
  47254. $stderr = str_replace($tmpFile, $filename, $stderr);
  47255. }
  47256. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  47257. }
  47258. } else {
  47259. throw new \RuntimeException('Could not start linter process');
  47260. }
  47261. }
  47262. }
  47263. if ($isWindows) {
  47264. @unlink($tmpFile);
  47265. }
  47266. }
  47267. private static function escapeWindowsPath($path)
  47268. {
  47269. if (strpbrk($path, " ()") !== false) {
  47270. $path = '"'.$path.'"';
  47271. }
  47272. return $path;
  47273. }
  47274. }
  47275. <?php
  47276. namespace Seld\PharUtils;
  47277. class Timestamps
  47278. {
  47279. private $contents;
  47280. public function __construct($file)
  47281. {
  47282. $this->contents = file_get_contents($file);
  47283. }
  47284. public function updateTimestamps($timestamp = null)
  47285. {
  47286. if ($timestamp instanceof \DateTime) {
  47287. $timestamp = $timestamp->getTimestamp();
  47288. } elseif (is_string($timestamp)) {
  47289. $timestamp = strtotime($timestamp);
  47290. } elseif (!is_int($timestamp)) {
  47291. $timestamp = strtotime('1984-12-24T00:00:00Z');
  47292. }
  47293. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47294. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47295. }
  47296. $pos = $match[0][1] + strlen($match[0][0]);
  47297. $stubEnd = $pos + $this->readUint($pos, 4);
  47298. $pos += 4;
  47299. $numFiles = $this->readUint($pos, 4);
  47300. $pos += 4;
  47301. $pos += 2;
  47302. $pos += 4;
  47303. $aliasLength = $this->readUint($pos, 4);
  47304. $pos += 4 + $aliasLength;
  47305. $metadataLength = $this->readUint($pos, 4);
  47306. $pos += 4 + $metadataLength;
  47307. while ($pos < $stubEnd) {
  47308. $filenameLength = $this->readUint($pos, 4);
  47309. $pos += 4 + $filenameLength;
  47310. $pos += 4;
  47311. $this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
  47312. $pos += 4*4;
  47313. $metadataLength = $this->readUint($pos, 4);
  47314. $pos += 4 + $metadataLength;
  47315. $numFiles--;
  47316. }
  47317. if ($numFiles !== 0) {
  47318. throw new \LogicException('All files were not processed, something must have gone wrong');
  47319. }
  47320. }
  47321. public function save($path, $signatureAlgo)
  47322. {
  47323. $pos = $this->determineSignatureBegin();
  47324. $algos = array(
  47325. \Phar::MD5 => 'md5',
  47326. \Phar::SHA1 => 'sha1',
  47327. \Phar::SHA256 => 'sha256',
  47328. \Phar::SHA512 => 'sha512',
  47329. );
  47330. if (!isset($algos[$signatureAlgo])) {
  47331. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  47332. }
  47333. $algo = $algos[$signatureAlgo];
  47334. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  47335. . pack('L', $signatureAlgo)
  47336. . 'GBMB';
  47337. $this->contents = substr($this->contents, 0, $pos) . $signature;
  47338. return file_put_contents($path, $this->contents);
  47339. }
  47340. private function readUint($pos, $bytes)
  47341. {
  47342. $res = unpack('V', substr($this->contents, $pos, $bytes));
  47343. return $res[1];
  47344. }
  47345. private function determineSignatureBegin()
  47346. {
  47347. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47348. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47349. }
  47350. $pos = $match[0][1] + strlen($match[0][0]);
  47351. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  47352. $pos += 4;
  47353. $numFiles = $this->readUint($pos, 4);
  47354. $pos += 4;
  47355. $pos += 2;
  47356. $pos += 4;
  47357. $aliasLength = $this->readUint($pos, 4);
  47358. $pos += 4 + $aliasLength;
  47359. $metadataLength = $this->readUint($pos, 4);
  47360. $pos += 4 + $metadataLength;
  47361. $compressedSizes = 0;
  47362. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  47363. $filenameLength = $this->readUint($pos, 4);
  47364. $pos += 4 + $filenameLength;
  47365. $pos += 2*4;
  47366. $compressedSizes += $this->readUint($pos, 4);
  47367. $pos += 3*4;
  47368. $metadataLength = $this->readUint($pos, 4);
  47369. $pos += 4 + $metadataLength;
  47370. $numFiles--;
  47371. }
  47372. if ($numFiles !== 0) {
  47373. throw new \LogicException('All files were not processed, something must have gone wrong');
  47374. }
  47375. return $manifestEnd + $compressedSizes;
  47376. }
  47377. }
  47378. <?php
  47379. namespace Symfony\Component\Console;
  47380. use Symfony\Component\Console\Command\Command;
  47381. use Symfony\Component\Console\Command\HelpCommand;
  47382. use Symfony\Component\Console\Command\ListCommand;
  47383. use Symfony\Component\Console\Descriptor\TextDescriptor;
  47384. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  47385. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  47386. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  47387. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  47388. use Symfony\Component\Console\Exception\CommandNotFoundException;
  47389. use Symfony\Component\Console\Exception\ExceptionInterface;
  47390. use Symfony\Component\Console\Exception\LogicException;
  47391. use Symfony\Component\Console\Formatter\OutputFormatter;
  47392. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  47393. use Symfony\Component\Console\Helper\DialogHelper;
  47394. use Symfony\Component\Console\Helper\FormatterHelper;
  47395. use Symfony\Component\Console\Helper\Helper;
  47396. use Symfony\Component\Console\Helper\HelperSet;
  47397. use Symfony\Component\Console\Helper\ProcessHelper;
  47398. use Symfony\Component\Console\Helper\ProgressHelper;
  47399. use Symfony\Component\Console\Helper\QuestionHelper;
  47400. use Symfony\Component\Console\Helper\TableHelper;
  47401. use Symfony\Component\Console\Input\ArgvInput;
  47402. use Symfony\Component\Console\Input\ArrayInput;
  47403. use Symfony\Component\Console\Input\InputArgument;
  47404. use Symfony\Component\Console\Input\InputAwareInterface;
  47405. use Symfony\Component\Console\Input\InputDefinition;
  47406. use Symfony\Component\Console\Input\InputInterface;
  47407. use Symfony\Component\Console\Input\InputOption;
  47408. use Symfony\Component\Console\Output\BufferedOutput;
  47409. use Symfony\Component\Console\Output\ConsoleOutput;
  47410. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  47411. use Symfony\Component\Console\Output\OutputInterface;
  47412. use Symfony\Component\Debug\Exception\FatalThrowableError;
  47413. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  47414. class Application
  47415. {
  47416. private $commands = array();
  47417. private $wantHelps = false;
  47418. private $runningCommand;
  47419. private $name;
  47420. private $version;
  47421. private $catchExceptions = true;
  47422. private $autoExit = true;
  47423. private $definition;
  47424. private $helperSet;
  47425. private $dispatcher;
  47426. private $terminalDimensions;
  47427. private $defaultCommand;
  47428. private $initialized;
  47429. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  47430. {
  47431. $this->name = $name;
  47432. $this->version = $version;
  47433. $this->defaultCommand = 'list';
  47434. }
  47435. public function setDispatcher(EventDispatcherInterface $dispatcher)
  47436. {
  47437. $this->dispatcher = $dispatcher;
  47438. }
  47439. public function run(InputInterface $input = null, OutputInterface $output = null)
  47440. {
  47441. if (null === $input) {
  47442. $input = new ArgvInput();
  47443. }
  47444. if (null === $output) {
  47445. $output = new ConsoleOutput();
  47446. }
  47447. $this->configureIO($input, $output);
  47448. try {
  47449. $e = null;
  47450. $exitCode = $this->doRun($input, $output);
  47451. } catch (\Exception $e) {
  47452. }
  47453. if (null !== $e) {
  47454. if (!$this->catchExceptions) {
  47455. throw $e;
  47456. }
  47457. if ($output instanceof ConsoleOutputInterface) {
  47458. $this->renderException($e, $output->getErrorOutput());
  47459. } else {
  47460. $this->renderException($e, $output);
  47461. }
  47462. $exitCode = $this->getExitCodeForThrowable($e);
  47463. }
  47464. if ($this->autoExit) {
  47465. if ($exitCode > 255) {
  47466. $exitCode = 255;
  47467. }
  47468. exit($exitCode);
  47469. }
  47470. return $exitCode;
  47471. }
  47472. public function doRun(InputInterface $input, OutputInterface $output)
  47473. {
  47474. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  47475. $output->writeln($this->getLongVersion());
  47476. return 0;
  47477. }
  47478. $name = $this->getCommandName($input);
  47479. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  47480. if (!$name) {
  47481. $name = 'help';
  47482. $input = new ArrayInput(array('command' => 'help'));
  47483. } else {
  47484. $this->wantHelps = true;
  47485. }
  47486. }
  47487. if (!$name) {
  47488. $name = $this->defaultCommand;
  47489. $definition = $this->getDefinition();
  47490. $definition->setArguments(array_merge(
  47491. $definition->getArguments(),
  47492. array(
  47493. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  47494. )
  47495. ));
  47496. }
  47497. $this->runningCommand = null;
  47498. $command = $this->find($name);
  47499. $this->runningCommand = $command;
  47500. $exitCode = $this->doRunCommand($command, $input, $output);
  47501. $this->runningCommand = null;
  47502. return $exitCode;
  47503. }
  47504. public function setHelperSet(HelperSet $helperSet)
  47505. {
  47506. $this->helperSet = $helperSet;
  47507. }
  47508. public function getHelperSet()
  47509. {
  47510. if (!$this->helperSet) {
  47511. $this->helperSet = $this->getDefaultHelperSet();
  47512. }
  47513. return $this->helperSet;
  47514. }
  47515. public function setDefinition(InputDefinition $definition)
  47516. {
  47517. $this->definition = $definition;
  47518. }
  47519. public function getDefinition()
  47520. {
  47521. if (!$this->definition) {
  47522. $this->definition = $this->getDefaultInputDefinition();
  47523. }
  47524. return $this->definition;
  47525. }
  47526. public function getHelp()
  47527. {
  47528. return $this->getLongVersion();
  47529. }
  47530. public function setCatchExceptions($boolean)
  47531. {
  47532. $this->catchExceptions = (bool) $boolean;
  47533. }
  47534. public function setAutoExit($boolean)
  47535. {
  47536. $this->autoExit = (bool) $boolean;
  47537. }
  47538. public function getName()
  47539. {
  47540. return $this->name;
  47541. }
  47542. public function setName($name)
  47543. {
  47544. $this->name = $name;
  47545. }
  47546. public function getVersion()
  47547. {
  47548. return $this->version;
  47549. }
  47550. public function setVersion($version)
  47551. {
  47552. $this->version = $version;
  47553. }
  47554. public function getLongVersion()
  47555. {
  47556. if ('UNKNOWN' !== $this->getName()) {
  47557. if ('UNKNOWN' !== $this->getVersion()) {
  47558. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  47559. }
  47560. return sprintf('<info>%s</info>', $this->getName());
  47561. }
  47562. return '<info>Console Tool</info>';
  47563. }
  47564. public function register($name)
  47565. {
  47566. return $this->add(new Command($name));
  47567. }
  47568. public function addCommands(array $commands)
  47569. {
  47570. foreach ($commands as $command) {
  47571. $this->add($command);
  47572. }
  47573. }
  47574. public function add(Command $command)
  47575. {
  47576. $this->init();
  47577. $command->setApplication($this);
  47578. if (!$command->isEnabled()) {
  47579. $command->setApplication(null);
  47580. return;
  47581. }
  47582. if (null === $command->getDefinition()) {
  47583. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  47584. }
  47585. $this->commands[$command->getName()] = $command;
  47586. foreach ($command->getAliases() as $alias) {
  47587. $this->commands[$alias] = $command;
  47588. }
  47589. return $command;
  47590. }
  47591. public function get($name)
  47592. {
  47593. $this->init();
  47594. if (!isset($this->commands[$name])) {
  47595. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  47596. }
  47597. $command = $this->commands[$name];
  47598. if ($this->wantHelps) {
  47599. $this->wantHelps = false;
  47600. $helpCommand = $this->get('help');
  47601. $helpCommand->setCommand($command);
  47602. return $helpCommand;
  47603. }
  47604. return $command;
  47605. }
  47606. public function has($name)
  47607. {
  47608. $this->init();
  47609. return isset($this->commands[$name]);
  47610. }
  47611. public function getNamespaces()
  47612. {
  47613. $namespaces = array();
  47614. foreach ($this->all() as $command) {
  47615. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  47616. foreach ($command->getAliases() as $alias) {
  47617. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  47618. }
  47619. }
  47620. return array_values(array_unique(array_filter($namespaces)));
  47621. }
  47622. public function findNamespace($namespace)
  47623. {
  47624. $allNamespaces = $this->getNamespaces();
  47625. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  47626. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  47627. if (empty($namespaces)) {
  47628. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  47629. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  47630. if (1 == \count($alternatives)) {
  47631. $message .= "\n\nDid you mean this?\n ";
  47632. } else {
  47633. $message .= "\n\nDid you mean one of these?\n ";
  47634. }
  47635. $message .= implode("\n ", $alternatives);
  47636. }
  47637. throw new CommandNotFoundException($message, $alternatives);
  47638. }
  47639. $exact = \in_array($namespace, $namespaces, true);
  47640. if (\count($namespaces) > 1 && !$exact) {
  47641. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  47642. }
  47643. return $exact ? $namespace : reset($namespaces);
  47644. }
  47645. public function find($name)
  47646. {
  47647. $this->init();
  47648. $aliases = array();
  47649. $allCommands = array_keys($this->commands);
  47650. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  47651. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  47652. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  47653. if (false !== $pos = strrpos($name, ':')) {
  47654. $this->findNamespace(substr($name, 0, $pos));
  47655. }
  47656. $message = sprintf('Command "%s" is not defined.', $name);
  47657. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  47658. if (1 == \count($alternatives)) {
  47659. $message .= "\n\nDid you mean this?\n ";
  47660. } else {
  47661. $message .= "\n\nDid you mean one of these?\n ";
  47662. }
  47663. $message .= implode("\n ", $alternatives);
  47664. }
  47665. throw new CommandNotFoundException($message, $alternatives);
  47666. }
  47667. if (\count($commands) > 1) {
  47668. $commandList = $this->commands;
  47669. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  47670. $commandName = $commandList[$nameOrAlias]->getName();
  47671. $aliases[$nameOrAlias] = $commandName;
  47672. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  47673. });
  47674. }
  47675. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  47676. if (!$exact && \count($commands) > 1) {
  47677. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  47678. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  47679. }
  47680. return $this->get($exact ? $name : reset($commands));
  47681. }
  47682. public function all($namespace = null)
  47683. {
  47684. $this->init();
  47685. if (null === $namespace) {
  47686. return $this->commands;
  47687. }
  47688. $commands = array();
  47689. foreach ($this->commands as $name => $command) {
  47690. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  47691. $commands[$name] = $command;
  47692. }
  47693. }
  47694. return $commands;
  47695. }
  47696. public static function getAbbreviations($names)
  47697. {
  47698. $abbrevs = array();
  47699. foreach ($names as $name) {
  47700. for ($len = \strlen($name); $len > 0; --$len) {
  47701. $abbrev = substr($name, 0, $len);
  47702. $abbrevs[$abbrev][] = $name;
  47703. }
  47704. }
  47705. return $abbrevs;
  47706. }
  47707. public function asText($namespace = null, $raw = false)
  47708. {
  47709. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  47710. $descriptor = new TextDescriptor();
  47711. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  47712. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  47713. return $output->fetch();
  47714. }
  47715. public function asXml($namespace = null, $asDom = false)
  47716. {
  47717. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  47718. $descriptor = new XmlDescriptor();
  47719. if ($asDom) {
  47720. return $descriptor->getApplicationDocument($this, $namespace);
  47721. }
  47722. $output = new BufferedOutput();
  47723. $descriptor->describe($output, $this, array('namespace' => $namespace));
  47724. return $output->fetch();
  47725. }
  47726. public function renderException($e, $output)
  47727. {
  47728. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  47729. do {
  47730. $title = sprintf(' [%s] ', \get_class($e));
  47731. $len = Helper::strlen($title);
  47732. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  47733. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  47734. $width = 1 << 31;
  47735. }
  47736. $lines = array();
  47737. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  47738. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  47739. $lineLength = Helper::strlen($line) + 4;
  47740. $lines[] = array($line, $lineLength);
  47741. $len = max($lineLength, $len);
  47742. }
  47743. }
  47744. $messages = array();
  47745. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  47746. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  47747. foreach ($lines as $line) {
  47748. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  47749. }
  47750. $messages[] = $emptyLine;
  47751. $messages[] = '';
  47752. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  47753. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  47754. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  47755. $trace = $e->getTrace();
  47756. array_unshift($trace, array(
  47757. 'function' => '',
  47758. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  47759. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  47760. 'args' => array(),
  47761. ));
  47762. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  47763. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  47764. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  47765. $function = $trace[$i]['function'];
  47766. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  47767. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  47768. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  47769. }
  47770. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  47771. }
  47772. } while ($e = $e->getPrevious());
  47773. if (null !== $this->runningCommand) {
  47774. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  47775. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  47776. }
  47777. }
  47778. protected function getTerminalWidth()
  47779. {
  47780. $dimensions = $this->getTerminalDimensions();
  47781. return $dimensions[0];
  47782. }
  47783. protected function getTerminalHeight()
  47784. {
  47785. $dimensions = $this->getTerminalDimensions();
  47786. return $dimensions[1];
  47787. }
  47788. public function getTerminalDimensions()
  47789. {
  47790. if ($this->terminalDimensions) {
  47791. return $this->terminalDimensions;
  47792. }
  47793. if ('\\' === \DIRECTORY_SEPARATOR) {
  47794. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  47795. return array((int) $matches[1], (int) $matches[2]);
  47796. }
  47797. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  47798. return array((int) $matches[1], (int) $matches[2]);
  47799. }
  47800. }
  47801. if ($sttyString = $this->getSttyColumns()) {
  47802. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  47803. return array((int) $matches[2], (int) $matches[1]);
  47804. }
  47805. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  47806. return array((int) $matches[2], (int) $matches[1]);
  47807. }
  47808. }
  47809. return array(null, null);
  47810. }
  47811. public function setTerminalDimensions($width, $height)
  47812. {
  47813. $this->terminalDimensions = array($width, $height);
  47814. return $this;
  47815. }
  47816. protected function configureIO(InputInterface $input, OutputInterface $output)
  47817. {
  47818. if (true === $input->hasParameterOption(array('--ansi'))) {
  47819. $output->setDecorated(true);
  47820. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  47821. $output->setDecorated(false);
  47822. }
  47823. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  47824. $input->setInteractive(false);
  47825. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  47826. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  47827. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  47828. $input->setInteractive(false);
  47829. }
  47830. }
  47831. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  47832. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  47833. $input->setInteractive(false);
  47834. } else {
  47835. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  47836. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  47837. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  47838. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  47839. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  47840. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  47841. }
  47842. }
  47843. }
  47844. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  47845. {
  47846. foreach ($command->getHelperSet() as $helper) {
  47847. if ($helper instanceof InputAwareInterface) {
  47848. $helper->setInput($input);
  47849. }
  47850. }
  47851. if (null === $this->dispatcher) {
  47852. return $command->run($input, $output);
  47853. }
  47854. try {
  47855. $command->mergeApplicationDefinition();
  47856. $input->bind($command->getDefinition());
  47857. } catch (ExceptionInterface $e) {
  47858. }
  47859. $event = new ConsoleCommandEvent($command, $input, $output);
  47860. $e = null;
  47861. try {
  47862. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  47863. if ($event->commandShouldRun()) {
  47864. $exitCode = $command->run($input, $output);
  47865. } else {
  47866. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  47867. }
  47868. } catch (\Exception $e) {
  47869. } catch (\Throwable $e) {
  47870. }
  47871. if (null !== $e) {
  47872. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  47873. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  47874. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  47875. if ($x !== $event->getException()) {
  47876. $e = $event->getException();
  47877. }
  47878. $exitCode = $this->getExitCodeForThrowable($e);
  47879. }
  47880. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  47881. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  47882. if (null !== $e) {
  47883. throw $e;
  47884. }
  47885. return $event->getExitCode();
  47886. }
  47887. protected function getCommandName(InputInterface $input)
  47888. {
  47889. return $input->getFirstArgument();
  47890. }
  47891. protected function getDefaultInputDefinition()
  47892. {
  47893. return new InputDefinition(array(
  47894. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  47895. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  47896. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  47897. 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'),
  47898. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  47899. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  47900. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  47901. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  47902. ));
  47903. }
  47904. protected function getDefaultCommands()
  47905. {
  47906. return array(new HelpCommand(), new ListCommand());
  47907. }
  47908. protected function getDefaultHelperSet()
  47909. {
  47910. return new HelperSet(array(
  47911. new FormatterHelper(),
  47912. new DialogHelper(false),
  47913. new ProgressHelper(false),
  47914. new TableHelper(false),
  47915. new DebugFormatterHelper(),
  47916. new ProcessHelper(),
  47917. new QuestionHelper(),
  47918. ));
  47919. }
  47920. private function getSttyColumns()
  47921. {
  47922. if (!\function_exists('proc_open')) {
  47923. return;
  47924. }
  47925. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  47926. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  47927. if (\is_resource($process)) {
  47928. $info = stream_get_contents($pipes[1]);
  47929. fclose($pipes[1]);
  47930. fclose($pipes[2]);
  47931. proc_close($process);
  47932. return $info;
  47933. }
  47934. }
  47935. private function getConsoleMode()
  47936. {
  47937. if (!\function_exists('proc_open')) {
  47938. return;
  47939. }
  47940. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  47941. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  47942. if (\is_resource($process)) {
  47943. $info = stream_get_contents($pipes[1]);
  47944. fclose($pipes[1]);
  47945. fclose($pipes[2]);
  47946. proc_close($process);
  47947. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  47948. return $matches[2].'x'.$matches[1];
  47949. }
  47950. }
  47951. }
  47952. private function getAbbreviationSuggestions($abbrevs)
  47953. {
  47954. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  47955. }
  47956. public function extractNamespace($name, $limit = null)
  47957. {
  47958. $parts = explode(':', $name);
  47959. array_pop($parts);
  47960. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  47961. }
  47962. private function findAlternatives($name, $collection)
  47963. {
  47964. $threshold = 1e3;
  47965. $alternatives = array();
  47966. $collectionParts = array();
  47967. foreach ($collection as $item) {
  47968. $collectionParts[$item] = explode(':', $item);
  47969. }
  47970. foreach (explode(':', $name) as $i => $subname) {
  47971. foreach ($collectionParts as $collectionName => $parts) {
  47972. $exists = isset($alternatives[$collectionName]);
  47973. if (!isset($parts[$i]) && $exists) {
  47974. $alternatives[$collectionName] += $threshold;
  47975. continue;
  47976. } elseif (!isset($parts[$i])) {
  47977. continue;
  47978. }
  47979. $lev = levenshtein($subname, $parts[$i]);
  47980. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  47981. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  47982. } elseif ($exists) {
  47983. $alternatives[$collectionName] += $threshold;
  47984. }
  47985. }
  47986. }
  47987. foreach ($collection as $item) {
  47988. $lev = levenshtein($name, $item);
  47989. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  47990. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  47991. }
  47992. }
  47993. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  47994. asort($alternatives);
  47995. return array_keys($alternatives);
  47996. }
  47997. public function setDefaultCommand($commandName)
  47998. {
  47999. $this->defaultCommand = $commandName;
  48000. }
  48001. private function splitStringByWidth($string, $width)
  48002. {
  48003. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  48004. return str_split($string, $width);
  48005. }
  48006. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  48007. $lines = array();
  48008. $line = '';
  48009. foreach (preg_split('//u', $utf8String) as $char) {
  48010. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  48011. $line .= $char;
  48012. continue;
  48013. }
  48014. $lines[] = str_pad($line, $width);
  48015. $line = $char;
  48016. }
  48017. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  48018. mb_convert_variables($encoding, 'utf8', $lines);
  48019. return $lines;
  48020. }
  48021. private function extractAllNamespaces($name)
  48022. {
  48023. $parts = explode(':', $name, -1);
  48024. $namespaces = array();
  48025. foreach ($parts as $part) {
  48026. if (\count($namespaces)) {
  48027. $namespaces[] = end($namespaces).':'.$part;
  48028. } else {
  48029. $namespaces[] = $part;
  48030. }
  48031. }
  48032. return $namespaces;
  48033. }
  48034. private function init()
  48035. {
  48036. if ($this->initialized) {
  48037. return;
  48038. }
  48039. $this->initialized = true;
  48040. foreach ($this->getDefaultCommands() as $command) {
  48041. $this->add($command);
  48042. }
  48043. }
  48044. private function getExitCodeForThrowable($throwable)
  48045. {
  48046. $exitCode = $throwable->getCode();
  48047. if (is_numeric($exitCode)) {
  48048. $exitCode = (int) $exitCode;
  48049. if (0 === $exitCode) {
  48050. $exitCode = 1;
  48051. }
  48052. } else {
  48053. $exitCode = 1;
  48054. }
  48055. return $exitCode;
  48056. }
  48057. }
  48058. <?php
  48059. namespace Symfony\Component\Console\Command;
  48060. use Symfony\Component\Console\Application;
  48061. use Symfony\Component\Console\Descriptor\TextDescriptor;
  48062. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  48063. use Symfony\Component\Console\Exception\ExceptionInterface;
  48064. use Symfony\Component\Console\Exception\InvalidArgumentException;
  48065. use Symfony\Component\Console\Exception\LogicException;
  48066. use Symfony\Component\Console\Helper\HelperSet;
  48067. use Symfony\Component\Console\Input\InputArgument;
  48068. use Symfony\Component\Console\Input\InputDefinition;
  48069. use Symfony\Component\Console\Input\InputInterface;
  48070. use Symfony\Component\Console\Input\InputOption;
  48071. use Symfony\Component\Console\Output\BufferedOutput;
  48072. use Symfony\Component\Console\Output\OutputInterface;
  48073. class Command
  48074. {
  48075. private $application;
  48076. private $name;
  48077. private $processTitle;
  48078. private $aliases = array();
  48079. private $definition;
  48080. private $help;
  48081. private $description;
  48082. private $ignoreValidationErrors = false;
  48083. private $applicationDefinitionMerged = false;
  48084. private $applicationDefinitionMergedWithArgs = false;
  48085. private $code;
  48086. private $synopsis = array();
  48087. private $usages = array();
  48088. private $helperSet;
  48089. public function __construct($name = null)
  48090. {
  48091. $this->definition = new InputDefinition();
  48092. if (null !== $name) {
  48093. $this->setName($name);
  48094. }
  48095. $this->configure();
  48096. if (!$this->name) {
  48097. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  48098. }
  48099. }
  48100. public function ignoreValidationErrors()
  48101. {
  48102. $this->ignoreValidationErrors = true;
  48103. }
  48104. public function setApplication(Application $application = null)
  48105. {
  48106. $this->application = $application;
  48107. if ($application) {
  48108. $this->setHelperSet($application->getHelperSet());
  48109. } else {
  48110. $this->helperSet = null;
  48111. }
  48112. }
  48113. public function setHelperSet(HelperSet $helperSet)
  48114. {
  48115. $this->helperSet = $helperSet;
  48116. }
  48117. public function getHelperSet()
  48118. {
  48119. return $this->helperSet;
  48120. }
  48121. public function getApplication()
  48122. {
  48123. return $this->application;
  48124. }
  48125. public function isEnabled()
  48126. {
  48127. return true;
  48128. }
  48129. protected function configure()
  48130. {
  48131. }
  48132. protected function execute(InputInterface $input, OutputInterface $output)
  48133. {
  48134. throw new LogicException('You must override the execute() method in the concrete command class.');
  48135. }
  48136. protected function interact(InputInterface $input, OutputInterface $output)
  48137. {
  48138. }
  48139. protected function initialize(InputInterface $input, OutputInterface $output)
  48140. {
  48141. }
  48142. public function run(InputInterface $input, OutputInterface $output)
  48143. {
  48144. $this->getSynopsis(true);
  48145. $this->getSynopsis(false);
  48146. $this->mergeApplicationDefinition();
  48147. try {
  48148. $input->bind($this->definition);
  48149. } catch (ExceptionInterface $e) {
  48150. if (!$this->ignoreValidationErrors) {
  48151. throw $e;
  48152. }
  48153. }
  48154. $this->initialize($input, $output);
  48155. if (null !== $this->processTitle) {
  48156. if (\function_exists('cli_set_process_title')) {
  48157. if (!@cli_set_process_title($this->processTitle)) {
  48158. if ('Darwin' === PHP_OS) {
  48159. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  48160. } else {
  48161. cli_set_process_title($this->processTitle);
  48162. }
  48163. }
  48164. } elseif (\function_exists('setproctitle')) {
  48165. setproctitle($this->processTitle);
  48166. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  48167. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  48168. }
  48169. }
  48170. if ($input->isInteractive()) {
  48171. $this->interact($input, $output);
  48172. }
  48173. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  48174. $input->setArgument('command', $this->getName());
  48175. }
  48176. $input->validate();
  48177. if ($this->code) {
  48178. $statusCode = \call_user_func($this->code, $input, $output);
  48179. } else {
  48180. $statusCode = $this->execute($input, $output);
  48181. }
  48182. return is_numeric($statusCode) ? (int) $statusCode : 0;
  48183. }
  48184. public function setCode($code)
  48185. {
  48186. if (!\is_callable($code)) {
  48187. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  48188. }
  48189. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  48190. $r = new \ReflectionFunction($code);
  48191. if (null === $r->getClosureThis()) {
  48192. if (\PHP_VERSION_ID < 70000) {
  48193. $code = @\Closure::bind($code, $this);
  48194. } else {
  48195. $code = \Closure::bind($code, $this);
  48196. }
  48197. }
  48198. }
  48199. $this->code = $code;
  48200. return $this;
  48201. }
  48202. public function mergeApplicationDefinition($mergeArgs = true)
  48203. {
  48204. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  48205. return;
  48206. }
  48207. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  48208. $this->applicationDefinitionMerged = true;
  48209. if ($mergeArgs) {
  48210. $currentArguments = $this->definition->getArguments();
  48211. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  48212. $this->definition->addArguments($currentArguments);
  48213. $this->applicationDefinitionMergedWithArgs = true;
  48214. }
  48215. }
  48216. public function setDefinition($definition)
  48217. {
  48218. if ($definition instanceof InputDefinition) {
  48219. $this->definition = $definition;
  48220. } else {
  48221. $this->definition->setDefinition($definition);
  48222. }
  48223. $this->applicationDefinitionMerged = false;
  48224. return $this;
  48225. }
  48226. public function getDefinition()
  48227. {
  48228. return $this->definition;
  48229. }
  48230. public function getNativeDefinition()
  48231. {
  48232. return $this->getDefinition();
  48233. }
  48234. public function addArgument($name, $mode = null, $description = '', $default = null)
  48235. {
  48236. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  48237. return $this;
  48238. }
  48239. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  48240. {
  48241. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  48242. return $this;
  48243. }
  48244. public function setName($name)
  48245. {
  48246. $this->validateName($name);
  48247. $this->name = $name;
  48248. return $this;
  48249. }
  48250. public function setProcessTitle($title)
  48251. {
  48252. $this->processTitle = $title;
  48253. return $this;
  48254. }
  48255. public function getName()
  48256. {
  48257. return $this->name;
  48258. }
  48259. public function setDescription($description)
  48260. {
  48261. $this->description = $description;
  48262. return $this;
  48263. }
  48264. public function getDescription()
  48265. {
  48266. return $this->description;
  48267. }
  48268. public function setHelp($help)
  48269. {
  48270. $this->help = $help;
  48271. return $this;
  48272. }
  48273. public function getHelp()
  48274. {
  48275. return $this->help;
  48276. }
  48277. public function getProcessedHelp()
  48278. {
  48279. $name = $this->name;
  48280. $placeholders = array(
  48281. '%command.name%',
  48282. '%command.full_name%',
  48283. );
  48284. $replacements = array(
  48285. $name,
  48286. $_SERVER['PHP_SELF'].' '.$name,
  48287. );
  48288. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  48289. }
  48290. public function setAliases($aliases)
  48291. {
  48292. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  48293. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  48294. }
  48295. foreach ($aliases as $alias) {
  48296. $this->validateName($alias);
  48297. }
  48298. $this->aliases = $aliases;
  48299. return $this;
  48300. }
  48301. public function getAliases()
  48302. {
  48303. return $this->aliases;
  48304. }
  48305. public function getSynopsis($short = false)
  48306. {
  48307. $key = $short ? 'short' : 'long';
  48308. if (!isset($this->synopsis[$key])) {
  48309. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  48310. }
  48311. return $this->synopsis[$key];
  48312. }
  48313. public function addUsage($usage)
  48314. {
  48315. if (0 !== strpos($usage, $this->name)) {
  48316. $usage = sprintf('%s %s', $this->name, $usage);
  48317. }
  48318. $this->usages[] = $usage;
  48319. return $this;
  48320. }
  48321. public function getUsages()
  48322. {
  48323. return $this->usages;
  48324. }
  48325. public function getHelper($name)
  48326. {
  48327. if (null === $this->helperSet) {
  48328. 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));
  48329. }
  48330. return $this->helperSet->get($name);
  48331. }
  48332. public function asText()
  48333. {
  48334. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48335. $descriptor = new TextDescriptor();
  48336. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  48337. $descriptor->describe($output, $this, array('raw_output' => true));
  48338. return $output->fetch();
  48339. }
  48340. public function asXml($asDom = false)
  48341. {
  48342. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48343. $descriptor = new XmlDescriptor();
  48344. if ($asDom) {
  48345. return $descriptor->getCommandDocument($this);
  48346. }
  48347. $output = new BufferedOutput();
  48348. $descriptor->describe($output, $this);
  48349. return $output->fetch();
  48350. }
  48351. private function validateName($name)
  48352. {
  48353. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  48354. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  48355. }
  48356. }
  48357. }
  48358. <?php
  48359. namespace Symfony\Component\Console\Command;
  48360. use Symfony\Component\Console\Helper\DescriptorHelper;
  48361. use Symfony\Component\Console\Input\InputArgument;
  48362. use Symfony\Component\Console\Input\InputInterface;
  48363. use Symfony\Component\Console\Input\InputOption;
  48364. use Symfony\Component\Console\Output\OutputInterface;
  48365. class HelpCommand extends Command
  48366. {
  48367. private $command;
  48368. protected function configure()
  48369. {
  48370. $this->ignoreValidationErrors();
  48371. $this
  48372. ->setName('help')
  48373. ->setDefinition(array(
  48374. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  48375. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  48376. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  48377. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  48378. ))
  48379. ->setDescription('Displays help for a command')
  48380. ->setHelp(<<<'EOF'
  48381. The <info>%command.name%</info> command displays help for a given command:
  48382. <info>php %command.full_name% list</info>
  48383. You can also output the help in other formats by using the <comment>--format</comment> option:
  48384. <info>php %command.full_name% --format=xml list</info>
  48385. To display the list of available commands, please use the <info>list</info> command.
  48386. EOF
  48387. )
  48388. ;
  48389. }
  48390. public function setCommand(Command $command)
  48391. {
  48392. $this->command = $command;
  48393. }
  48394. protected function execute(InputInterface $input, OutputInterface $output)
  48395. {
  48396. if (null === $this->command) {
  48397. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  48398. }
  48399. if ($input->getOption('xml')) {
  48400. @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);
  48401. $input->setOption('format', 'xml');
  48402. }
  48403. $helper = new DescriptorHelper();
  48404. $helper->describe($output, $this->command, array(
  48405. 'format' => $input->getOption('format'),
  48406. 'raw_text' => $input->getOption('raw'),
  48407. ));
  48408. $this->command = null;
  48409. }
  48410. }
  48411. <?php
  48412. namespace Symfony\Component\Console\Command;
  48413. use Symfony\Component\Console\Helper\DescriptorHelper;
  48414. use Symfony\Component\Console\Input\InputArgument;
  48415. use Symfony\Component\Console\Input\InputDefinition;
  48416. use Symfony\Component\Console\Input\InputInterface;
  48417. use Symfony\Component\Console\Input\InputOption;
  48418. use Symfony\Component\Console\Output\OutputInterface;
  48419. class ListCommand extends Command
  48420. {
  48421. protected function configure()
  48422. {
  48423. $this
  48424. ->setName('list')
  48425. ->setDefinition($this->createDefinition())
  48426. ->setDescription('Lists commands')
  48427. ->setHelp(<<<'EOF'
  48428. The <info>%command.name%</info> command lists all commands:
  48429. <info>php %command.full_name%</info>
  48430. You can also display the commands for a specific namespace:
  48431. <info>php %command.full_name% test</info>
  48432. You can also output the information in other formats by using the <comment>--format</comment> option:
  48433. <info>php %command.full_name% --format=xml</info>
  48434. It's also possible to get raw list of commands (useful for embedding command runner):
  48435. <info>php %command.full_name% --raw</info>
  48436. EOF
  48437. )
  48438. ;
  48439. }
  48440. public function getNativeDefinition()
  48441. {
  48442. return $this->createDefinition();
  48443. }
  48444. protected function execute(InputInterface $input, OutputInterface $output)
  48445. {
  48446. if ($input->getOption('xml')) {
  48447. @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);
  48448. $input->setOption('format', 'xml');
  48449. }
  48450. $helper = new DescriptorHelper();
  48451. $helper->describe($output, $this->getApplication(), array(
  48452. 'format' => $input->getOption('format'),
  48453. 'raw_text' => $input->getOption('raw'),
  48454. 'namespace' => $input->getArgument('namespace'),
  48455. ));
  48456. }
  48457. private function createDefinition()
  48458. {
  48459. return new InputDefinition(array(
  48460. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  48461. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  48462. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  48463. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  48464. ));
  48465. }
  48466. }
  48467. <?php
  48468. namespace Symfony\Component\Console;
  48469. final class ConsoleEvents
  48470. {
  48471. const COMMAND = 'console.command';
  48472. const TERMINATE = 'console.terminate';
  48473. const EXCEPTION = 'console.exception';
  48474. }
  48475. <?php
  48476. namespace Symfony\Component\Console\Descriptor;
  48477. use Symfony\Component\Console\Application;
  48478. use Symfony\Component\Console\Command\Command;
  48479. use Symfony\Component\Console\Exception\CommandNotFoundException;
  48480. class ApplicationDescription
  48481. {
  48482. const GLOBAL_NAMESPACE = '_global';
  48483. private $application;
  48484. private $namespace;
  48485. private $namespaces;
  48486. private $commands;
  48487. private $aliases;
  48488. public function __construct(Application $application, $namespace = null)
  48489. {
  48490. $this->application = $application;
  48491. $this->namespace = $namespace;
  48492. }
  48493. public function getNamespaces()
  48494. {
  48495. if (null === $this->namespaces) {
  48496. $this->inspectApplication();
  48497. }
  48498. return $this->namespaces;
  48499. }
  48500. public function getCommands()
  48501. {
  48502. if (null === $this->commands) {
  48503. $this->inspectApplication();
  48504. }
  48505. return $this->commands;
  48506. }
  48507. public function getCommand($name)
  48508. {
  48509. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  48510. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  48511. }
  48512. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  48513. }
  48514. private function inspectApplication()
  48515. {
  48516. $this->commands = array();
  48517. $this->namespaces = array();
  48518. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  48519. foreach ($this->sortCommands($all) as $namespace => $commands) {
  48520. $names = array();
  48521. foreach ($commands as $name => $command) {
  48522. if (!$command->getName()) {
  48523. continue;
  48524. }
  48525. if ($command->getName() === $name) {
  48526. $this->commands[$name] = $command;
  48527. } else {
  48528. $this->aliases[$name] = $command;
  48529. }
  48530. $names[] = $name;
  48531. }
  48532. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  48533. }
  48534. }
  48535. private function sortCommands(array $commands)
  48536. {
  48537. $namespacedCommands = array();
  48538. $globalCommands = array();
  48539. foreach ($commands as $name => $command) {
  48540. $key = $this->application->extractNamespace($name, 1);
  48541. if (!$key) {
  48542. $globalCommands['_global'][$name] = $command;
  48543. } else {
  48544. $namespacedCommands[$key][$name] = $command;
  48545. }
  48546. }
  48547. ksort($namespacedCommands);
  48548. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  48549. foreach ($namespacedCommands as &$commandsSet) {
  48550. ksort($commandsSet);
  48551. }
  48552. unset($commandsSet);
  48553. return $namespacedCommands;
  48554. }
  48555. }
  48556. <?php
  48557. namespace Symfony\Component\Console\Descriptor;
  48558. use Symfony\Component\Console\Application;
  48559. use Symfony\Component\Console\Command\Command;
  48560. use Symfony\Component\Console\Exception\InvalidArgumentException;
  48561. use Symfony\Component\Console\Input\InputArgument;
  48562. use Symfony\Component\Console\Input\InputDefinition;
  48563. use Symfony\Component\Console\Input\InputOption;
  48564. use Symfony\Component\Console\Output\OutputInterface;
  48565. abstract class Descriptor implements DescriptorInterface
  48566. {
  48567. private $output;
  48568. public function describe(OutputInterface $output, $object, array $options = array())
  48569. {
  48570. $this->output = $output;
  48571. switch (true) {
  48572. case $object instanceof InputArgument:
  48573. $this->describeInputArgument($object, $options);
  48574. break;
  48575. case $object instanceof InputOption:
  48576. $this->describeInputOption($object, $options);
  48577. break;
  48578. case $object instanceof InputDefinition:
  48579. $this->describeInputDefinition($object, $options);
  48580. break;
  48581. case $object instanceof Command:
  48582. $this->describeCommand($object, $options);
  48583. break;
  48584. case $object instanceof Application:
  48585. $this->describeApplication($object, $options);
  48586. break;
  48587. default:
  48588. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  48589. }
  48590. }
  48591. protected function write($content, $decorated = false)
  48592. {
  48593. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  48594. }
  48595. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  48596. abstract protected function describeInputOption(InputOption $option, array $options = array());
  48597. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  48598. abstract protected function describeCommand(Command $command, array $options = array());
  48599. abstract protected function describeApplication(Application $application, array $options = array());
  48600. }
  48601. <?php
  48602. namespace Symfony\Component\Console\Descriptor;
  48603. use Symfony\Component\Console\Output\OutputInterface;
  48604. interface DescriptorInterface
  48605. {
  48606. public function describe(OutputInterface $output, $object, array $options = array());
  48607. }
  48608. <?php
  48609. namespace Symfony\Component\Console\Descriptor;
  48610. use Symfony\Component\Console\Application;
  48611. use Symfony\Component\Console\Command\Command;
  48612. use Symfony\Component\Console\Input\InputArgument;
  48613. use Symfony\Component\Console\Input\InputDefinition;
  48614. use Symfony\Component\Console\Input\InputOption;
  48615. class JsonDescriptor extends Descriptor
  48616. {
  48617. protected function describeInputArgument(InputArgument $argument, array $options = array())
  48618. {
  48619. $this->writeData($this->getInputArgumentData($argument), $options);
  48620. }
  48621. protected function describeInputOption(InputOption $option, array $options = array())
  48622. {
  48623. $this->writeData($this->getInputOptionData($option), $options);
  48624. }
  48625. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  48626. {
  48627. $this->writeData($this->getInputDefinitionData($definition), $options);
  48628. }
  48629. protected function describeCommand(Command $command, array $options = array())
  48630. {
  48631. $this->writeData($this->getCommandData($command), $options);
  48632. }
  48633. protected function describeApplication(Application $application, array $options = array())
  48634. {
  48635. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  48636. $description = new ApplicationDescription($application, $describedNamespace);
  48637. $commands = array();
  48638. foreach ($description->getCommands() as $command) {
  48639. $commands[] = $this->getCommandData($command);
  48640. }
  48641. $data = $describedNamespace
  48642. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  48643. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  48644. $this->writeData($data, $options);
  48645. }
  48646. private function writeData(array $data, array $options)
  48647. {
  48648. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  48649. }
  48650. private function getInputArgumentData(InputArgument $argument)
  48651. {
  48652. return array(
  48653. 'name' => $argument->getName(),
  48654. 'is_required' => $argument->isRequired(),
  48655. 'is_array' => $argument->isArray(),
  48656. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  48657. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  48658. );
  48659. }
  48660. private function getInputOptionData(InputOption $option)
  48661. {
  48662. return array(
  48663. 'name' => '--'.$option->getName(),
  48664. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  48665. 'accept_value' => $option->acceptValue(),
  48666. 'is_value_required' => $option->isValueRequired(),
  48667. 'is_multiple' => $option->isArray(),
  48668. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  48669. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  48670. );
  48671. }
  48672. private function getInputDefinitionData(InputDefinition $definition)
  48673. {
  48674. $inputArguments = array();
  48675. foreach ($definition->getArguments() as $name => $argument) {
  48676. $inputArguments[$name] = $this->getInputArgumentData($argument);
  48677. }
  48678. $inputOptions = array();
  48679. foreach ($definition->getOptions() as $name => $option) {
  48680. $inputOptions[$name] = $this->getInputOptionData($option);
  48681. }
  48682. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  48683. }
  48684. private function getCommandData(Command $command)
  48685. {
  48686. $command->getSynopsis();
  48687. $command->mergeApplicationDefinition(false);
  48688. return array(
  48689. 'name' => $command->getName(),
  48690. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  48691. 'description' => $command->getDescription(),
  48692. 'help' => $command->getProcessedHelp(),
  48693. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  48694. );
  48695. }
  48696. }
  48697. <?php
  48698. namespace Symfony\Component\Console\Descriptor;
  48699. use Symfony\Component\Console\Application;
  48700. use Symfony\Component\Console\Command\Command;
  48701. use Symfony\Component\Console\Helper\Helper;
  48702. use Symfony\Component\Console\Input\InputArgument;
  48703. use Symfony\Component\Console\Input\InputDefinition;
  48704. use Symfony\Component\Console\Input\InputOption;
  48705. class MarkdownDescriptor extends Descriptor
  48706. {
  48707. protected function describeInputArgument(InputArgument $argument, array $options = array())
  48708. {
  48709. $this->write(
  48710. '**'.$argument->getName().':**'."\n\n"
  48711. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  48712. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  48713. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  48714. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  48715. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  48716. );
  48717. }
  48718. protected function describeInputOption(InputOption $option, array $options = array())
  48719. {
  48720. $this->write(
  48721. '**'.$option->getName().':**'."\n\n"
  48722. .'* Name: `--'.$option->getName().'`'."\n"
  48723. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  48724. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  48725. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  48726. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  48727. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  48728. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  48729. );
  48730. }
  48731. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  48732. {
  48733. if ($showArguments = \count($definition->getArguments()) > 0) {
  48734. $this->write('### Arguments:');
  48735. foreach ($definition->getArguments() as $argument) {
  48736. $this->write("\n\n");
  48737. $this->write($this->describeInputArgument($argument));
  48738. }
  48739. }
  48740. if (\count($definition->getOptions()) > 0) {
  48741. if ($showArguments) {
  48742. $this->write("\n\n");
  48743. }
  48744. $this->write('### Options:');
  48745. foreach ($definition->getOptions() as $option) {
  48746. $this->write("\n\n");
  48747. $this->write($this->describeInputOption($option));
  48748. }
  48749. }
  48750. }
  48751. protected function describeCommand(Command $command, array $options = array())
  48752. {
  48753. $command->getSynopsis();
  48754. $command->mergeApplicationDefinition(false);
  48755. $this->write(
  48756. $command->getName()."\n"
  48757. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  48758. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  48759. .'* Usage:'."\n\n"
  48760. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  48761. return $carry.' * `'.$usage.'`'."\n";
  48762. })
  48763. );
  48764. if ($help = $command->getProcessedHelp()) {
  48765. $this->write("\n");
  48766. $this->write($help);
  48767. }
  48768. if ($command->getNativeDefinition()) {
  48769. $this->write("\n\n");
  48770. $this->describeInputDefinition($command->getNativeDefinition());
  48771. }
  48772. }
  48773. protected function describeApplication(Application $application, array $options = array())
  48774. {
  48775. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  48776. $description = new ApplicationDescription($application, $describedNamespace);
  48777. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  48778. foreach ($description->getNamespaces() as $namespace) {
  48779. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  48780. $this->write("\n\n");
  48781. $this->write('**'.$namespace['id'].':**');
  48782. }
  48783. $this->write("\n\n");
  48784. $this->write(implode("\n", array_map(function ($commandName) {
  48785. return '* '.$commandName;
  48786. }, $namespace['commands'])));
  48787. }
  48788. foreach ($description->getCommands() as $command) {
  48789. $this->write("\n\n");
  48790. $this->write($this->describeCommand($command));
  48791. }
  48792. }
  48793. }
  48794. <?php
  48795. namespace Symfony\Component\Console\Descriptor;
  48796. use Symfony\Component\Console\Application;
  48797. use Symfony\Component\Console\Command\Command;
  48798. use Symfony\Component\Console\Formatter\OutputFormatter;
  48799. use Symfony\Component\Console\Helper\Helper;
  48800. use Symfony\Component\Console\Input\InputArgument;
  48801. use Symfony\Component\Console\Input\InputDefinition;
  48802. use Symfony\Component\Console\Input\InputOption;
  48803. class TextDescriptor extends Descriptor
  48804. {
  48805. protected function describeInputArgument(InputArgument $argument, array $options = array())
  48806. {
  48807. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  48808. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  48809. } else {
  48810. $default = '';
  48811. }
  48812. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  48813. $spacingWidth = $totalWidth - \strlen($argument->getName());
  48814. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  48815. $argument->getName(),
  48816. str_repeat(' ', $spacingWidth),
  48817. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  48818. $default
  48819. ), $options);
  48820. }
  48821. protected function describeInputOption(InputOption $option, array $options = array())
  48822. {
  48823. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  48824. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  48825. } else {
  48826. $default = '';
  48827. }
  48828. $value = '';
  48829. if ($option->acceptValue()) {
  48830. $value = '='.strtoupper($option->getName());
  48831. if ($option->isValueOptional()) {
  48832. $value = '['.$value.']';
  48833. }
  48834. }
  48835. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  48836. $synopsis = sprintf('%s%s',
  48837. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  48838. sprintf('--%s%s', $option->getName(), $value)
  48839. );
  48840. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  48841. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  48842. $synopsis,
  48843. str_repeat(' ', $spacingWidth),
  48844. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  48845. $default,
  48846. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  48847. ), $options);
  48848. }
  48849. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  48850. {
  48851. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  48852. foreach ($definition->getArguments() as $argument) {
  48853. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  48854. }
  48855. if ($definition->getArguments()) {
  48856. $this->writeText('<comment>Arguments:</comment>', $options);
  48857. $this->writeText("\n");
  48858. foreach ($definition->getArguments() as $argument) {
  48859. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  48860. $this->writeText("\n");
  48861. }
  48862. }
  48863. if ($definition->getArguments() && $definition->getOptions()) {
  48864. $this->writeText("\n");
  48865. }
  48866. if ($definition->getOptions()) {
  48867. $laterOptions = array();
  48868. $this->writeText('<comment>Options:</comment>', $options);
  48869. foreach ($definition->getOptions() as $option) {
  48870. if (\strlen($option->getShortcut()) > 1) {
  48871. $laterOptions[] = $option;
  48872. continue;
  48873. }
  48874. $this->writeText("\n");
  48875. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  48876. }
  48877. foreach ($laterOptions as $option) {
  48878. $this->writeText("\n");
  48879. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  48880. }
  48881. }
  48882. }
  48883. protected function describeCommand(Command $command, array $options = array())
  48884. {
  48885. $command->getSynopsis(true);
  48886. $command->getSynopsis(false);
  48887. $command->mergeApplicationDefinition(false);
  48888. $this->writeText('<comment>Usage:</comment>', $options);
  48889. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  48890. $this->writeText("\n");
  48891. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  48892. }
  48893. $this->writeText("\n");
  48894. $definition = $command->getNativeDefinition();
  48895. if ($definition->getOptions() || $definition->getArguments()) {
  48896. $this->writeText("\n");
  48897. $this->describeInputDefinition($definition, $options);
  48898. $this->writeText("\n");
  48899. }
  48900. if ($help = $command->getProcessedHelp()) {
  48901. $this->writeText("\n");
  48902. $this->writeText('<comment>Help:</comment>', $options);
  48903. $this->writeText("\n");
  48904. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  48905. $this->writeText("\n");
  48906. }
  48907. }
  48908. protected function describeApplication(Application $application, array $options = array())
  48909. {
  48910. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  48911. $description = new ApplicationDescription($application, $describedNamespace);
  48912. if (isset($options['raw_text']) && $options['raw_text']) {
  48913. $width = $this->getColumnWidth($description->getCommands());
  48914. foreach ($description->getCommands() as $command) {
  48915. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  48916. $this->writeText("\n");
  48917. }
  48918. } else {
  48919. if ('' != $help = $application->getHelp()) {
  48920. $this->writeText("$help\n\n", $options);
  48921. }
  48922. $this->writeText("<comment>Usage:</comment>\n", $options);
  48923. $this->writeText(" command [options] [arguments]\n\n", $options);
  48924. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  48925. $this->writeText("\n");
  48926. $this->writeText("\n");
  48927. $width = $this->getColumnWidth($description->getCommands());
  48928. if ($describedNamespace) {
  48929. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  48930. } else {
  48931. $this->writeText('<comment>Available commands:</comment>', $options);
  48932. }
  48933. foreach ($description->getNamespaces() as $namespace) {
  48934. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  48935. $this->writeText("\n");
  48936. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  48937. }
  48938. foreach ($namespace['commands'] as $name) {
  48939. $this->writeText("\n");
  48940. $spacingWidth = $width - Helper::strlen($name);
  48941. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  48942. }
  48943. }
  48944. $this->writeText("\n");
  48945. }
  48946. }
  48947. private function writeText($content, array $options = array())
  48948. {
  48949. $this->write(
  48950. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  48951. isset($options['raw_output']) ? !$options['raw_output'] : true
  48952. );
  48953. }
  48954. private function formatDefaultValue($default)
  48955. {
  48956. if (INF === $default) {
  48957. return 'INF';
  48958. }
  48959. if (\is_string($default)) {
  48960. $default = OutputFormatter::escape($default);
  48961. } elseif (\is_array($default)) {
  48962. foreach ($default as $key => $value) {
  48963. if (\is_string($value)) {
  48964. $default[$key] = OutputFormatter::escape($value);
  48965. }
  48966. }
  48967. }
  48968. if (\PHP_VERSION_ID < 50400) {
  48969. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  48970. }
  48971. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  48972. }
  48973. private function getColumnWidth(array $commands)
  48974. {
  48975. $widths = array();
  48976. foreach ($commands as $command) {
  48977. $widths[] = Helper::strlen($command->getName());
  48978. foreach ($command->getAliases() as $alias) {
  48979. $widths[] = Helper::strlen($alias);
  48980. }
  48981. }
  48982. return max($widths) + 2;
  48983. }
  48984. private function calculateTotalWidthForOptions(array $options)
  48985. {
  48986. $totalWidth = 0;
  48987. foreach ($options as $option) {
  48988. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  48989. if ($option->acceptValue()) {
  48990. $valueLength = 1 + Helper::strlen($option->getName());
  48991. $valueLength += $option->isValueOptional() ? 2 : 0;
  48992. $nameLength += $valueLength;
  48993. }
  48994. $totalWidth = max($totalWidth, $nameLength);
  48995. }
  48996. return $totalWidth;
  48997. }
  48998. }
  48999. <?php
  49000. namespace Symfony\Component\Console\Descriptor;
  49001. use Symfony\Component\Console\Application;
  49002. use Symfony\Component\Console\Command\Command;
  49003. use Symfony\Component\Console\Input\InputArgument;
  49004. use Symfony\Component\Console\Input\InputDefinition;
  49005. use Symfony\Component\Console\Input\InputOption;
  49006. class XmlDescriptor extends Descriptor
  49007. {
  49008. public function getInputDefinitionDocument(InputDefinition $definition)
  49009. {
  49010. $dom = new \DOMDocument('1.0', 'UTF-8');
  49011. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  49012. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  49013. foreach ($definition->getArguments() as $argument) {
  49014. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  49015. }
  49016. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  49017. foreach ($definition->getOptions() as $option) {
  49018. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  49019. }
  49020. return $dom;
  49021. }
  49022. public function getCommandDocument(Command $command)
  49023. {
  49024. $dom = new \DOMDocument('1.0', 'UTF-8');
  49025. $dom->appendChild($commandXML = $dom->createElement('command'));
  49026. $command->getSynopsis();
  49027. $command->mergeApplicationDefinition(false);
  49028. $commandXML->setAttribute('id', $command->getName());
  49029. $commandXML->setAttribute('name', $command->getName());
  49030. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  49031. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  49032. $usagesXML->appendChild($dom->createElement('usage', $usage));
  49033. }
  49034. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  49035. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  49036. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  49037. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  49038. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  49039. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  49040. return $dom;
  49041. }
  49042. public function getApplicationDocument(Application $application, $namespace = null)
  49043. {
  49044. $dom = new \DOMDocument('1.0', 'UTF-8');
  49045. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  49046. if ('UNKNOWN' !== $application->getName()) {
  49047. $rootXml->setAttribute('name', $application->getName());
  49048. if ('UNKNOWN' !== $application->getVersion()) {
  49049. $rootXml->setAttribute('version', $application->getVersion());
  49050. }
  49051. }
  49052. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  49053. $description = new ApplicationDescription($application, $namespace);
  49054. if ($namespace) {
  49055. $commandsXML->setAttribute('namespace', $namespace);
  49056. }
  49057. foreach ($description->getCommands() as $command) {
  49058. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  49059. }
  49060. if (!$namespace) {
  49061. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  49062. foreach ($description->getNamespaces() as $namespaceDescription) {
  49063. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  49064. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  49065. foreach ($namespaceDescription['commands'] as $name) {
  49066. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  49067. $commandXML->appendChild($dom->createTextNode($name));
  49068. }
  49069. }
  49070. }
  49071. return $dom;
  49072. }
  49073. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49074. {
  49075. $this->writeDocument($this->getInputArgumentDocument($argument));
  49076. }
  49077. protected function describeInputOption(InputOption $option, array $options = array())
  49078. {
  49079. $this->writeDocument($this->getInputOptionDocument($option));
  49080. }
  49081. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49082. {
  49083. $this->writeDocument($this->getInputDefinitionDocument($definition));
  49084. }
  49085. protected function describeCommand(Command $command, array $options = array())
  49086. {
  49087. $this->writeDocument($this->getCommandDocument($command));
  49088. }
  49089. protected function describeApplication(Application $application, array $options = array())
  49090. {
  49091. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  49092. }
  49093. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  49094. {
  49095. foreach ($importedParent->childNodes as $childNode) {
  49096. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  49097. }
  49098. }
  49099. private function writeDocument(\DOMDocument $dom)
  49100. {
  49101. $dom->formatOutput = true;
  49102. $this->write($dom->saveXML());
  49103. }
  49104. private function getInputArgumentDocument(InputArgument $argument)
  49105. {
  49106. $dom = new \DOMDocument('1.0', 'UTF-8');
  49107. $dom->appendChild($objectXML = $dom->createElement('argument'));
  49108. $objectXML->setAttribute('name', $argument->getName());
  49109. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  49110. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  49111. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49112. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  49113. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49114. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  49115. foreach ($defaults as $default) {
  49116. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49117. $defaultXML->appendChild($dom->createTextNode($default));
  49118. }
  49119. return $dom;
  49120. }
  49121. private function getInputOptionDocument(InputOption $option)
  49122. {
  49123. $dom = new \DOMDocument('1.0', 'UTF-8');
  49124. $dom->appendChild($objectXML = $dom->createElement('option'));
  49125. $objectXML->setAttribute('name', '--'.$option->getName());
  49126. $pos = strpos($option->getShortcut(), '|');
  49127. if (false !== $pos) {
  49128. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  49129. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  49130. } else {
  49131. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  49132. }
  49133. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  49134. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  49135. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  49136. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49137. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  49138. if ($option->acceptValue()) {
  49139. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  49140. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49141. if (!empty($defaults)) {
  49142. foreach ($defaults as $default) {
  49143. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49144. $defaultXML->appendChild($dom->createTextNode($default));
  49145. }
  49146. }
  49147. }
  49148. return $dom;
  49149. }
  49150. }
  49151. <?php
  49152. namespace Symfony\Component\Console\Event;
  49153. class ConsoleCommandEvent extends ConsoleEvent
  49154. {
  49155. const RETURN_CODE_DISABLED = 113;
  49156. private $commandShouldRun = true;
  49157. public function disableCommand()
  49158. {
  49159. return $this->commandShouldRun = false;
  49160. }
  49161. public function enableCommand()
  49162. {
  49163. return $this->commandShouldRun = true;
  49164. }
  49165. public function commandShouldRun()
  49166. {
  49167. return $this->commandShouldRun;
  49168. }
  49169. }
  49170. <?php
  49171. namespace Symfony\Component\Console\Event;
  49172. use Symfony\Component\Console\Command\Command;
  49173. use Symfony\Component\Console\Input\InputInterface;
  49174. use Symfony\Component\Console\Output\OutputInterface;
  49175. use Symfony\Component\EventDispatcher\Event;
  49176. class ConsoleEvent extends Event
  49177. {
  49178. protected $command;
  49179. private $input;
  49180. private $output;
  49181. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  49182. {
  49183. $this->command = $command;
  49184. $this->input = $input;
  49185. $this->output = $output;
  49186. }
  49187. public function getCommand()
  49188. {
  49189. return $this->command;
  49190. }
  49191. public function getInput()
  49192. {
  49193. return $this->input;
  49194. }
  49195. public function getOutput()
  49196. {
  49197. return $this->output;
  49198. }
  49199. }
  49200. <?php
  49201. namespace Symfony\Component\Console\Event;
  49202. use Symfony\Component\Console\Command\Command;
  49203. use Symfony\Component\Console\Input\InputInterface;
  49204. use Symfony\Component\Console\Output\OutputInterface;
  49205. class ConsoleExceptionEvent extends ConsoleEvent
  49206. {
  49207. private $exception;
  49208. private $exitCode;
  49209. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  49210. {
  49211. parent::__construct($command, $input, $output);
  49212. $this->setException($exception);
  49213. $this->exitCode = (int) $exitCode;
  49214. }
  49215. public function getException()
  49216. {
  49217. return $this->exception;
  49218. }
  49219. public function setException(\Exception $exception)
  49220. {
  49221. $this->exception = $exception;
  49222. }
  49223. public function getExitCode()
  49224. {
  49225. return $this->exitCode;
  49226. }
  49227. }
  49228. <?php
  49229. namespace Symfony\Component\Console\Event;
  49230. use Symfony\Component\Console\Command\Command;
  49231. use Symfony\Component\Console\Input\InputInterface;
  49232. use Symfony\Component\Console\Output\OutputInterface;
  49233. class ConsoleTerminateEvent extends ConsoleEvent
  49234. {
  49235. private $exitCode;
  49236. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  49237. {
  49238. parent::__construct($command, $input, $output);
  49239. $this->setExitCode($exitCode);
  49240. }
  49241. public function setExitCode($exitCode)
  49242. {
  49243. $this->exitCode = (int) $exitCode;
  49244. }
  49245. public function getExitCode()
  49246. {
  49247. return $this->exitCode;
  49248. }
  49249. }
  49250. <?php
  49251. namespace Symfony\Component\Console\Exception;
  49252. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  49253. {
  49254. private $alternatives;
  49255. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  49256. {
  49257. parent::__construct($message, $code, $previous);
  49258. $this->alternatives = $alternatives;
  49259. }
  49260. public function getAlternatives()
  49261. {
  49262. return $this->alternatives;
  49263. }
  49264. }
  49265. <?php
  49266. namespace Symfony\Component\Console\Exception;
  49267. interface ExceptionInterface
  49268. {
  49269. }
  49270. <?php
  49271. namespace Symfony\Component\Console\Exception;
  49272. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  49273. {
  49274. }
  49275. <?php
  49276. namespace Symfony\Component\Console\Exception;
  49277. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  49278. {
  49279. }
  49280. <?php
  49281. namespace Symfony\Component\Console\Exception;
  49282. class LogicException extends \LogicException implements ExceptionInterface
  49283. {
  49284. }
  49285. <?php
  49286. namespace Symfony\Component\Console\Exception;
  49287. class RuntimeException extends \RuntimeException implements ExceptionInterface
  49288. {
  49289. }
  49290. <?php
  49291. namespace Symfony\Component\Console\Formatter;
  49292. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49293. class OutputFormatter implements OutputFormatterInterface
  49294. {
  49295. private $decorated;
  49296. private $styles = array();
  49297. private $styleStack;
  49298. public static function escape($text)
  49299. {
  49300. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  49301. return self::escapeTrailingBackslash($text);
  49302. }
  49303. public static function escapeTrailingBackslash($text)
  49304. {
  49305. if ('\\' === substr($text, -1)) {
  49306. $len = \strlen($text);
  49307. $text = rtrim($text, '\\');
  49308. $text = str_replace("\0", '', $text);
  49309. $text .= str_repeat("\0", $len - \strlen($text));
  49310. }
  49311. return $text;
  49312. }
  49313. public function __construct($decorated = false, array $styles = array())
  49314. {
  49315. $this->decorated = (bool) $decorated;
  49316. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  49317. $this->setStyle('info', new OutputFormatterStyle('green'));
  49318. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  49319. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  49320. foreach ($styles as $name => $style) {
  49321. $this->setStyle($name, $style);
  49322. }
  49323. $this->styleStack = new OutputFormatterStyleStack();
  49324. }
  49325. public function setDecorated($decorated)
  49326. {
  49327. $this->decorated = (bool) $decorated;
  49328. }
  49329. public function isDecorated()
  49330. {
  49331. return $this->decorated;
  49332. }
  49333. public function setStyle($name, OutputFormatterStyleInterface $style)
  49334. {
  49335. $this->styles[strtolower($name)] = $style;
  49336. }
  49337. public function hasStyle($name)
  49338. {
  49339. return isset($this->styles[strtolower($name)]);
  49340. }
  49341. public function getStyle($name)
  49342. {
  49343. if (!$this->hasStyle($name)) {
  49344. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  49345. }
  49346. return $this->styles[strtolower($name)];
  49347. }
  49348. public function format($message)
  49349. {
  49350. $message = (string) $message;
  49351. $offset = 0;
  49352. $output = '';
  49353. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  49354. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  49355. foreach ($matches[0] as $i => $match) {
  49356. $pos = $match[1];
  49357. $text = $match[0];
  49358. if (0 != $pos && '\\' == $message[$pos - 1]) {
  49359. continue;
  49360. }
  49361. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  49362. $offset = $pos + \strlen($text);
  49363. if ($open = '/' != $text[1]) {
  49364. $tag = $matches[1][$i][0];
  49365. } else {
  49366. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  49367. }
  49368. if (!$open && !$tag) {
  49369. $this->styleStack->pop();
  49370. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  49371. $output .= $this->applyCurrentStyle($text);
  49372. } elseif ($open) {
  49373. $this->styleStack->push($style);
  49374. } else {
  49375. $this->styleStack->pop($style);
  49376. }
  49377. }
  49378. $output .= $this->applyCurrentStyle(substr($message, $offset));
  49379. if (false !== strpos($output, "\0")) {
  49380. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  49381. }
  49382. return str_replace('\\<', '<', $output);
  49383. }
  49384. public function getStyleStack()
  49385. {
  49386. return $this->styleStack;
  49387. }
  49388. private function createStyleFromString($string)
  49389. {
  49390. if (isset($this->styles[$string])) {
  49391. return $this->styles[$string];
  49392. }
  49393. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  49394. return false;
  49395. }
  49396. $style = new OutputFormatterStyle();
  49397. foreach ($matches as $match) {
  49398. array_shift($match);
  49399. if ('fg' == $match[0]) {
  49400. $style->setForeground($match[1]);
  49401. } elseif ('bg' == $match[0]) {
  49402. $style->setBackground($match[1]);
  49403. } else {
  49404. try {
  49405. $style->setOption($match[1]);
  49406. } catch (\InvalidArgumentException $e) {
  49407. return false;
  49408. }
  49409. }
  49410. }
  49411. return $style;
  49412. }
  49413. private function applyCurrentStyle($text)
  49414. {
  49415. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  49416. }
  49417. }
  49418. <?php
  49419. namespace Symfony\Component\Console\Formatter;
  49420. interface OutputFormatterInterface
  49421. {
  49422. public function setDecorated($decorated);
  49423. public function isDecorated();
  49424. public function setStyle($name, OutputFormatterStyleInterface $style);
  49425. public function hasStyle($name);
  49426. public function getStyle($name);
  49427. public function format($message);
  49428. }
  49429. <?php
  49430. namespace Symfony\Component\Console\Formatter;
  49431. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49432. class OutputFormatterStyle implements OutputFormatterStyleInterface
  49433. {
  49434. private static $availableForegroundColors = array(
  49435. 'black' => array('set' => 30, 'unset' => 39),
  49436. 'red' => array('set' => 31, 'unset' => 39),
  49437. 'green' => array('set' => 32, 'unset' => 39),
  49438. 'yellow' => array('set' => 33, 'unset' => 39),
  49439. 'blue' => array('set' => 34, 'unset' => 39),
  49440. 'magenta' => array('set' => 35, 'unset' => 39),
  49441. 'cyan' => array('set' => 36, 'unset' => 39),
  49442. 'white' => array('set' => 37, 'unset' => 39),
  49443. 'default' => array('set' => 39, 'unset' => 39),
  49444. );
  49445. private static $availableBackgroundColors = array(
  49446. 'black' => array('set' => 40, 'unset' => 49),
  49447. 'red' => array('set' => 41, 'unset' => 49),
  49448. 'green' => array('set' => 42, 'unset' => 49),
  49449. 'yellow' => array('set' => 43, 'unset' => 49),
  49450. 'blue' => array('set' => 44, 'unset' => 49),
  49451. 'magenta' => array('set' => 45, 'unset' => 49),
  49452. 'cyan' => array('set' => 46, 'unset' => 49),
  49453. 'white' => array('set' => 47, 'unset' => 49),
  49454. 'default' => array('set' => 49, 'unset' => 49),
  49455. );
  49456. private static $availableOptions = array(
  49457. 'bold' => array('set' => 1, 'unset' => 22),
  49458. 'underscore' => array('set' => 4, 'unset' => 24),
  49459. 'blink' => array('set' => 5, 'unset' => 25),
  49460. 'reverse' => array('set' => 7, 'unset' => 27),
  49461. 'conceal' => array('set' => 8, 'unset' => 28),
  49462. );
  49463. private $foreground;
  49464. private $background;
  49465. private $options = array();
  49466. public function __construct($foreground = null, $background = null, array $options = array())
  49467. {
  49468. if (null !== $foreground) {
  49469. $this->setForeground($foreground);
  49470. }
  49471. if (null !== $background) {
  49472. $this->setBackground($background);
  49473. }
  49474. if (\count($options)) {
  49475. $this->setOptions($options);
  49476. }
  49477. }
  49478. public function setForeground($color = null)
  49479. {
  49480. if (null === $color) {
  49481. $this->foreground = null;
  49482. return;
  49483. }
  49484. if (!isset(static::$availableForegroundColors[$color])) {
  49485. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  49486. }
  49487. $this->foreground = static::$availableForegroundColors[$color];
  49488. }
  49489. public function setBackground($color = null)
  49490. {
  49491. if (null === $color) {
  49492. $this->background = null;
  49493. return;
  49494. }
  49495. if (!isset(static::$availableBackgroundColors[$color])) {
  49496. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  49497. }
  49498. $this->background = static::$availableBackgroundColors[$color];
  49499. }
  49500. public function setOption($option)
  49501. {
  49502. if (!isset(static::$availableOptions[$option])) {
  49503. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  49504. }
  49505. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  49506. $this->options[] = static::$availableOptions[$option];
  49507. }
  49508. }
  49509. public function unsetOption($option)
  49510. {
  49511. if (!isset(static::$availableOptions[$option])) {
  49512. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  49513. }
  49514. $pos = array_search(static::$availableOptions[$option], $this->options);
  49515. if (false !== $pos) {
  49516. unset($this->options[$pos]);
  49517. }
  49518. }
  49519. public function setOptions(array $options)
  49520. {
  49521. $this->options = array();
  49522. foreach ($options as $option) {
  49523. $this->setOption($option);
  49524. }
  49525. }
  49526. public function apply($text)
  49527. {
  49528. $setCodes = array();
  49529. $unsetCodes = array();
  49530. if (null !== $this->foreground) {
  49531. $setCodes[] = $this->foreground['set'];
  49532. $unsetCodes[] = $this->foreground['unset'];
  49533. }
  49534. if (null !== $this->background) {
  49535. $setCodes[] = $this->background['set'];
  49536. $unsetCodes[] = $this->background['unset'];
  49537. }
  49538. if (\count($this->options)) {
  49539. foreach ($this->options as $option) {
  49540. $setCodes[] = $option['set'];
  49541. $unsetCodes[] = $option['unset'];
  49542. }
  49543. }
  49544. if (0 === \count($setCodes)) {
  49545. return $text;
  49546. }
  49547. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  49548. }
  49549. }
  49550. <?php
  49551. namespace Symfony\Component\Console\Formatter;
  49552. interface OutputFormatterStyleInterface
  49553. {
  49554. public function setForeground($color = null);
  49555. public function setBackground($color = null);
  49556. public function setOption($option);
  49557. public function unsetOption($option);
  49558. public function setOptions(array $options);
  49559. public function apply($text);
  49560. }
  49561. <?php
  49562. namespace Symfony\Component\Console\Formatter;
  49563. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49564. class OutputFormatterStyleStack
  49565. {
  49566. private $styles;
  49567. private $emptyStyle;
  49568. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  49569. {
  49570. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  49571. $this->reset();
  49572. }
  49573. public function reset()
  49574. {
  49575. $this->styles = array();
  49576. }
  49577. public function push(OutputFormatterStyleInterface $style)
  49578. {
  49579. $this->styles[] = $style;
  49580. }
  49581. public function pop(OutputFormatterStyleInterface $style = null)
  49582. {
  49583. if (empty($this->styles)) {
  49584. return $this->emptyStyle;
  49585. }
  49586. if (null === $style) {
  49587. return array_pop($this->styles);
  49588. }
  49589. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  49590. if ($style->apply('') === $stackedStyle->apply('')) {
  49591. $this->styles = \array_slice($this->styles, 0, $index);
  49592. return $stackedStyle;
  49593. }
  49594. }
  49595. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  49596. }
  49597. public function getCurrent()
  49598. {
  49599. if (empty($this->styles)) {
  49600. return $this->emptyStyle;
  49601. }
  49602. return $this->styles[\count($this->styles) - 1];
  49603. }
  49604. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  49605. {
  49606. $this->emptyStyle = $emptyStyle;
  49607. return $this;
  49608. }
  49609. public function getEmptyStyle()
  49610. {
  49611. return $this->emptyStyle;
  49612. }
  49613. }
  49614. <?php
  49615. namespace Symfony\Component\Console\Helper;
  49616. class DebugFormatterHelper extends Helper
  49617. {
  49618. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  49619. private $started = array();
  49620. private $count = -1;
  49621. public function start($id, $message, $prefix = 'RUN')
  49622. {
  49623. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  49624. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  49625. }
  49626. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  49627. {
  49628. $message = '';
  49629. if ($error) {
  49630. if (isset($this->started[$id]['out'])) {
  49631. $message .= "\n";
  49632. unset($this->started[$id]['out']);
  49633. }
  49634. if (!isset($this->started[$id]['err'])) {
  49635. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  49636. $this->started[$id]['err'] = true;
  49637. }
  49638. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  49639. } else {
  49640. if (isset($this->started[$id]['err'])) {
  49641. $message .= "\n";
  49642. unset($this->started[$id]['err']);
  49643. }
  49644. if (!isset($this->started[$id]['out'])) {
  49645. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  49646. $this->started[$id]['out'] = true;
  49647. }
  49648. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  49649. }
  49650. return $message;
  49651. }
  49652. public function stop($id, $message, $successful, $prefix = 'RES')
  49653. {
  49654. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  49655. if ($successful) {
  49656. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  49657. }
  49658. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  49659. unset($this->started[$id]['out'], $this->started[$id]['err']);
  49660. return $message;
  49661. }
  49662. private function getBorder($id)
  49663. {
  49664. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  49665. }
  49666. public function getName()
  49667. {
  49668. return 'debug_formatter';
  49669. }
  49670. }
  49671. <?php
  49672. namespace Symfony\Component\Console\Helper;
  49673. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  49674. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  49675. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  49676. use Symfony\Component\Console\Descriptor\TextDescriptor;
  49677. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  49678. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49679. use Symfony\Component\Console\Output\OutputInterface;
  49680. class DescriptorHelper extends Helper
  49681. {
  49682. private $descriptors = array();
  49683. public function __construct()
  49684. {
  49685. $this
  49686. ->register('txt', new TextDescriptor())
  49687. ->register('xml', new XmlDescriptor())
  49688. ->register('json', new JsonDescriptor())
  49689. ->register('md', new MarkdownDescriptor())
  49690. ;
  49691. }
  49692. public function describe(OutputInterface $output, $object, array $options = array())
  49693. {
  49694. $options = array_merge(array(
  49695. 'raw_text' => false,
  49696. 'format' => 'txt',
  49697. ), $options);
  49698. if (!isset($this->descriptors[$options['format']])) {
  49699. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  49700. }
  49701. $descriptor = $this->descriptors[$options['format']];
  49702. $descriptor->describe($output, $object, $options);
  49703. }
  49704. public function register($format, DescriptorInterface $descriptor)
  49705. {
  49706. $this->descriptors[$format] = $descriptor;
  49707. return $this;
  49708. }
  49709. public function getName()
  49710. {
  49711. return 'descriptor';
  49712. }
  49713. }
  49714. <?php
  49715. namespace Symfony\Component\Console\Helper;
  49716. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49717. use Symfony\Component\Console\Exception\RuntimeException;
  49718. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  49719. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  49720. use Symfony\Component\Console\Output\OutputInterface;
  49721. class DialogHelper extends InputAwareHelper
  49722. {
  49723. private $inputStream;
  49724. private static $shell;
  49725. private static $stty;
  49726. public function __construct($triggerDeprecationError = true)
  49727. {
  49728. if ($triggerDeprecationError) {
  49729. @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);
  49730. }
  49731. }
  49732. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  49733. {
  49734. if ($output instanceof ConsoleOutputInterface) {
  49735. $output = $output->getErrorOutput();
  49736. }
  49737. $width = max(array_map('strlen', array_keys($choices)));
  49738. $messages = (array) $question;
  49739. foreach ($choices as $key => $value) {
  49740. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  49741. }
  49742. $output->writeln($messages);
  49743. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  49744. $selectedChoices = str_replace(' ', '', $picked);
  49745. if ($multiselect) {
  49746. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  49747. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  49748. }
  49749. $selectedChoices = explode(',', $selectedChoices);
  49750. } else {
  49751. $selectedChoices = array($picked);
  49752. }
  49753. $multiselectChoices = array();
  49754. foreach ($selectedChoices as $value) {
  49755. if (empty($choices[$value])) {
  49756. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  49757. }
  49758. $multiselectChoices[] = $value;
  49759. }
  49760. if ($multiselect) {
  49761. return $multiselectChoices;
  49762. }
  49763. return $picked;
  49764. }, $attempts, $default);
  49765. return $result;
  49766. }
  49767. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  49768. {
  49769. if ($this->input && !$this->input->isInteractive()) {
  49770. return $default;
  49771. }
  49772. if ($output instanceof ConsoleOutputInterface) {
  49773. $output = $output->getErrorOutput();
  49774. }
  49775. $output->write($question);
  49776. $inputStream = $this->inputStream ?: STDIN;
  49777. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  49778. $ret = fgets($inputStream, 4096);
  49779. if (false === $ret) {
  49780. throw new RuntimeException('Aborted');
  49781. }
  49782. $ret = trim($ret);
  49783. } else {
  49784. $ret = '';
  49785. $i = 0;
  49786. $ofs = -1;
  49787. $matches = $autocomplete;
  49788. $numMatches = \count($matches);
  49789. $sttyMode = shell_exec('stty -g');
  49790. shell_exec('stty -icanon -echo');
  49791. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  49792. while (!feof($inputStream)) {
  49793. $c = fread($inputStream, 1);
  49794. if ("\177" === $c) {
  49795. if (0 === $numMatches && 0 !== $i) {
  49796. --$i;
  49797. $output->write("\033[1D");
  49798. }
  49799. if (0 === $i) {
  49800. $ofs = -1;
  49801. $matches = $autocomplete;
  49802. $numMatches = \count($matches);
  49803. } else {
  49804. $numMatches = 0;
  49805. }
  49806. $ret = substr($ret, 0, $i);
  49807. } elseif ("\033" === $c) {
  49808. $c .= fread($inputStream, 2);
  49809. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  49810. if ('A' === $c[2] && -1 === $ofs) {
  49811. $ofs = 0;
  49812. }
  49813. if (0 === $numMatches) {
  49814. continue;
  49815. }
  49816. $ofs += ('A' === $c[2]) ? -1 : 1;
  49817. $ofs = ($numMatches + $ofs) % $numMatches;
  49818. }
  49819. } elseif (\ord($c) < 32) {
  49820. if ("\t" === $c || "\n" === $c) {
  49821. if ($numMatches > 0 && -1 !== $ofs) {
  49822. $ret = $matches[$ofs];
  49823. $output->write(substr($ret, $i));
  49824. $i = \strlen($ret);
  49825. }
  49826. if ("\n" === $c) {
  49827. $output->write($c);
  49828. break;
  49829. }
  49830. $numMatches = 0;
  49831. }
  49832. continue;
  49833. } else {
  49834. $output->write($c);
  49835. $ret .= $c;
  49836. ++$i;
  49837. $numMatches = 0;
  49838. $ofs = 0;
  49839. foreach ($autocomplete as $value) {
  49840. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  49841. $matches[$numMatches++] = $value;
  49842. }
  49843. }
  49844. }
  49845. $output->write("\033[K");
  49846. if ($numMatches > 0 && -1 !== $ofs) {
  49847. $output->write("\0337");
  49848. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  49849. $output->write("\0338");
  49850. }
  49851. }
  49852. shell_exec(sprintf('stty %s', $sttyMode));
  49853. }
  49854. return \strlen($ret) > 0 ? $ret : $default;
  49855. }
  49856. public function askConfirmation(OutputInterface $output, $question, $default = true)
  49857. {
  49858. $answer = 'z';
  49859. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  49860. $answer = $this->ask($output, $question);
  49861. }
  49862. if (false === $default) {
  49863. return $answer && 'y' == strtolower($answer[0]);
  49864. }
  49865. return !$answer || 'y' == strtolower($answer[0]);
  49866. }
  49867. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  49868. {
  49869. if ($output instanceof ConsoleOutputInterface) {
  49870. $output = $output->getErrorOutput();
  49871. }
  49872. if ('\\' === \DIRECTORY_SEPARATOR) {
  49873. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  49874. if ('phar:' === substr(__FILE__, 0, 5)) {
  49875. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  49876. copy($exe, $tmpExe);
  49877. $exe = $tmpExe;
  49878. }
  49879. $output->write($question);
  49880. $value = rtrim(shell_exec($exe));
  49881. $output->writeln('');
  49882. if (isset($tmpExe)) {
  49883. unlink($tmpExe);
  49884. }
  49885. return $value;
  49886. }
  49887. if ($this->hasSttyAvailable()) {
  49888. $output->write($question);
  49889. $sttyMode = shell_exec('stty -g');
  49890. shell_exec('stty -echo');
  49891. $value = fgets($this->inputStream ?: STDIN, 4096);
  49892. shell_exec(sprintf('stty %s', $sttyMode));
  49893. if (false === $value) {
  49894. throw new RuntimeException('Aborted');
  49895. }
  49896. $value = trim($value);
  49897. $output->writeln('');
  49898. return $value;
  49899. }
  49900. if (false !== $shell = $this->getShell()) {
  49901. $output->write($question);
  49902. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  49903. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  49904. $value = rtrim(shell_exec($command));
  49905. $output->writeln('');
  49906. return $value;
  49907. }
  49908. if ($fallback) {
  49909. return $this->ask($output, $question);
  49910. }
  49911. throw new RuntimeException('Unable to hide the response');
  49912. }
  49913. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  49914. {
  49915. $that = $this;
  49916. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  49917. return $that->ask($output, $question, $default, $autocomplete);
  49918. };
  49919. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  49920. }
  49921. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  49922. {
  49923. $that = $this;
  49924. $interviewer = function () use ($output, $question, $fallback, $that) {
  49925. return $that->askHiddenResponse($output, $question, $fallback);
  49926. };
  49927. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  49928. }
  49929. public function setInputStream($stream)
  49930. {
  49931. $this->inputStream = $stream;
  49932. }
  49933. public function getInputStream()
  49934. {
  49935. return $this->inputStream;
  49936. }
  49937. public function getName()
  49938. {
  49939. return 'dialog';
  49940. }
  49941. private function getShell()
  49942. {
  49943. if (null !== self::$shell) {
  49944. return self::$shell;
  49945. }
  49946. self::$shell = false;
  49947. if (file_exists('/usr/bin/env')) {
  49948. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  49949. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  49950. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  49951. self::$shell = $sh;
  49952. break;
  49953. }
  49954. }
  49955. }
  49956. return self::$shell;
  49957. }
  49958. private function hasSttyAvailable()
  49959. {
  49960. if (null !== self::$stty) {
  49961. return self::$stty;
  49962. }
  49963. exec('stty 2>&1', $output, $exitcode);
  49964. return self::$stty = 0 === $exitcode;
  49965. }
  49966. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  49967. {
  49968. if ($output instanceof ConsoleOutputInterface) {
  49969. $output = $output->getErrorOutput();
  49970. }
  49971. $e = null;
  49972. while (false === $attempts || $attempts--) {
  49973. if (null !== $e) {
  49974. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  49975. }
  49976. try {
  49977. return \call_user_func($validator, $interviewer());
  49978. } catch (\Exception $e) {
  49979. }
  49980. }
  49981. throw $e;
  49982. }
  49983. }
  49984. <?php
  49985. namespace Symfony\Component\Console\Helper;
  49986. use Symfony\Component\Console\Formatter\OutputFormatter;
  49987. class FormatterHelper extends Helper
  49988. {
  49989. public function formatSection($section, $message, $style = 'info')
  49990. {
  49991. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  49992. }
  49993. public function formatBlock($messages, $style, $large = false)
  49994. {
  49995. if (!\is_array($messages)) {
  49996. $messages = array($messages);
  49997. }
  49998. $len = 0;
  49999. $lines = array();
  50000. foreach ($messages as $message) {
  50001. $message = OutputFormatter::escape($message);
  50002. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  50003. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  50004. }
  50005. $messages = $large ? array(str_repeat(' ', $len)) : array();
  50006. for ($i = 0; isset($lines[$i]); ++$i) {
  50007. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  50008. }
  50009. if ($large) {
  50010. $messages[] = str_repeat(' ', $len);
  50011. }
  50012. for ($i = 0; isset($messages[$i]); ++$i) {
  50013. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  50014. }
  50015. return implode("\n", $messages);
  50016. }
  50017. public function getName()
  50018. {
  50019. return 'formatter';
  50020. }
  50021. }
  50022. <?php
  50023. namespace Symfony\Component\Console\Helper;
  50024. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  50025. abstract class Helper implements HelperInterface
  50026. {
  50027. protected $helperSet = null;
  50028. public function setHelperSet(HelperSet $helperSet = null)
  50029. {
  50030. $this->helperSet = $helperSet;
  50031. }
  50032. public function getHelperSet()
  50033. {
  50034. return $this->helperSet;
  50035. }
  50036. public static function strlen($string)
  50037. {
  50038. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  50039. return \strlen($string);
  50040. }
  50041. return mb_strwidth($string, $encoding);
  50042. }
  50043. public static function formatTime($secs)
  50044. {
  50045. static $timeFormats = array(
  50046. array(0, '< 1 sec'),
  50047. array(1, '1 sec'),
  50048. array(2, 'secs', 1),
  50049. array(60, '1 min'),
  50050. array(120, 'mins', 60),
  50051. array(3600, '1 hr'),
  50052. array(7200, 'hrs', 3600),
  50053. array(86400, '1 day'),
  50054. array(172800, 'days', 86400),
  50055. );
  50056. foreach ($timeFormats as $index => $format) {
  50057. if ($secs >= $format[0]) {
  50058. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  50059. || $index == \count($timeFormats) - 1
  50060. ) {
  50061. if (2 == \count($format)) {
  50062. return $format[1];
  50063. }
  50064. return floor($secs / $format[2]).' '.$format[1];
  50065. }
  50066. }
  50067. }
  50068. }
  50069. public static function formatMemory($memory)
  50070. {
  50071. if ($memory >= 1024 * 1024 * 1024) {
  50072. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  50073. }
  50074. if ($memory >= 1024 * 1024) {
  50075. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  50076. }
  50077. if ($memory >= 1024) {
  50078. return sprintf('%d KiB', $memory / 1024);
  50079. }
  50080. return sprintf('%d B', $memory);
  50081. }
  50082. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  50083. {
  50084. return self::strlen(self::removeDecoration($formatter, $string));
  50085. }
  50086. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  50087. {
  50088. $isDecorated = $formatter->isDecorated();
  50089. $formatter->setDecorated(false);
  50090. $string = $formatter->format($string);
  50091. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  50092. $formatter->setDecorated($isDecorated);
  50093. return $string;
  50094. }
  50095. }
  50096. <?php
  50097. namespace Symfony\Component\Console\Helper;
  50098. interface HelperInterface
  50099. {
  50100. public function setHelperSet(HelperSet $helperSet = null);
  50101. public function getHelperSet();
  50102. public function getName();
  50103. }
  50104. <?php
  50105. namespace Symfony\Component\Console\Helper;
  50106. use Symfony\Component\Console\Command\Command;
  50107. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50108. class HelperSet implements \IteratorAggregate
  50109. {
  50110. private $helpers = array();
  50111. private $command;
  50112. public function __construct(array $helpers = array())
  50113. {
  50114. foreach ($helpers as $alias => $helper) {
  50115. $this->set($helper, \is_int($alias) ? null : $alias);
  50116. }
  50117. }
  50118. public function set(HelperInterface $helper, $alias = null)
  50119. {
  50120. $this->helpers[$helper->getName()] = $helper;
  50121. if (null !== $alias) {
  50122. $this->helpers[$alias] = $helper;
  50123. }
  50124. $helper->setHelperSet($this);
  50125. }
  50126. public function has($name)
  50127. {
  50128. return isset($this->helpers[$name]);
  50129. }
  50130. public function get($name)
  50131. {
  50132. if (!$this->has($name)) {
  50133. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  50134. }
  50135. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  50136. @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);
  50137. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  50138. @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);
  50139. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  50140. @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);
  50141. }
  50142. return $this->helpers[$name];
  50143. }
  50144. public function setCommand(Command $command = null)
  50145. {
  50146. $this->command = $command;
  50147. }
  50148. public function getCommand()
  50149. {
  50150. return $this->command;
  50151. }
  50152. public function getIterator()
  50153. {
  50154. return new \ArrayIterator($this->helpers);
  50155. }
  50156. }
  50157. <?php
  50158. namespace Symfony\Component\Console\Helper;
  50159. use Symfony\Component\Console\Input\InputAwareInterface;
  50160. use Symfony\Component\Console\Input\InputInterface;
  50161. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  50162. {
  50163. protected $input;
  50164. public function setInput(InputInterface $input)
  50165. {
  50166. $this->input = $input;
  50167. }
  50168. }
  50169. <?php
  50170. namespace Symfony\Component\Console\Helper;
  50171. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50172. use Symfony\Component\Console\Output\OutputInterface;
  50173. use Symfony\Component\Process\Exception\ProcessFailedException;
  50174. use Symfony\Component\Process\Process;
  50175. use Symfony\Component\Process\ProcessBuilder;
  50176. class ProcessHelper extends Helper
  50177. {
  50178. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  50179. {
  50180. if ($output instanceof ConsoleOutputInterface) {
  50181. $output = $output->getErrorOutput();
  50182. }
  50183. $formatter = $this->getHelperSet()->get('debug_formatter');
  50184. if (\is_array($cmd)) {
  50185. $process = ProcessBuilder::create($cmd)->getProcess();
  50186. } elseif ($cmd instanceof Process) {
  50187. $process = $cmd;
  50188. } else {
  50189. $process = new Process($cmd);
  50190. }
  50191. if ($verbosity <= $output->getVerbosity()) {
  50192. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  50193. }
  50194. if ($output->isDebug()) {
  50195. $callback = $this->wrapCallback($output, $process, $callback);
  50196. }
  50197. $process->run($callback);
  50198. if ($verbosity <= $output->getVerbosity()) {
  50199. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  50200. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  50201. }
  50202. if (!$process->isSuccessful() && null !== $error) {
  50203. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  50204. }
  50205. return $process;
  50206. }
  50207. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  50208. {
  50209. $process = $this->run($output, $cmd, $error, $callback);
  50210. if (!$process->isSuccessful()) {
  50211. throw new ProcessFailedException($process);
  50212. }
  50213. return $process;
  50214. }
  50215. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  50216. {
  50217. if ($output instanceof ConsoleOutputInterface) {
  50218. $output = $output->getErrorOutput();
  50219. }
  50220. $formatter = $this->getHelperSet()->get('debug_formatter');
  50221. $that = $this;
  50222. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  50223. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  50224. if (null !== $callback) {
  50225. \call_user_func($callback, $type, $buffer);
  50226. }
  50227. };
  50228. }
  50229. public function escapeString($str)
  50230. {
  50231. return str_replace('<', '\\<', $str);
  50232. }
  50233. public function getName()
  50234. {
  50235. return 'process';
  50236. }
  50237. }
  50238. <?php
  50239. namespace Symfony\Component\Console\Helper;
  50240. use Symfony\Component\Console\Exception\LogicException;
  50241. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50242. use Symfony\Component\Console\Output\OutputInterface;
  50243. class ProgressBar
  50244. {
  50245. private $barWidth = 28;
  50246. private $barChar;
  50247. private $emptyBarChar = '-';
  50248. private $progressChar = '>';
  50249. private $format;
  50250. private $internalFormat;
  50251. private $redrawFreq = 1;
  50252. private $output;
  50253. private $step = 0;
  50254. private $max;
  50255. private $startTime;
  50256. private $stepWidth;
  50257. private $percent = 0.0;
  50258. private $formatLineCount;
  50259. private $messages = array();
  50260. private $overwrite = true;
  50261. private $firstRun = true;
  50262. private static $formatters;
  50263. private static $formats;
  50264. public function __construct(OutputInterface $output, $max = 0)
  50265. {
  50266. if ($output instanceof ConsoleOutputInterface) {
  50267. $output = $output->getErrorOutput();
  50268. }
  50269. $this->output = $output;
  50270. $this->setMaxSteps($max);
  50271. if (!$this->output->isDecorated()) {
  50272. $this->overwrite = false;
  50273. $this->setRedrawFrequency($max / 10);
  50274. }
  50275. $this->startTime = time();
  50276. }
  50277. public static function setPlaceholderFormatterDefinition($name, $callable)
  50278. {
  50279. if (!self::$formatters) {
  50280. self::$formatters = self::initPlaceholderFormatters();
  50281. }
  50282. self::$formatters[$name] = $callable;
  50283. }
  50284. public static function getPlaceholderFormatterDefinition($name)
  50285. {
  50286. if (!self::$formatters) {
  50287. self::$formatters = self::initPlaceholderFormatters();
  50288. }
  50289. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  50290. }
  50291. public static function setFormatDefinition($name, $format)
  50292. {
  50293. if (!self::$formats) {
  50294. self::$formats = self::initFormats();
  50295. }
  50296. self::$formats[$name] = $format;
  50297. }
  50298. public static function getFormatDefinition($name)
  50299. {
  50300. if (!self::$formats) {
  50301. self::$formats = self::initFormats();
  50302. }
  50303. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  50304. }
  50305. public function setMessage($message, $name = 'message')
  50306. {
  50307. $this->messages[$name] = $message;
  50308. }
  50309. public function getMessage($name = 'message')
  50310. {
  50311. return $this->messages[$name];
  50312. }
  50313. public function getStartTime()
  50314. {
  50315. return $this->startTime;
  50316. }
  50317. public function getMaxSteps()
  50318. {
  50319. return $this->max;
  50320. }
  50321. public function getStep()
  50322. {
  50323. @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);
  50324. return $this->getProgress();
  50325. }
  50326. public function getProgress()
  50327. {
  50328. return $this->step;
  50329. }
  50330. public function getStepWidth()
  50331. {
  50332. return $this->stepWidth;
  50333. }
  50334. public function getProgressPercent()
  50335. {
  50336. return $this->percent;
  50337. }
  50338. public function setBarWidth($size)
  50339. {
  50340. $this->barWidth = (int) $size;
  50341. }
  50342. public function getBarWidth()
  50343. {
  50344. return $this->barWidth;
  50345. }
  50346. public function setBarCharacter($char)
  50347. {
  50348. $this->barChar = $char;
  50349. }
  50350. public function getBarCharacter()
  50351. {
  50352. if (null === $this->barChar) {
  50353. return $this->max ? '=' : $this->emptyBarChar;
  50354. }
  50355. return $this->barChar;
  50356. }
  50357. public function setEmptyBarCharacter($char)
  50358. {
  50359. $this->emptyBarChar = $char;
  50360. }
  50361. public function getEmptyBarCharacter()
  50362. {
  50363. return $this->emptyBarChar;
  50364. }
  50365. public function setProgressCharacter($char)
  50366. {
  50367. $this->progressChar = $char;
  50368. }
  50369. public function getProgressCharacter()
  50370. {
  50371. return $this->progressChar;
  50372. }
  50373. public function setFormat($format)
  50374. {
  50375. $this->format = null;
  50376. $this->internalFormat = $format;
  50377. }
  50378. public function setRedrawFrequency($freq)
  50379. {
  50380. $this->redrawFreq = max((int) $freq, 1);
  50381. }
  50382. public function start($max = null)
  50383. {
  50384. $this->startTime = time();
  50385. $this->step = 0;
  50386. $this->percent = 0.0;
  50387. if (null !== $max) {
  50388. $this->setMaxSteps($max);
  50389. }
  50390. $this->display();
  50391. }
  50392. public function advance($step = 1)
  50393. {
  50394. $this->setProgress($this->step + $step);
  50395. }
  50396. public function setCurrent($step)
  50397. {
  50398. @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);
  50399. $this->setProgress($step);
  50400. }
  50401. public function setOverwrite($overwrite)
  50402. {
  50403. $this->overwrite = (bool) $overwrite;
  50404. }
  50405. public function setProgress($step)
  50406. {
  50407. $step = (int) $step;
  50408. if ($step < $this->step) {
  50409. throw new LogicException('You can\'t regress the progress bar.');
  50410. }
  50411. if ($this->max && $step > $this->max) {
  50412. $this->max = $step;
  50413. }
  50414. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  50415. $currPeriod = (int) ($step / $this->redrawFreq);
  50416. $this->step = $step;
  50417. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  50418. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  50419. $this->display();
  50420. }
  50421. }
  50422. public function finish()
  50423. {
  50424. if (!$this->max) {
  50425. $this->max = $this->step;
  50426. }
  50427. if ($this->step === $this->max && !$this->overwrite) {
  50428. return;
  50429. }
  50430. $this->setProgress($this->max);
  50431. }
  50432. public function display()
  50433. {
  50434. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  50435. return;
  50436. }
  50437. if (null === $this->format) {
  50438. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  50439. }
  50440. $self = $this;
  50441. $output = $this->output;
  50442. $messages = $this->messages;
  50443. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  50444. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  50445. $text = \call_user_func($formatter, $self, $output);
  50446. } elseif (isset($messages[$matches[1]])) {
  50447. $text = $messages[$matches[1]];
  50448. } else {
  50449. return $matches[0];
  50450. }
  50451. if (isset($matches[2])) {
  50452. $text = sprintf('%'.$matches[2], $text);
  50453. }
  50454. return $text;
  50455. }, $this->format));
  50456. }
  50457. public function clear()
  50458. {
  50459. if (!$this->overwrite) {
  50460. return;
  50461. }
  50462. if (null === $this->format) {
  50463. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  50464. }
  50465. $this->overwrite('');
  50466. }
  50467. private function setRealFormat($format)
  50468. {
  50469. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  50470. $this->format = self::getFormatDefinition($format.'_nomax');
  50471. } elseif (null !== self::getFormatDefinition($format)) {
  50472. $this->format = self::getFormatDefinition($format);
  50473. } else {
  50474. $this->format = $format;
  50475. }
  50476. $this->formatLineCount = substr_count($this->format, "\n");
  50477. }
  50478. private function setMaxSteps($max)
  50479. {
  50480. $this->max = max(0, (int) $max);
  50481. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  50482. }
  50483. private function overwrite($message)
  50484. {
  50485. if ($this->overwrite) {
  50486. if (!$this->firstRun) {
  50487. $this->output->write("\x0D");
  50488. $this->output->write("\x1B[2K");
  50489. if ($this->formatLineCount > 0) {
  50490. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  50491. }
  50492. }
  50493. } elseif ($this->step > 0) {
  50494. $this->output->writeln('');
  50495. }
  50496. $this->firstRun = false;
  50497. $this->output->write($message);
  50498. }
  50499. private function determineBestFormat()
  50500. {
  50501. switch ($this->output->getVerbosity()) {
  50502. case OutputInterface::VERBOSITY_VERBOSE:
  50503. return $this->max ? 'verbose' : 'verbose_nomax';
  50504. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  50505. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  50506. case OutputInterface::VERBOSITY_DEBUG:
  50507. return $this->max ? 'debug' : 'debug_nomax';
  50508. default:
  50509. return $this->max ? 'normal' : 'normal_nomax';
  50510. }
  50511. }
  50512. private static function initPlaceholderFormatters()
  50513. {
  50514. return array(
  50515. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  50516. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  50517. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  50518. if ($completeBars < $bar->getBarWidth()) {
  50519. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  50520. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  50521. }
  50522. return $display;
  50523. },
  50524. 'elapsed' => function (ProgressBar $bar) {
  50525. return Helper::formatTime(time() - $bar->getStartTime());
  50526. },
  50527. 'remaining' => function (ProgressBar $bar) {
  50528. if (!$bar->getMaxSteps()) {
  50529. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  50530. }
  50531. if (!$bar->getProgress()) {
  50532. $remaining = 0;
  50533. } else {
  50534. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  50535. }
  50536. return Helper::formatTime($remaining);
  50537. },
  50538. 'estimated' => function (ProgressBar $bar) {
  50539. if (!$bar->getMaxSteps()) {
  50540. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  50541. }
  50542. if (!$bar->getProgress()) {
  50543. $estimated = 0;
  50544. } else {
  50545. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  50546. }
  50547. return Helper::formatTime($estimated);
  50548. },
  50549. 'memory' => function (ProgressBar $bar) {
  50550. return Helper::formatMemory(memory_get_usage(true));
  50551. },
  50552. 'current' => function (ProgressBar $bar) {
  50553. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  50554. },
  50555. 'max' => function (ProgressBar $bar) {
  50556. return $bar->getMaxSteps();
  50557. },
  50558. 'percent' => function (ProgressBar $bar) {
  50559. return floor($bar->getProgressPercent() * 100);
  50560. },
  50561. );
  50562. }
  50563. private static function initFormats()
  50564. {
  50565. return array(
  50566. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  50567. 'normal_nomax' => ' %current% [%bar%]',
  50568. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  50569. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  50570. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  50571. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  50572. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  50573. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  50574. );
  50575. }
  50576. }
  50577. <?php
  50578. namespace Symfony\Component\Console\Helper;
  50579. use Symfony\Component\Console\Exception\LogicException;
  50580. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50581. use Symfony\Component\Console\Output\NullOutput;
  50582. use Symfony\Component\Console\Output\OutputInterface;
  50583. class ProgressHelper extends Helper
  50584. {
  50585. const FORMAT_QUIET = ' %percent%%';
  50586. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  50587. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  50588. const FORMAT_QUIET_NOMAX = ' %current%';
  50589. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  50590. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  50591. private $barWidth = 28;
  50592. private $barChar = '=';
  50593. private $emptyBarChar = '-';
  50594. private $progressChar = '>';
  50595. private $format = null;
  50596. private $redrawFreq = 1;
  50597. private $lastMessagesLength;
  50598. private $barCharOriginal;
  50599. private $output;
  50600. private $current;
  50601. private $max;
  50602. private $startTime;
  50603. private $defaultFormatVars = array(
  50604. 'current',
  50605. 'max',
  50606. 'bar',
  50607. 'percent',
  50608. 'elapsed',
  50609. );
  50610. private $formatVars;
  50611. private $widths = array(
  50612. 'current' => 4,
  50613. 'max' => 4,
  50614. 'percent' => 3,
  50615. 'elapsed' => 6,
  50616. );
  50617. private $timeFormats = array(
  50618. array(0, '???'),
  50619. array(2, '1 sec'),
  50620. array(59, 'secs', 1),
  50621. array(60, '1 min'),
  50622. array(3600, 'mins', 60),
  50623. array(5400, '1 hr'),
  50624. array(86400, 'hrs', 3600),
  50625. array(129600, '1 day'),
  50626. array(604800, 'days', 86400),
  50627. );
  50628. public function __construct($triggerDeprecationError = true)
  50629. {
  50630. if ($triggerDeprecationError) {
  50631. @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);
  50632. }
  50633. }
  50634. public function setBarWidth($size)
  50635. {
  50636. $this->barWidth = (int) $size;
  50637. }
  50638. public function setBarCharacter($char)
  50639. {
  50640. $this->barChar = $char;
  50641. }
  50642. public function setEmptyBarCharacter($char)
  50643. {
  50644. $this->emptyBarChar = $char;
  50645. }
  50646. public function setProgressCharacter($char)
  50647. {
  50648. $this->progressChar = $char;
  50649. }
  50650. public function setFormat($format)
  50651. {
  50652. $this->format = $format;
  50653. }
  50654. public function setRedrawFrequency($freq)
  50655. {
  50656. $this->redrawFreq = (int) $freq;
  50657. }
  50658. public function start(OutputInterface $output, $max = null)
  50659. {
  50660. if ($output instanceof ConsoleOutputInterface) {
  50661. $output = $output->getErrorOutput();
  50662. }
  50663. $this->startTime = time();
  50664. $this->current = 0;
  50665. $this->max = (int) $max;
  50666. $this->output = $output->isDecorated() ? $output : new NullOutput();
  50667. $this->lastMessagesLength = 0;
  50668. $this->barCharOriginal = '';
  50669. if (null === $this->format) {
  50670. switch ($output->getVerbosity()) {
  50671. case OutputInterface::VERBOSITY_QUIET:
  50672. $this->format = self::FORMAT_QUIET_NOMAX;
  50673. if ($this->max > 0) {
  50674. $this->format = self::FORMAT_QUIET;
  50675. }
  50676. break;
  50677. case OutputInterface::VERBOSITY_VERBOSE:
  50678. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  50679. case OutputInterface::VERBOSITY_DEBUG:
  50680. $this->format = self::FORMAT_VERBOSE_NOMAX;
  50681. if ($this->max > 0) {
  50682. $this->format = self::FORMAT_VERBOSE;
  50683. }
  50684. break;
  50685. default:
  50686. $this->format = self::FORMAT_NORMAL_NOMAX;
  50687. if ($this->max > 0) {
  50688. $this->format = self::FORMAT_NORMAL;
  50689. }
  50690. break;
  50691. }
  50692. }
  50693. $this->initialize();
  50694. }
  50695. public function advance($step = 1, $redraw = false)
  50696. {
  50697. $this->setCurrent($this->current + $step, $redraw);
  50698. }
  50699. public function setCurrent($current, $redraw = false)
  50700. {
  50701. if (null === $this->startTime) {
  50702. throw new LogicException('You must start the progress bar before calling setCurrent().');
  50703. }
  50704. $current = (int) $current;
  50705. if ($current < $this->current) {
  50706. throw new LogicException('You can\'t regress the progress bar');
  50707. }
  50708. if (0 === $this->current) {
  50709. $redraw = true;
  50710. }
  50711. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  50712. $this->current = $current;
  50713. $currPeriod = (int) ($this->current / $this->redrawFreq);
  50714. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  50715. $this->display();
  50716. }
  50717. }
  50718. public function display($finish = false)
  50719. {
  50720. if (null === $this->startTime) {
  50721. throw new LogicException('You must start the progress bar before calling display().');
  50722. }
  50723. $message = $this->format;
  50724. foreach ($this->generate($finish) as $name => $value) {
  50725. $message = str_replace("%{$name}%", $value, $message);
  50726. }
  50727. $this->overwrite($this->output, $message);
  50728. }
  50729. public function clear()
  50730. {
  50731. $this->overwrite($this->output, '');
  50732. }
  50733. public function finish()
  50734. {
  50735. if (null === $this->startTime) {
  50736. throw new LogicException('You must start the progress bar before calling finish().');
  50737. }
  50738. if (null !== $this->startTime) {
  50739. if (!$this->max) {
  50740. $this->barChar = $this->barCharOriginal;
  50741. $this->display(true);
  50742. }
  50743. $this->startTime = null;
  50744. $this->output->writeln('');
  50745. $this->output = null;
  50746. }
  50747. }
  50748. private function initialize()
  50749. {
  50750. $this->formatVars = array();
  50751. foreach ($this->defaultFormatVars as $var) {
  50752. if (false !== strpos($this->format, "%{$var}%")) {
  50753. $this->formatVars[$var] = true;
  50754. }
  50755. }
  50756. if ($this->max > 0) {
  50757. $this->widths['max'] = $this->strlen($this->max);
  50758. $this->widths['current'] = $this->widths['max'];
  50759. } else {
  50760. $this->barCharOriginal = $this->barChar;
  50761. $this->barChar = $this->emptyBarChar;
  50762. }
  50763. }
  50764. private function generate($finish = false)
  50765. {
  50766. $vars = array();
  50767. $percent = 0;
  50768. if ($this->max > 0) {
  50769. $percent = (float) $this->current / $this->max;
  50770. }
  50771. if (isset($this->formatVars['bar'])) {
  50772. if ($this->max > 0) {
  50773. $completeBars = floor($percent * $this->barWidth);
  50774. } else {
  50775. if (!$finish) {
  50776. $completeBars = floor($this->current % $this->barWidth);
  50777. } else {
  50778. $completeBars = $this->barWidth;
  50779. }
  50780. }
  50781. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  50782. $bar = str_repeat($this->barChar, $completeBars);
  50783. if ($completeBars < $this->barWidth) {
  50784. $bar .= $this->progressChar;
  50785. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  50786. }
  50787. $vars['bar'] = $bar;
  50788. }
  50789. if (isset($this->formatVars['elapsed'])) {
  50790. $elapsed = time() - $this->startTime;
  50791. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  50792. }
  50793. if (isset($this->formatVars['current'])) {
  50794. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  50795. }
  50796. if (isset($this->formatVars['max'])) {
  50797. $vars['max'] = $this->max;
  50798. }
  50799. if (isset($this->formatVars['percent'])) {
  50800. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  50801. }
  50802. return $vars;
  50803. }
  50804. private function humaneTime($secs)
  50805. {
  50806. $text = '';
  50807. foreach ($this->timeFormats as $format) {
  50808. if ($secs < $format[0]) {
  50809. if (2 == \count($format)) {
  50810. $text = $format[1];
  50811. break;
  50812. } else {
  50813. $text = ceil($secs / $format[2]).' '.$format[1];
  50814. break;
  50815. }
  50816. }
  50817. }
  50818. return $text;
  50819. }
  50820. private function overwrite(OutputInterface $output, $message)
  50821. {
  50822. $length = $this->strlen($message);
  50823. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  50824. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  50825. }
  50826. $output->write("\x0D");
  50827. $output->write($message);
  50828. $this->lastMessagesLength = $this->strlen($message);
  50829. }
  50830. public function getName()
  50831. {
  50832. return 'progress';
  50833. }
  50834. }
  50835. <?php
  50836. namespace Symfony\Component\Console\Helper;
  50837. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50838. use Symfony\Component\Console\Exception\LogicException;
  50839. use Symfony\Component\Console\Output\OutputInterface;
  50840. class ProgressIndicator
  50841. {
  50842. private $output;
  50843. private $startTime;
  50844. private $format;
  50845. private $message;
  50846. private $indicatorValues;
  50847. private $indicatorCurrent;
  50848. private $indicatorChangeInterval;
  50849. private $indicatorUpdateTime;
  50850. private $started = false;
  50851. private static $formatters;
  50852. private static $formats;
  50853. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  50854. {
  50855. $this->output = $output;
  50856. if (null === $format) {
  50857. $format = $this->determineBestFormat();
  50858. }
  50859. if (null === $indicatorValues) {
  50860. $indicatorValues = array('-', '\\', '|', '/');
  50861. }
  50862. $indicatorValues = array_values($indicatorValues);
  50863. if (2 > \count($indicatorValues)) {
  50864. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  50865. }
  50866. $this->format = self::getFormatDefinition($format);
  50867. $this->indicatorChangeInterval = $indicatorChangeInterval;
  50868. $this->indicatorValues = $indicatorValues;
  50869. $this->startTime = time();
  50870. }
  50871. public function setMessage($message)
  50872. {
  50873. $this->message = $message;
  50874. $this->display();
  50875. }
  50876. public function getMessage()
  50877. {
  50878. return $this->message;
  50879. }
  50880. public function getStartTime()
  50881. {
  50882. return $this->startTime;
  50883. }
  50884. public function getCurrentValue()
  50885. {
  50886. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  50887. }
  50888. public function start($message)
  50889. {
  50890. if ($this->started) {
  50891. throw new LogicException('Progress indicator already started.');
  50892. }
  50893. $this->message = $message;
  50894. $this->started = true;
  50895. $this->startTime = time();
  50896. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  50897. $this->indicatorCurrent = 0;
  50898. $this->display();
  50899. }
  50900. public function advance()
  50901. {
  50902. if (!$this->started) {
  50903. throw new LogicException('Progress indicator has not yet been started.');
  50904. }
  50905. if (!$this->output->isDecorated()) {
  50906. return;
  50907. }
  50908. $currentTime = $this->getCurrentTimeInMilliseconds();
  50909. if ($currentTime < $this->indicatorUpdateTime) {
  50910. return;
  50911. }
  50912. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  50913. ++$this->indicatorCurrent;
  50914. $this->display();
  50915. }
  50916. public function finish($message)
  50917. {
  50918. if (!$this->started) {
  50919. throw new LogicException('Progress indicator has not yet been started.');
  50920. }
  50921. $this->message = $message;
  50922. $this->display();
  50923. $this->output->writeln('');
  50924. $this->started = false;
  50925. }
  50926. public static function getFormatDefinition($name)
  50927. {
  50928. if (!self::$formats) {
  50929. self::$formats = self::initFormats();
  50930. }
  50931. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  50932. }
  50933. public static function setPlaceholderFormatterDefinition($name, $callable)
  50934. {
  50935. if (!self::$formatters) {
  50936. self::$formatters = self::initPlaceholderFormatters();
  50937. }
  50938. self::$formatters[$name] = $callable;
  50939. }
  50940. public static function getPlaceholderFormatterDefinition($name)
  50941. {
  50942. if (!self::$formatters) {
  50943. self::$formatters = self::initPlaceholderFormatters();
  50944. }
  50945. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  50946. }
  50947. private function display()
  50948. {
  50949. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  50950. return;
  50951. }
  50952. $self = $this;
  50953. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  50954. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  50955. return \call_user_func($formatter, $self);
  50956. }
  50957. return $matches[0];
  50958. }, $this->format));
  50959. }
  50960. private function determineBestFormat()
  50961. {
  50962. switch ($this->output->getVerbosity()) {
  50963. case OutputInterface::VERBOSITY_VERBOSE:
  50964. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  50965. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  50966. case OutputInterface::VERBOSITY_DEBUG:
  50967. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  50968. default:
  50969. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  50970. }
  50971. }
  50972. private function overwrite($message)
  50973. {
  50974. if ($this->output->isDecorated()) {
  50975. $this->output->write("\x0D\x1B[2K");
  50976. $this->output->write($message);
  50977. } else {
  50978. $this->output->writeln($message);
  50979. }
  50980. }
  50981. private function getCurrentTimeInMilliseconds()
  50982. {
  50983. return round(microtime(true) * 1000);
  50984. }
  50985. private static function initPlaceholderFormatters()
  50986. {
  50987. return array(
  50988. 'indicator' => function (ProgressIndicator $indicator) {
  50989. return $indicator->getCurrentValue();
  50990. },
  50991. 'message' => function (ProgressIndicator $indicator) {
  50992. return $indicator->getMessage();
  50993. },
  50994. 'elapsed' => function (ProgressIndicator $indicator) {
  50995. return Helper::formatTime(time() - $indicator->getStartTime());
  50996. },
  50997. 'memory' => function () {
  50998. return Helper::formatMemory(memory_get_usage(true));
  50999. },
  51000. );
  51001. }
  51002. private static function initFormats()
  51003. {
  51004. return array(
  51005. 'normal' => ' %indicator% %message%',
  51006. 'normal_no_ansi' => ' %message%',
  51007. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  51008. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  51009. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  51010. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  51011. );
  51012. }
  51013. }
  51014. <?php
  51015. namespace Symfony\Component\Console\Helper;
  51016. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51017. use Symfony\Component\Console\Exception\RuntimeException;
  51018. use Symfony\Component\Console\Formatter\OutputFormatter;
  51019. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  51020. use Symfony\Component\Console\Input\InputInterface;
  51021. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  51022. use Symfony\Component\Console\Output\OutputInterface;
  51023. use Symfony\Component\Console\Question\ChoiceQuestion;
  51024. use Symfony\Component\Console\Question\Question;
  51025. class QuestionHelper extends Helper
  51026. {
  51027. private $inputStream;
  51028. private static $shell;
  51029. private static $stty;
  51030. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51031. {
  51032. if ($output instanceof ConsoleOutputInterface) {
  51033. $output = $output->getErrorOutput();
  51034. }
  51035. if (!$input->isInteractive()) {
  51036. $default = $question->getDefault();
  51037. if (null !== $default && $question instanceof ChoiceQuestion) {
  51038. $choices = $question->getChoices();
  51039. if (!$question->isMultiselect()) {
  51040. return isset($choices[$default]) ? $choices[$default] : $default;
  51041. }
  51042. $default = explode(',', $default);
  51043. foreach ($default as $k => $v) {
  51044. $v = trim($v);
  51045. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  51046. }
  51047. }
  51048. return $default;
  51049. }
  51050. if (!$question->getValidator()) {
  51051. return $this->doAsk($output, $question);
  51052. }
  51053. $that = $this;
  51054. $interviewer = function () use ($output, $question, $that) {
  51055. return $that->doAsk($output, $question);
  51056. };
  51057. return $this->validateAttempts($interviewer, $output, $question);
  51058. }
  51059. public function setInputStream($stream)
  51060. {
  51061. if (!\is_resource($stream)) {
  51062. throw new InvalidArgumentException('Input stream must be a valid resource.');
  51063. }
  51064. $this->inputStream = $stream;
  51065. }
  51066. public function getInputStream()
  51067. {
  51068. return $this->inputStream;
  51069. }
  51070. public function getName()
  51071. {
  51072. return 'question';
  51073. }
  51074. public function doAsk(OutputInterface $output, Question $question)
  51075. {
  51076. $this->writePrompt($output, $question);
  51077. $inputStream = $this->inputStream ?: STDIN;
  51078. $autocomplete = $question->getAutocompleterValues();
  51079. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  51080. $ret = false;
  51081. if ($question->isHidden()) {
  51082. try {
  51083. $ret = trim($this->getHiddenResponse($output, $inputStream));
  51084. } catch (RuntimeException $e) {
  51085. if (!$question->isHiddenFallback()) {
  51086. throw $e;
  51087. }
  51088. }
  51089. }
  51090. if (false === $ret) {
  51091. $ret = fgets($inputStream, 4096);
  51092. if (false === $ret) {
  51093. throw new RuntimeException('Aborted');
  51094. }
  51095. $ret = trim($ret);
  51096. }
  51097. } else {
  51098. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  51099. }
  51100. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  51101. if ($normalizer = $question->getNormalizer()) {
  51102. return $normalizer($ret);
  51103. }
  51104. return $ret;
  51105. }
  51106. protected function writePrompt(OutputInterface $output, Question $question)
  51107. {
  51108. $message = $question->getQuestion();
  51109. if ($question instanceof ChoiceQuestion) {
  51110. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  51111. $messages = (array) $question->getQuestion();
  51112. foreach ($question->getChoices() as $key => $value) {
  51113. $width = $maxWidth - $this->strlen($key);
  51114. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  51115. }
  51116. $output->writeln($messages);
  51117. $message = $question->getPrompt();
  51118. }
  51119. $output->write($message);
  51120. }
  51121. protected function writeError(OutputInterface $output, \Exception $error)
  51122. {
  51123. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  51124. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  51125. } else {
  51126. $message = '<error>'.$error->getMessage().'</error>';
  51127. }
  51128. $output->writeln($message);
  51129. }
  51130. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  51131. {
  51132. $ret = '';
  51133. $i = 0;
  51134. $ofs = -1;
  51135. $matches = $autocomplete;
  51136. $numMatches = \count($matches);
  51137. $sttyMode = shell_exec('stty -g');
  51138. shell_exec('stty -icanon -echo');
  51139. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  51140. while (!feof($inputStream)) {
  51141. $c = fread($inputStream, 1);
  51142. if ("\177" === $c) {
  51143. if (0 === $numMatches && 0 !== $i) {
  51144. --$i;
  51145. $output->write("\033[1D");
  51146. }
  51147. if (0 === $i) {
  51148. $ofs = -1;
  51149. $matches = $autocomplete;
  51150. $numMatches = \count($matches);
  51151. } else {
  51152. $numMatches = 0;
  51153. }
  51154. $ret = substr($ret, 0, $i);
  51155. } elseif ("\033" === $c) {
  51156. $c .= fread($inputStream, 2);
  51157. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  51158. if ('A' === $c[2] && -1 === $ofs) {
  51159. $ofs = 0;
  51160. }
  51161. if (0 === $numMatches) {
  51162. continue;
  51163. }
  51164. $ofs += ('A' === $c[2]) ? -1 : 1;
  51165. $ofs = ($numMatches + $ofs) % $numMatches;
  51166. }
  51167. } elseif (\ord($c) < 32) {
  51168. if ("\t" === $c || "\n" === $c) {
  51169. if ($numMatches > 0 && -1 !== $ofs) {
  51170. $ret = $matches[$ofs];
  51171. $output->write(substr($ret, $i));
  51172. $i = \strlen($ret);
  51173. }
  51174. if ("\n" === $c) {
  51175. $output->write($c);
  51176. break;
  51177. }
  51178. $numMatches = 0;
  51179. }
  51180. continue;
  51181. } else {
  51182. $output->write($c);
  51183. $ret .= $c;
  51184. ++$i;
  51185. $numMatches = 0;
  51186. $ofs = 0;
  51187. foreach ($autocomplete as $value) {
  51188. if (0 === strpos($value, $ret)) {
  51189. $matches[$numMatches++] = $value;
  51190. }
  51191. }
  51192. }
  51193. $output->write("\033[K");
  51194. if ($numMatches > 0 && -1 !== $ofs) {
  51195. $output->write("\0337");
  51196. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  51197. $output->write("\0338");
  51198. }
  51199. }
  51200. shell_exec(sprintf('stty %s', $sttyMode));
  51201. return $ret;
  51202. }
  51203. private function getHiddenResponse(OutputInterface $output, $inputStream)
  51204. {
  51205. if ('\\' === \DIRECTORY_SEPARATOR) {
  51206. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  51207. if ('phar:' === substr(__FILE__, 0, 5)) {
  51208. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  51209. copy($exe, $tmpExe);
  51210. $exe = $tmpExe;
  51211. }
  51212. $value = rtrim(shell_exec($exe));
  51213. $output->writeln('');
  51214. if (isset($tmpExe)) {
  51215. unlink($tmpExe);
  51216. }
  51217. return $value;
  51218. }
  51219. if ($this->hasSttyAvailable()) {
  51220. $sttyMode = shell_exec('stty -g');
  51221. shell_exec('stty -echo');
  51222. $value = fgets($inputStream, 4096);
  51223. shell_exec(sprintf('stty %s', $sttyMode));
  51224. if (false === $value) {
  51225. throw new RuntimeException('Aborted');
  51226. }
  51227. $value = trim($value);
  51228. $output->writeln('');
  51229. return $value;
  51230. }
  51231. if (false !== $shell = $this->getShell()) {
  51232. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  51233. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  51234. $value = rtrim(shell_exec($command));
  51235. $output->writeln('');
  51236. return $value;
  51237. }
  51238. throw new RuntimeException('Unable to hide the response.');
  51239. }
  51240. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  51241. {
  51242. $error = null;
  51243. $attempts = $question->getMaxAttempts();
  51244. while (null === $attempts || $attempts--) {
  51245. if (null !== $error) {
  51246. $this->writeError($output, $error);
  51247. }
  51248. try {
  51249. return \call_user_func($question->getValidator(), $interviewer());
  51250. } catch (RuntimeException $e) {
  51251. throw $e;
  51252. } catch (\Exception $error) {
  51253. }
  51254. }
  51255. throw $error;
  51256. }
  51257. private function getShell()
  51258. {
  51259. if (null !== self::$shell) {
  51260. return self::$shell;
  51261. }
  51262. self::$shell = false;
  51263. if (file_exists('/usr/bin/env')) {
  51264. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  51265. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  51266. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  51267. self::$shell = $sh;
  51268. break;
  51269. }
  51270. }
  51271. }
  51272. return self::$shell;
  51273. }
  51274. private function hasSttyAvailable()
  51275. {
  51276. if (null !== self::$stty) {
  51277. return self::$stty;
  51278. }
  51279. exec('stty 2>&1', $output, $exitcode);
  51280. return self::$stty = 0 === $exitcode;
  51281. }
  51282. }
  51283. <?php
  51284. namespace Symfony\Component\Console\Helper;
  51285. use Symfony\Component\Console\Exception\LogicException;
  51286. use Symfony\Component\Console\Formatter\OutputFormatter;
  51287. use Symfony\Component\Console\Input\InputInterface;
  51288. use Symfony\Component\Console\Output\OutputInterface;
  51289. use Symfony\Component\Console\Question\ChoiceQuestion;
  51290. use Symfony\Component\Console\Question\ConfirmationQuestion;
  51291. use Symfony\Component\Console\Question\Question;
  51292. use Symfony\Component\Console\Style\SymfonyStyle;
  51293. class SymfonyQuestionHelper extends QuestionHelper
  51294. {
  51295. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51296. {
  51297. $validator = $question->getValidator();
  51298. $question->setValidator(function ($value) use ($validator) {
  51299. if (null !== $validator) {
  51300. $value = $validator($value);
  51301. } else {
  51302. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  51303. throw new LogicException('A value is required.');
  51304. }
  51305. }
  51306. return $value;
  51307. });
  51308. return parent::ask($input, $output, $question);
  51309. }
  51310. protected function writePrompt(OutputInterface $output, Question $question)
  51311. {
  51312. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  51313. $default = $question->getDefault();
  51314. switch (true) {
  51315. case null === $default:
  51316. $text = sprintf(' <info>%s</info>:', $text);
  51317. break;
  51318. case $question instanceof ConfirmationQuestion:
  51319. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  51320. break;
  51321. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  51322. $choices = $question->getChoices();
  51323. $default = explode(',', $default);
  51324. foreach ($default as $key => $value) {
  51325. $default[$key] = $choices[trim($value)];
  51326. }
  51327. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  51328. break;
  51329. case $question instanceof ChoiceQuestion:
  51330. $choices = $question->getChoices();
  51331. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  51332. break;
  51333. default:
  51334. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  51335. }
  51336. $output->writeln($text);
  51337. if ($question instanceof ChoiceQuestion) {
  51338. $width = max(array_map('strlen', array_keys($question->getChoices())));
  51339. foreach ($question->getChoices() as $key => $value) {
  51340. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  51341. }
  51342. }
  51343. $output->write(' > ');
  51344. }
  51345. protected function writeError(OutputInterface $output, \Exception $error)
  51346. {
  51347. if ($output instanceof SymfonyStyle) {
  51348. $output->newLine();
  51349. $output->error($error->getMessage());
  51350. return;
  51351. }
  51352. parent::writeError($output, $error);
  51353. }
  51354. }
  51355. <?php
  51356. namespace Symfony\Component\Console\Helper;
  51357. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51358. use Symfony\Component\Console\Output\OutputInterface;
  51359. class Table
  51360. {
  51361. private $headers = array();
  51362. private $rows = array();
  51363. private $columnWidths = array();
  51364. private $numberOfColumns;
  51365. private $output;
  51366. private $style;
  51367. private $columnStyles = array();
  51368. private static $styles;
  51369. public function __construct(OutputInterface $output)
  51370. {
  51371. $this->output = $output;
  51372. if (!self::$styles) {
  51373. self::$styles = self::initStyles();
  51374. }
  51375. $this->setStyle('default');
  51376. }
  51377. public static function setStyleDefinition($name, TableStyle $style)
  51378. {
  51379. if (!self::$styles) {
  51380. self::$styles = self::initStyles();
  51381. }
  51382. self::$styles[$name] = $style;
  51383. }
  51384. public static function getStyleDefinition($name)
  51385. {
  51386. if (!self::$styles) {
  51387. self::$styles = self::initStyles();
  51388. }
  51389. if (isset(self::$styles[$name])) {
  51390. return self::$styles[$name];
  51391. }
  51392. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  51393. }
  51394. public function setStyle($name)
  51395. {
  51396. $this->style = $this->resolveStyle($name);
  51397. return $this;
  51398. }
  51399. public function getStyle()
  51400. {
  51401. return $this->style;
  51402. }
  51403. public function setColumnStyle($columnIndex, $name)
  51404. {
  51405. $columnIndex = (int) $columnIndex;
  51406. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  51407. return $this;
  51408. }
  51409. public function getColumnStyle($columnIndex)
  51410. {
  51411. if (isset($this->columnStyles[$columnIndex])) {
  51412. return $this->columnStyles[$columnIndex];
  51413. }
  51414. return $this->getStyle();
  51415. }
  51416. public function setHeaders(array $headers)
  51417. {
  51418. $headers = array_values($headers);
  51419. if (!empty($headers) && !\is_array($headers[0])) {
  51420. $headers = array($headers);
  51421. }
  51422. $this->headers = $headers;
  51423. return $this;
  51424. }
  51425. public function setRows(array $rows)
  51426. {
  51427. $this->rows = array();
  51428. return $this->addRows($rows);
  51429. }
  51430. public function addRows(array $rows)
  51431. {
  51432. foreach ($rows as $row) {
  51433. $this->addRow($row);
  51434. }
  51435. return $this;
  51436. }
  51437. public function addRow($row)
  51438. {
  51439. if ($row instanceof TableSeparator) {
  51440. $this->rows[] = $row;
  51441. return $this;
  51442. }
  51443. if (!\is_array($row)) {
  51444. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  51445. }
  51446. $this->rows[] = array_values($row);
  51447. return $this;
  51448. }
  51449. public function setRow($column, array $row)
  51450. {
  51451. $this->rows[$column] = $row;
  51452. return $this;
  51453. }
  51454. public function render()
  51455. {
  51456. $this->calculateNumberOfColumns();
  51457. $rows = $this->buildTableRows($this->rows);
  51458. $headers = $this->buildTableRows($this->headers);
  51459. $this->calculateColumnsWidth(array_merge($headers, $rows));
  51460. $this->renderRowSeparator();
  51461. if (!empty($headers)) {
  51462. foreach ($headers as $header) {
  51463. $this->renderRow($header, $this->style->getCellHeaderFormat());
  51464. $this->renderRowSeparator();
  51465. }
  51466. }
  51467. foreach ($rows as $row) {
  51468. if ($row instanceof TableSeparator) {
  51469. $this->renderRowSeparator();
  51470. } else {
  51471. $this->renderRow($row, $this->style->getCellRowFormat());
  51472. }
  51473. }
  51474. if (!empty($rows)) {
  51475. $this->renderRowSeparator();
  51476. }
  51477. $this->cleanup();
  51478. }
  51479. private function renderRowSeparator()
  51480. {
  51481. if (0 === $count = $this->numberOfColumns) {
  51482. return;
  51483. }
  51484. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  51485. return;
  51486. }
  51487. $markup = $this->style->getCrossingChar();
  51488. for ($column = 0; $column < $count; ++$column) {
  51489. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  51490. }
  51491. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  51492. }
  51493. private function renderColumnSeparator()
  51494. {
  51495. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  51496. }
  51497. private function renderRow(array $row, $cellFormat)
  51498. {
  51499. if (empty($row)) {
  51500. return;
  51501. }
  51502. $rowContent = $this->renderColumnSeparator();
  51503. foreach ($this->getRowColumns($row) as $column) {
  51504. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  51505. $rowContent .= $this->renderColumnSeparator();
  51506. }
  51507. $this->output->writeln($rowContent);
  51508. }
  51509. private function renderCell(array $row, $column, $cellFormat)
  51510. {
  51511. $cell = isset($row[$column]) ? $row[$column] : '';
  51512. $width = $this->columnWidths[$column];
  51513. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  51514. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  51515. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  51516. }
  51517. }
  51518. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  51519. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  51520. }
  51521. $style = $this->getColumnStyle($column);
  51522. if ($cell instanceof TableSeparator) {
  51523. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  51524. }
  51525. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  51526. $content = sprintf($style->getCellRowContentFormat(), $cell);
  51527. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  51528. }
  51529. private function calculateNumberOfColumns()
  51530. {
  51531. if (null !== $this->numberOfColumns) {
  51532. return;
  51533. }
  51534. $columns = array(0);
  51535. foreach (array_merge($this->headers, $this->rows) as $row) {
  51536. if ($row instanceof TableSeparator) {
  51537. continue;
  51538. }
  51539. $columns[] = $this->getNumberOfColumns($row);
  51540. }
  51541. $this->numberOfColumns = max($columns);
  51542. }
  51543. private function buildTableRows($rows)
  51544. {
  51545. $unmergedRows = array();
  51546. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  51547. $rows = $this->fillNextRows($rows, $rowKey);
  51548. foreach ($rows[$rowKey] as $column => $cell) {
  51549. if (!strstr($cell, "\n")) {
  51550. continue;
  51551. }
  51552. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  51553. foreach ($lines as $lineKey => $line) {
  51554. if ($cell instanceof TableCell) {
  51555. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  51556. }
  51557. if (0 === $lineKey) {
  51558. $rows[$rowKey][$column] = $line;
  51559. } else {
  51560. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  51561. }
  51562. }
  51563. }
  51564. }
  51565. $tableRows = array();
  51566. foreach ($rows as $rowKey => $row) {
  51567. $tableRows[] = $this->fillCells($row);
  51568. if (isset($unmergedRows[$rowKey])) {
  51569. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  51570. }
  51571. }
  51572. return $tableRows;
  51573. }
  51574. private function fillNextRows(array $rows, $line)
  51575. {
  51576. $unmergedRows = array();
  51577. foreach ($rows[$line] as $column => $cell) {
  51578. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  51579. $nbLines = $cell->getRowspan() - 1;
  51580. $lines = array($cell);
  51581. if (strstr($cell, "\n")) {
  51582. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  51583. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  51584. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  51585. unset($lines[0]);
  51586. }
  51587. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  51588. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  51589. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  51590. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  51591. if ($nbLines === $unmergedRowKey - $line) {
  51592. break;
  51593. }
  51594. }
  51595. }
  51596. }
  51597. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  51598. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  51599. foreach ($unmergedRow as $cellKey => $cell) {
  51600. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  51601. }
  51602. } else {
  51603. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  51604. foreach ($unmergedRow as $column => $cell) {
  51605. if (!empty($cell)) {
  51606. $row[$column] = $unmergedRow[$column];
  51607. }
  51608. }
  51609. array_splice($rows, $unmergedRowKey, 0, array($row));
  51610. }
  51611. }
  51612. return $rows;
  51613. }
  51614. private function fillCells($row)
  51615. {
  51616. $newRow = array();
  51617. foreach ($row as $column => $cell) {
  51618. $newRow[] = $cell;
  51619. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  51620. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  51621. $newRow[] = '';
  51622. }
  51623. }
  51624. }
  51625. return $newRow ?: $row;
  51626. }
  51627. private function copyRow(array $rows, $line)
  51628. {
  51629. $row = $rows[$line];
  51630. foreach ($row as $cellKey => $cellValue) {
  51631. $row[$cellKey] = '';
  51632. if ($cellValue instanceof TableCell) {
  51633. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  51634. }
  51635. }
  51636. return $row;
  51637. }
  51638. private function getNumberOfColumns(array $row)
  51639. {
  51640. $columns = \count($row);
  51641. foreach ($row as $column) {
  51642. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  51643. }
  51644. return $columns;
  51645. }
  51646. private function getRowColumns(array $row)
  51647. {
  51648. $columns = range(0, $this->numberOfColumns - 1);
  51649. foreach ($row as $cellKey => $cell) {
  51650. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  51651. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  51652. }
  51653. }
  51654. return $columns;
  51655. }
  51656. private function calculateColumnsWidth($rows)
  51657. {
  51658. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  51659. $lengths = array();
  51660. foreach ($rows as $row) {
  51661. if ($row instanceof TableSeparator) {
  51662. continue;
  51663. }
  51664. foreach ($row as $i => $cell) {
  51665. if ($cell instanceof TableCell) {
  51666. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  51667. $textLength = Helper::strlen($textContent);
  51668. if ($textLength > 0) {
  51669. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  51670. foreach ($contentColumns as $position => $content) {
  51671. $row[$i + $position] = $content;
  51672. }
  51673. }
  51674. }
  51675. }
  51676. $lengths[] = $this->getCellWidth($row, $column);
  51677. }
  51678. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  51679. }
  51680. }
  51681. private function getColumnSeparatorWidth()
  51682. {
  51683. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  51684. }
  51685. private function getCellWidth(array $row, $column)
  51686. {
  51687. if (isset($row[$column])) {
  51688. $cell = $row[$column];
  51689. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  51690. return $cellWidth;
  51691. }
  51692. return 0;
  51693. }
  51694. private function cleanup()
  51695. {
  51696. $this->columnWidths = array();
  51697. $this->numberOfColumns = null;
  51698. }
  51699. private static function initStyles()
  51700. {
  51701. $borderless = new TableStyle();
  51702. $borderless
  51703. ->setHorizontalBorderChar('=')
  51704. ->setVerticalBorderChar(' ')
  51705. ->setCrossingChar(' ')
  51706. ;
  51707. $compact = new TableStyle();
  51708. $compact
  51709. ->setHorizontalBorderChar('')
  51710. ->setVerticalBorderChar(' ')
  51711. ->setCrossingChar('')
  51712. ->setCellRowContentFormat('%s')
  51713. ;
  51714. $styleGuide = new TableStyle();
  51715. $styleGuide
  51716. ->setHorizontalBorderChar('-')
  51717. ->setVerticalBorderChar(' ')
  51718. ->setCrossingChar(' ')
  51719. ->setCellHeaderFormat('%s')
  51720. ;
  51721. return array(
  51722. 'default' => new TableStyle(),
  51723. 'borderless' => $borderless,
  51724. 'compact' => $compact,
  51725. 'symfony-style-guide' => $styleGuide,
  51726. );
  51727. }
  51728. private function resolveStyle($name)
  51729. {
  51730. if ($name instanceof TableStyle) {
  51731. return $name;
  51732. }
  51733. if (isset(self::$styles[$name])) {
  51734. return self::$styles[$name];
  51735. }
  51736. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  51737. }
  51738. }
  51739. <?php
  51740. namespace Symfony\Component\Console\Helper;
  51741. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51742. class TableCell
  51743. {
  51744. private $value;
  51745. private $options = array(
  51746. 'rowspan' => 1,
  51747. 'colspan' => 1,
  51748. );
  51749. public function __construct($value = '', array $options = array())
  51750. {
  51751. if (is_numeric($value) && !\is_string($value)) {
  51752. $value = (string) $value;
  51753. }
  51754. $this->value = $value;
  51755. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  51756. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  51757. }
  51758. $this->options = array_merge($this->options, $options);
  51759. }
  51760. public function __toString()
  51761. {
  51762. return $this->value;
  51763. }
  51764. public function getColspan()
  51765. {
  51766. return (int) $this->options['colspan'];
  51767. }
  51768. public function getRowspan()
  51769. {
  51770. return (int) $this->options['rowspan'];
  51771. }
  51772. }
  51773. <?php
  51774. namespace Symfony\Component\Console\Helper;
  51775. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51776. use Symfony\Component\Console\Output\NullOutput;
  51777. use Symfony\Component\Console\Output\OutputInterface;
  51778. class TableHelper extends Helper
  51779. {
  51780. const LAYOUT_DEFAULT = 0;
  51781. const LAYOUT_BORDERLESS = 1;
  51782. const LAYOUT_COMPACT = 2;
  51783. private $table;
  51784. public function __construct($triggerDeprecationError = true)
  51785. {
  51786. if ($triggerDeprecationError) {
  51787. @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);
  51788. }
  51789. $this->table = new Table(new NullOutput());
  51790. }
  51791. public function setLayout($layout)
  51792. {
  51793. switch ($layout) {
  51794. case self::LAYOUT_BORDERLESS:
  51795. $this->table->setStyle('borderless');
  51796. break;
  51797. case self::LAYOUT_COMPACT:
  51798. $this->table->setStyle('compact');
  51799. break;
  51800. case self::LAYOUT_DEFAULT:
  51801. $this->table->setStyle('default');
  51802. break;
  51803. default:
  51804. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  51805. }
  51806. return $this;
  51807. }
  51808. public function setHeaders(array $headers)
  51809. {
  51810. $this->table->setHeaders($headers);
  51811. return $this;
  51812. }
  51813. public function setRows(array $rows)
  51814. {
  51815. $this->table->setRows($rows);
  51816. return $this;
  51817. }
  51818. public function addRows(array $rows)
  51819. {
  51820. $this->table->addRows($rows);
  51821. return $this;
  51822. }
  51823. public function addRow(array $row)
  51824. {
  51825. $this->table->addRow($row);
  51826. return $this;
  51827. }
  51828. public function setRow($column, array $row)
  51829. {
  51830. $this->table->setRow($column, $row);
  51831. return $this;
  51832. }
  51833. public function setPaddingChar($paddingChar)
  51834. {
  51835. $this->table->getStyle()->setPaddingChar($paddingChar);
  51836. return $this;
  51837. }
  51838. public function setHorizontalBorderChar($horizontalBorderChar)
  51839. {
  51840. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  51841. return $this;
  51842. }
  51843. public function setVerticalBorderChar($verticalBorderChar)
  51844. {
  51845. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  51846. return $this;
  51847. }
  51848. public function setCrossingChar($crossingChar)
  51849. {
  51850. $this->table->getStyle()->setCrossingChar($crossingChar);
  51851. return $this;
  51852. }
  51853. public function setCellHeaderFormat($cellHeaderFormat)
  51854. {
  51855. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  51856. return $this;
  51857. }
  51858. public function setCellRowFormat($cellRowFormat)
  51859. {
  51860. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  51861. return $this;
  51862. }
  51863. public function setCellRowContentFormat($cellRowContentFormat)
  51864. {
  51865. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  51866. return $this;
  51867. }
  51868. public function setBorderFormat($borderFormat)
  51869. {
  51870. $this->table->getStyle()->setBorderFormat($borderFormat);
  51871. return $this;
  51872. }
  51873. public function setPadType($padType)
  51874. {
  51875. $this->table->getStyle()->setPadType($padType);
  51876. return $this;
  51877. }
  51878. public function render(OutputInterface $output)
  51879. {
  51880. $p = new \ReflectionProperty($this->table, 'output');
  51881. $p->setAccessible(true);
  51882. $p->setValue($this->table, $output);
  51883. $this->table->render();
  51884. }
  51885. public function getName()
  51886. {
  51887. return 'table';
  51888. }
  51889. }
  51890. <?php
  51891. namespace Symfony\Component\Console\Helper;
  51892. class TableSeparator extends TableCell
  51893. {
  51894. public function __construct(array $options = array())
  51895. {
  51896. parent::__construct('', $options);
  51897. }
  51898. }
  51899. <?php
  51900. namespace Symfony\Component\Console\Helper;
  51901. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51902. use Symfony\Component\Console\Exception\LogicException;
  51903. class TableStyle
  51904. {
  51905. private $paddingChar = ' ';
  51906. private $horizontalBorderChar = '-';
  51907. private $verticalBorderChar = '|';
  51908. private $crossingChar = '+';
  51909. private $cellHeaderFormat = '<info>%s</info>';
  51910. private $cellRowFormat = '%s';
  51911. private $cellRowContentFormat = ' %s ';
  51912. private $borderFormat = '%s';
  51913. private $padType = STR_PAD_RIGHT;
  51914. public function setPaddingChar($paddingChar)
  51915. {
  51916. if (!$paddingChar) {
  51917. throw new LogicException('The padding char must not be empty');
  51918. }
  51919. $this->paddingChar = $paddingChar;
  51920. return $this;
  51921. }
  51922. public function getPaddingChar()
  51923. {
  51924. return $this->paddingChar;
  51925. }
  51926. public function setHorizontalBorderChar($horizontalBorderChar)
  51927. {
  51928. $this->horizontalBorderChar = $horizontalBorderChar;
  51929. return $this;
  51930. }
  51931. public function getHorizontalBorderChar()
  51932. {
  51933. return $this->horizontalBorderChar;
  51934. }
  51935. public function setVerticalBorderChar($verticalBorderChar)
  51936. {
  51937. $this->verticalBorderChar = $verticalBorderChar;
  51938. return $this;
  51939. }
  51940. public function getVerticalBorderChar()
  51941. {
  51942. return $this->verticalBorderChar;
  51943. }
  51944. public function setCrossingChar($crossingChar)
  51945. {
  51946. $this->crossingChar = $crossingChar;
  51947. return $this;
  51948. }
  51949. public function getCrossingChar()
  51950. {
  51951. return $this->crossingChar;
  51952. }
  51953. public function setCellHeaderFormat($cellHeaderFormat)
  51954. {
  51955. $this->cellHeaderFormat = $cellHeaderFormat;
  51956. return $this;
  51957. }
  51958. public function getCellHeaderFormat()
  51959. {
  51960. return $this->cellHeaderFormat;
  51961. }
  51962. public function setCellRowFormat($cellRowFormat)
  51963. {
  51964. $this->cellRowFormat = $cellRowFormat;
  51965. return $this;
  51966. }
  51967. public function getCellRowFormat()
  51968. {
  51969. return $this->cellRowFormat;
  51970. }
  51971. public function setCellRowContentFormat($cellRowContentFormat)
  51972. {
  51973. $this->cellRowContentFormat = $cellRowContentFormat;
  51974. return $this;
  51975. }
  51976. public function getCellRowContentFormat()
  51977. {
  51978. return $this->cellRowContentFormat;
  51979. }
  51980. public function setBorderFormat($borderFormat)
  51981. {
  51982. $this->borderFormat = $borderFormat;
  51983. return $this;
  51984. }
  51985. public function getBorderFormat()
  51986. {
  51987. return $this->borderFormat;
  51988. }
  51989. public function setPadType($padType)
  51990. {
  51991. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  51992. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  51993. }
  51994. $this->padType = $padType;
  51995. return $this;
  51996. }
  51997. public function getPadType()
  51998. {
  51999. return $this->padType;
  52000. }
  52001. }
  52002. <?php
  52003. namespace Symfony\Component\Console\Input;
  52004. use Symfony\Component\Console\Exception\RuntimeException;
  52005. class ArgvInput extends Input
  52006. {
  52007. private $tokens;
  52008. private $parsed;
  52009. public function __construct(array $argv = null, InputDefinition $definition = null)
  52010. {
  52011. if (null === $argv) {
  52012. $argv = $_SERVER['argv'];
  52013. }
  52014. array_shift($argv);
  52015. $this->tokens = $argv;
  52016. parent::__construct($definition);
  52017. }
  52018. protected function setTokens(array $tokens)
  52019. {
  52020. $this->tokens = $tokens;
  52021. }
  52022. protected function parse()
  52023. {
  52024. $parseOptions = true;
  52025. $this->parsed = $this->tokens;
  52026. while (null !== $token = array_shift($this->parsed)) {
  52027. if ($parseOptions && '' == $token) {
  52028. $this->parseArgument($token);
  52029. } elseif ($parseOptions && '--' == $token) {
  52030. $parseOptions = false;
  52031. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  52032. $this->parseLongOption($token);
  52033. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  52034. $this->parseShortOption($token);
  52035. } else {
  52036. $this->parseArgument($token);
  52037. }
  52038. }
  52039. }
  52040. private function parseShortOption($token)
  52041. {
  52042. $name = substr($token, 1);
  52043. if (\strlen($name) > 1) {
  52044. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  52045. $this->addShortOption($name[0], substr($name, 1));
  52046. } else {
  52047. $this->parseShortOptionSet($name);
  52048. }
  52049. } else {
  52050. $this->addShortOption($name, null);
  52051. }
  52052. }
  52053. private function parseShortOptionSet($name)
  52054. {
  52055. $len = \strlen($name);
  52056. for ($i = 0; $i < $len; ++$i) {
  52057. if (!$this->definition->hasShortcut($name[$i])) {
  52058. $encoding = mb_detect_encoding($name, null, true);
  52059. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  52060. }
  52061. $option = $this->definition->getOptionForShortcut($name[$i]);
  52062. if ($option->acceptValue()) {
  52063. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  52064. break;
  52065. } else {
  52066. $this->addLongOption($option->getName(), null);
  52067. }
  52068. }
  52069. }
  52070. private function parseLongOption($token)
  52071. {
  52072. $name = substr($token, 2);
  52073. if (false !== $pos = strpos($name, '=')) {
  52074. if (0 === \strlen($value = substr($name, $pos + 1))) {
  52075. array_unshift($this->parsed, null);
  52076. }
  52077. $this->addLongOption(substr($name, 0, $pos), $value);
  52078. } else {
  52079. $this->addLongOption($name, null);
  52080. }
  52081. }
  52082. private function parseArgument($token)
  52083. {
  52084. $c = \count($this->arguments);
  52085. if ($this->definition->hasArgument($c)) {
  52086. $arg = $this->definition->getArgument($c);
  52087. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  52088. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  52089. $arg = $this->definition->getArgument($c - 1);
  52090. $this->arguments[$arg->getName()][] = $token;
  52091. } else {
  52092. $all = $this->definition->getArguments();
  52093. if (\count($all)) {
  52094. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  52095. }
  52096. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  52097. }
  52098. }
  52099. private function addShortOption($shortcut, $value)
  52100. {
  52101. if (!$this->definition->hasShortcut($shortcut)) {
  52102. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  52103. }
  52104. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52105. }
  52106. private function addLongOption($name, $value)
  52107. {
  52108. if (!$this->definition->hasOption($name)) {
  52109. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  52110. }
  52111. $option = $this->definition->getOption($name);
  52112. if (!isset($value[0])) {
  52113. $value = null;
  52114. }
  52115. if (null !== $value && !$option->acceptValue()) {
  52116. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  52117. }
  52118. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  52119. $next = array_shift($this->parsed);
  52120. if (isset($next[0]) && '-' !== $next[0]) {
  52121. $value = $next;
  52122. } elseif (empty($next)) {
  52123. $value = null;
  52124. } else {
  52125. array_unshift($this->parsed, $next);
  52126. }
  52127. }
  52128. if (null === $value) {
  52129. if ($option->isValueRequired()) {
  52130. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  52131. }
  52132. if (!$option->isArray()) {
  52133. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52134. }
  52135. }
  52136. if ($option->isArray()) {
  52137. $this->options[$name][] = $value;
  52138. } else {
  52139. $this->options[$name] = $value;
  52140. }
  52141. }
  52142. public function getFirstArgument()
  52143. {
  52144. foreach ($this->tokens as $token) {
  52145. if ($token && '-' === $token[0]) {
  52146. continue;
  52147. }
  52148. return $token;
  52149. }
  52150. }
  52151. public function hasParameterOption($values)
  52152. {
  52153. $values = (array) $values;
  52154. foreach ($this->tokens as $token) {
  52155. foreach ($values as $value) {
  52156. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52157. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  52158. return true;
  52159. }
  52160. }
  52161. }
  52162. return false;
  52163. }
  52164. public function getParameterOption($values, $default = false)
  52165. {
  52166. $values = (array) $values;
  52167. $tokens = $this->tokens;
  52168. while (0 < \count($tokens)) {
  52169. $token = array_shift($tokens);
  52170. foreach ($values as $value) {
  52171. if ($token === $value) {
  52172. return array_shift($tokens);
  52173. }
  52174. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52175. if ('' !== $leading && 0 === strpos($token, $leading)) {
  52176. return substr($token, \strlen($leading));
  52177. }
  52178. }
  52179. }
  52180. return $default;
  52181. }
  52182. public function __toString()
  52183. {
  52184. $self = $this;
  52185. $tokens = array_map(function ($token) use ($self) {
  52186. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  52187. return $match[1].$self->escapeToken($match[2]);
  52188. }
  52189. if ($token && '-' !== $token[0]) {
  52190. return $self->escapeToken($token);
  52191. }
  52192. return $token;
  52193. }, $this->tokens);
  52194. return implode(' ', $tokens);
  52195. }
  52196. }
  52197. <?php
  52198. namespace Symfony\Component\Console\Input;
  52199. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52200. use Symfony\Component\Console\Exception\InvalidOptionException;
  52201. class ArrayInput extends Input
  52202. {
  52203. private $parameters;
  52204. public function __construct(array $parameters, InputDefinition $definition = null)
  52205. {
  52206. $this->parameters = $parameters;
  52207. parent::__construct($definition);
  52208. }
  52209. public function getFirstArgument()
  52210. {
  52211. foreach ($this->parameters as $key => $value) {
  52212. if ($key && '-' === $key[0]) {
  52213. continue;
  52214. }
  52215. return $value;
  52216. }
  52217. }
  52218. public function hasParameterOption($values)
  52219. {
  52220. $values = (array) $values;
  52221. foreach ($this->parameters as $k => $v) {
  52222. if (!\is_int($k)) {
  52223. $v = $k;
  52224. }
  52225. if (\in_array($v, $values)) {
  52226. return true;
  52227. }
  52228. }
  52229. return false;
  52230. }
  52231. public function getParameterOption($values, $default = false)
  52232. {
  52233. $values = (array) $values;
  52234. foreach ($this->parameters as $k => $v) {
  52235. if (\is_int($k)) {
  52236. if (\in_array($v, $values)) {
  52237. return true;
  52238. }
  52239. } elseif (\in_array($k, $values)) {
  52240. return $v;
  52241. }
  52242. }
  52243. return $default;
  52244. }
  52245. public function __toString()
  52246. {
  52247. $params = array();
  52248. foreach ($this->parameters as $param => $val) {
  52249. if ($param && '-' === $param[0]) {
  52250. if (\is_array($val)) {
  52251. foreach ($val as $v) {
  52252. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  52253. }
  52254. } else {
  52255. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  52256. }
  52257. } else {
  52258. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  52259. }
  52260. }
  52261. return implode(' ', $params);
  52262. }
  52263. protected function parse()
  52264. {
  52265. foreach ($this->parameters as $key => $value) {
  52266. if (0 === strpos($key, '--')) {
  52267. $this->addLongOption(substr($key, 2), $value);
  52268. } elseif ('-' === $key[0]) {
  52269. $this->addShortOption(substr($key, 1), $value);
  52270. } else {
  52271. $this->addArgument($key, $value);
  52272. }
  52273. }
  52274. }
  52275. private function addShortOption($shortcut, $value)
  52276. {
  52277. if (!$this->definition->hasShortcut($shortcut)) {
  52278. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  52279. }
  52280. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52281. }
  52282. private function addLongOption($name, $value)
  52283. {
  52284. if (!$this->definition->hasOption($name)) {
  52285. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  52286. }
  52287. $option = $this->definition->getOption($name);
  52288. if (null === $value) {
  52289. if ($option->isValueRequired()) {
  52290. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  52291. }
  52292. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52293. }
  52294. $this->options[$name] = $value;
  52295. }
  52296. private function addArgument($name, $value)
  52297. {
  52298. if (!$this->definition->hasArgument($name)) {
  52299. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52300. }
  52301. $this->arguments[$name] = $value;
  52302. }
  52303. }
  52304. <?php
  52305. namespace Symfony\Component\Console\Input;
  52306. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52307. use Symfony\Component\Console\Exception\RuntimeException;
  52308. abstract class Input implements InputInterface
  52309. {
  52310. protected $definition;
  52311. protected $options = array();
  52312. protected $arguments = array();
  52313. protected $interactive = true;
  52314. public function __construct(InputDefinition $definition = null)
  52315. {
  52316. if (null === $definition) {
  52317. $this->definition = new InputDefinition();
  52318. } else {
  52319. $this->bind($definition);
  52320. $this->validate();
  52321. }
  52322. }
  52323. public function bind(InputDefinition $definition)
  52324. {
  52325. $this->arguments = array();
  52326. $this->options = array();
  52327. $this->definition = $definition;
  52328. $this->parse();
  52329. }
  52330. abstract protected function parse();
  52331. public function validate()
  52332. {
  52333. $definition = $this->definition;
  52334. $givenArguments = $this->arguments;
  52335. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  52336. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  52337. });
  52338. if (\count($missingArguments) > 0) {
  52339. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  52340. }
  52341. }
  52342. public function isInteractive()
  52343. {
  52344. return $this->interactive;
  52345. }
  52346. public function setInteractive($interactive)
  52347. {
  52348. $this->interactive = (bool) $interactive;
  52349. }
  52350. public function getArguments()
  52351. {
  52352. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  52353. }
  52354. public function getArgument($name)
  52355. {
  52356. if (!$this->definition->hasArgument($name)) {
  52357. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52358. }
  52359. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  52360. }
  52361. public function setArgument($name, $value)
  52362. {
  52363. if (!$this->definition->hasArgument($name)) {
  52364. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52365. }
  52366. $this->arguments[$name] = $value;
  52367. }
  52368. public function hasArgument($name)
  52369. {
  52370. return $this->definition->hasArgument($name);
  52371. }
  52372. public function getOptions()
  52373. {
  52374. return array_merge($this->definition->getOptionDefaults(), $this->options);
  52375. }
  52376. public function getOption($name)
  52377. {
  52378. if (!$this->definition->hasOption($name)) {
  52379. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  52380. }
  52381. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  52382. }
  52383. public function setOption($name, $value)
  52384. {
  52385. if (!$this->definition->hasOption($name)) {
  52386. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  52387. }
  52388. $this->options[$name] = $value;
  52389. }
  52390. public function hasOption($name)
  52391. {
  52392. return $this->definition->hasOption($name);
  52393. }
  52394. public function escapeToken($token)
  52395. {
  52396. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  52397. }
  52398. }
  52399. <?php
  52400. namespace Symfony\Component\Console\Input;
  52401. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52402. use Symfony\Component\Console\Exception\LogicException;
  52403. class InputArgument
  52404. {
  52405. const REQUIRED = 1;
  52406. const OPTIONAL = 2;
  52407. const IS_ARRAY = 4;
  52408. private $name;
  52409. private $mode;
  52410. private $default;
  52411. private $description;
  52412. public function __construct($name, $mode = null, $description = '', $default = null)
  52413. {
  52414. if (null === $mode) {
  52415. $mode = self::OPTIONAL;
  52416. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  52417. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  52418. }
  52419. $this->name = $name;
  52420. $this->mode = $mode;
  52421. $this->description = $description;
  52422. $this->setDefault($default);
  52423. }
  52424. public function getName()
  52425. {
  52426. return $this->name;
  52427. }
  52428. public function isRequired()
  52429. {
  52430. return self::REQUIRED === (self::REQUIRED & $this->mode);
  52431. }
  52432. public function isArray()
  52433. {
  52434. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  52435. }
  52436. public function setDefault($default = null)
  52437. {
  52438. if (self::REQUIRED === $this->mode && null !== $default) {
  52439. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  52440. }
  52441. if ($this->isArray()) {
  52442. if (null === $default) {
  52443. $default = array();
  52444. } elseif (!\is_array($default)) {
  52445. throw new LogicException('A default value for an array argument must be an array.');
  52446. }
  52447. }
  52448. $this->default = $default;
  52449. }
  52450. public function getDefault()
  52451. {
  52452. return $this->default;
  52453. }
  52454. public function getDescription()
  52455. {
  52456. return $this->description;
  52457. }
  52458. }
  52459. <?php
  52460. namespace Symfony\Component\Console\Input;
  52461. interface InputAwareInterface
  52462. {
  52463. public function setInput(InputInterface $input);
  52464. }
  52465. <?php
  52466. namespace Symfony\Component\Console\Input;
  52467. use Symfony\Component\Console\Descriptor\TextDescriptor;
  52468. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  52469. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52470. use Symfony\Component\Console\Exception\LogicException;
  52471. use Symfony\Component\Console\Output\BufferedOutput;
  52472. class InputDefinition
  52473. {
  52474. private $arguments;
  52475. private $requiredCount;
  52476. private $hasAnArrayArgument = false;
  52477. private $hasOptional;
  52478. private $options;
  52479. private $shortcuts;
  52480. public function __construct(array $definition = array())
  52481. {
  52482. $this->setDefinition($definition);
  52483. }
  52484. public function setDefinition(array $definition)
  52485. {
  52486. $arguments = array();
  52487. $options = array();
  52488. foreach ($definition as $item) {
  52489. if ($item instanceof InputOption) {
  52490. $options[] = $item;
  52491. } else {
  52492. $arguments[] = $item;
  52493. }
  52494. }
  52495. $this->setArguments($arguments);
  52496. $this->setOptions($options);
  52497. }
  52498. public function setArguments($arguments = array())
  52499. {
  52500. $this->arguments = array();
  52501. $this->requiredCount = 0;
  52502. $this->hasOptional = false;
  52503. $this->hasAnArrayArgument = false;
  52504. $this->addArguments($arguments);
  52505. }
  52506. public function addArguments($arguments = array())
  52507. {
  52508. if (null !== $arguments) {
  52509. foreach ($arguments as $argument) {
  52510. $this->addArgument($argument);
  52511. }
  52512. }
  52513. }
  52514. public function addArgument(InputArgument $argument)
  52515. {
  52516. if (isset($this->arguments[$argument->getName()])) {
  52517. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  52518. }
  52519. if ($this->hasAnArrayArgument) {
  52520. throw new LogicException('Cannot add an argument after an array argument.');
  52521. }
  52522. if ($argument->isRequired() && $this->hasOptional) {
  52523. throw new LogicException('Cannot add a required argument after an optional one.');
  52524. }
  52525. if ($argument->isArray()) {
  52526. $this->hasAnArrayArgument = true;
  52527. }
  52528. if ($argument->isRequired()) {
  52529. ++$this->requiredCount;
  52530. } else {
  52531. $this->hasOptional = true;
  52532. }
  52533. $this->arguments[$argument->getName()] = $argument;
  52534. }
  52535. public function getArgument($name)
  52536. {
  52537. if (!$this->hasArgument($name)) {
  52538. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52539. }
  52540. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  52541. return $arguments[$name];
  52542. }
  52543. public function hasArgument($name)
  52544. {
  52545. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  52546. return isset($arguments[$name]);
  52547. }
  52548. public function getArguments()
  52549. {
  52550. return $this->arguments;
  52551. }
  52552. public function getArgumentCount()
  52553. {
  52554. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  52555. }
  52556. public function getArgumentRequiredCount()
  52557. {
  52558. return $this->requiredCount;
  52559. }
  52560. public function getArgumentDefaults()
  52561. {
  52562. $values = array();
  52563. foreach ($this->arguments as $argument) {
  52564. $values[$argument->getName()] = $argument->getDefault();
  52565. }
  52566. return $values;
  52567. }
  52568. public function setOptions($options = array())
  52569. {
  52570. $this->options = array();
  52571. $this->shortcuts = array();
  52572. $this->addOptions($options);
  52573. }
  52574. public function addOptions($options = array())
  52575. {
  52576. foreach ($options as $option) {
  52577. $this->addOption($option);
  52578. }
  52579. }
  52580. public function addOption(InputOption $option)
  52581. {
  52582. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  52583. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  52584. }
  52585. if ($option->getShortcut()) {
  52586. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  52587. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  52588. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  52589. }
  52590. }
  52591. }
  52592. $this->options[$option->getName()] = $option;
  52593. if ($option->getShortcut()) {
  52594. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  52595. $this->shortcuts[$shortcut] = $option->getName();
  52596. }
  52597. }
  52598. }
  52599. public function getOption($name)
  52600. {
  52601. if (!$this->hasOption($name)) {
  52602. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  52603. }
  52604. return $this->options[$name];
  52605. }
  52606. public function hasOption($name)
  52607. {
  52608. return isset($this->options[$name]);
  52609. }
  52610. public function getOptions()
  52611. {
  52612. return $this->options;
  52613. }
  52614. public function hasShortcut($name)
  52615. {
  52616. return isset($this->shortcuts[$name]);
  52617. }
  52618. public function getOptionForShortcut($shortcut)
  52619. {
  52620. return $this->getOption($this->shortcutToName($shortcut));
  52621. }
  52622. public function getOptionDefaults()
  52623. {
  52624. $values = array();
  52625. foreach ($this->options as $option) {
  52626. $values[$option->getName()] = $option->getDefault();
  52627. }
  52628. return $values;
  52629. }
  52630. private function shortcutToName($shortcut)
  52631. {
  52632. if (!isset($this->shortcuts[$shortcut])) {
  52633. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  52634. }
  52635. return $this->shortcuts[$shortcut];
  52636. }
  52637. public function getSynopsis($short = false)
  52638. {
  52639. $elements = array();
  52640. if ($short && $this->getOptions()) {
  52641. $elements[] = '[options]';
  52642. } elseif (!$short) {
  52643. foreach ($this->getOptions() as $option) {
  52644. $value = '';
  52645. if ($option->acceptValue()) {
  52646. $value = sprintf(
  52647. ' %s%s%s',
  52648. $option->isValueOptional() ? '[' : '',
  52649. strtoupper($option->getName()),
  52650. $option->isValueOptional() ? ']' : ''
  52651. );
  52652. }
  52653. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  52654. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  52655. }
  52656. }
  52657. if (\count($elements) && $this->getArguments()) {
  52658. $elements[] = '[--]';
  52659. }
  52660. foreach ($this->getArguments() as $argument) {
  52661. $element = '<'.$argument->getName().'>';
  52662. if (!$argument->isRequired()) {
  52663. $element = '['.$element.']';
  52664. } elseif ($argument->isArray()) {
  52665. $element .= ' ('.$element.')';
  52666. }
  52667. if ($argument->isArray()) {
  52668. $element .= '...';
  52669. }
  52670. $elements[] = $element;
  52671. }
  52672. return implode(' ', $elements);
  52673. }
  52674. public function asText()
  52675. {
  52676. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  52677. $descriptor = new TextDescriptor();
  52678. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  52679. $descriptor->describe($output, $this, array('raw_output' => true));
  52680. return $output->fetch();
  52681. }
  52682. public function asXml($asDom = false)
  52683. {
  52684. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  52685. $descriptor = new XmlDescriptor();
  52686. if ($asDom) {
  52687. return $descriptor->getInputDefinitionDocument($this);
  52688. }
  52689. $output = new BufferedOutput();
  52690. $descriptor->describe($output, $this);
  52691. return $output->fetch();
  52692. }
  52693. }
  52694. <?php
  52695. namespace Symfony\Component\Console\Input;
  52696. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52697. use Symfony\Component\Console\Exception\RuntimeException;
  52698. interface InputInterface
  52699. {
  52700. public function getFirstArgument();
  52701. public function hasParameterOption($values);
  52702. public function getParameterOption($values, $default = false);
  52703. public function bind(InputDefinition $definition);
  52704. public function validate();
  52705. public function getArguments();
  52706. public function getArgument($name);
  52707. public function setArgument($name, $value);
  52708. public function hasArgument($name);
  52709. public function getOptions();
  52710. public function getOption($name);
  52711. public function setOption($name, $value);
  52712. public function hasOption($name);
  52713. public function isInteractive();
  52714. public function setInteractive($interactive);
  52715. }
  52716. <?php
  52717. namespace Symfony\Component\Console\Input;
  52718. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52719. use Symfony\Component\Console\Exception\LogicException;
  52720. class InputOption
  52721. {
  52722. const VALUE_NONE = 1;
  52723. const VALUE_REQUIRED = 2;
  52724. const VALUE_OPTIONAL = 4;
  52725. const VALUE_IS_ARRAY = 8;
  52726. private $name;
  52727. private $shortcut;
  52728. private $mode;
  52729. private $default;
  52730. private $description;
  52731. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  52732. {
  52733. if (0 === strpos($name, '--')) {
  52734. $name = substr($name, 2);
  52735. }
  52736. if (empty($name)) {
  52737. throw new InvalidArgumentException('An option name cannot be empty.');
  52738. }
  52739. if (empty($shortcut)) {
  52740. $shortcut = null;
  52741. }
  52742. if (null !== $shortcut) {
  52743. if (\is_array($shortcut)) {
  52744. $shortcut = implode('|', $shortcut);
  52745. }
  52746. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  52747. $shortcuts = array_filter($shortcuts);
  52748. $shortcut = implode('|', $shortcuts);
  52749. if (empty($shortcut)) {
  52750. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  52751. }
  52752. }
  52753. if (null === $mode) {
  52754. $mode = self::VALUE_NONE;
  52755. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  52756. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  52757. }
  52758. $this->name = $name;
  52759. $this->shortcut = $shortcut;
  52760. $this->mode = $mode;
  52761. $this->description = $description;
  52762. if ($this->isArray() && !$this->acceptValue()) {
  52763. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  52764. }
  52765. $this->setDefault($default);
  52766. }
  52767. public function getShortcut()
  52768. {
  52769. return $this->shortcut;
  52770. }
  52771. public function getName()
  52772. {
  52773. return $this->name;
  52774. }
  52775. public function acceptValue()
  52776. {
  52777. return $this->isValueRequired() || $this->isValueOptional();
  52778. }
  52779. public function isValueRequired()
  52780. {
  52781. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  52782. }
  52783. public function isValueOptional()
  52784. {
  52785. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  52786. }
  52787. public function isArray()
  52788. {
  52789. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  52790. }
  52791. public function setDefault($default = null)
  52792. {
  52793. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  52794. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  52795. }
  52796. if ($this->isArray()) {
  52797. if (null === $default) {
  52798. $default = array();
  52799. } elseif (!\is_array($default)) {
  52800. throw new LogicException('A default value for an array option must be an array.');
  52801. }
  52802. }
  52803. $this->default = $this->acceptValue() ? $default : false;
  52804. }
  52805. public function getDefault()
  52806. {
  52807. return $this->default;
  52808. }
  52809. public function getDescription()
  52810. {
  52811. return $this->description;
  52812. }
  52813. public function equals(self $option)
  52814. {
  52815. return $option->getName() === $this->getName()
  52816. && $option->getShortcut() === $this->getShortcut()
  52817. && $option->getDefault() === $this->getDefault()
  52818. && $option->isArray() === $this->isArray()
  52819. && $option->isValueRequired() === $this->isValueRequired()
  52820. && $option->isValueOptional() === $this->isValueOptional()
  52821. ;
  52822. }
  52823. }
  52824. <?php
  52825. namespace Symfony\Component\Console\Input;
  52826. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52827. class StringInput extends ArgvInput
  52828. {
  52829. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  52830. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  52831. public function __construct($input, InputDefinition $definition = null)
  52832. {
  52833. if ($definition) {
  52834. @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);
  52835. }
  52836. parent::__construct(array(), null);
  52837. $this->setTokens($this->tokenize($input));
  52838. if (null !== $definition) {
  52839. $this->bind($definition);
  52840. }
  52841. }
  52842. private function tokenize($input)
  52843. {
  52844. $tokens = array();
  52845. $length = \strlen($input);
  52846. $cursor = 0;
  52847. while ($cursor < $length) {
  52848. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  52849. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  52850. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  52851. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  52852. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  52853. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  52854. $tokens[] = stripcslashes($match[1]);
  52855. } else {
  52856. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  52857. }
  52858. $cursor += \strlen($match[0]);
  52859. }
  52860. return $tokens;
  52861. }
  52862. }
  52863. Copyright (c) 2004-2018 Fabien Potencier
  52864. Permission is hereby granted, free of charge, to any person obtaining a copy
  52865. of this software and associated documentation files (the "Software"), to deal
  52866. in the Software without restriction, including without limitation the rights
  52867. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  52868. copies of the Software, and to permit persons to whom the Software is furnished
  52869. to do so, subject to the following conditions:
  52870. The above copyright notice and this permission notice shall be included in all
  52871. copies or substantial portions of the Software.
  52872. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  52873. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  52874. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  52875. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  52876. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  52877. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  52878. THE SOFTWARE.
  52879. <?php
  52880. namespace Symfony\Component\Console\Logger;
  52881. use Psr\Log\AbstractLogger;
  52882. use Psr\Log\InvalidArgumentException;
  52883. use Psr\Log\LogLevel;
  52884. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  52885. use Symfony\Component\Console\Output\OutputInterface;
  52886. class ConsoleLogger extends AbstractLogger
  52887. {
  52888. const INFO = 'info';
  52889. const ERROR = 'error';
  52890. private $output;
  52891. private $verbosityLevelMap = array(
  52892. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  52893. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  52894. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  52895. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  52896. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  52897. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  52898. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  52899. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  52900. );
  52901. private $formatLevelMap = array(
  52902. LogLevel::EMERGENCY => self::ERROR,
  52903. LogLevel::ALERT => self::ERROR,
  52904. LogLevel::CRITICAL => self::ERROR,
  52905. LogLevel::ERROR => self::ERROR,
  52906. LogLevel::WARNING => self::INFO,
  52907. LogLevel::NOTICE => self::INFO,
  52908. LogLevel::INFO => self::INFO,
  52909. LogLevel::DEBUG => self::INFO,
  52910. );
  52911. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  52912. {
  52913. $this->output = $output;
  52914. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  52915. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  52916. }
  52917. public function log($level, $message, array $context = array())
  52918. {
  52919. if (!isset($this->verbosityLevelMap[$level])) {
  52920. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  52921. }
  52922. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  52923. $output = $this->output->getErrorOutput();
  52924. } else {
  52925. $output = $this->output;
  52926. }
  52927. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  52928. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  52929. }
  52930. }
  52931. private function interpolate($message, array $context)
  52932. {
  52933. $replace = array();
  52934. foreach ($context as $key => $val) {
  52935. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  52936. $replace[sprintf('{%s}', $key)] = $val;
  52937. }
  52938. }
  52939. return strtr($message, $replace);
  52940. }
  52941. }
  52942. <?php
  52943. namespace Symfony\Component\Console\Output;
  52944. class BufferedOutput extends Output
  52945. {
  52946. private $buffer = '';
  52947. public function fetch()
  52948. {
  52949. $content = $this->buffer;
  52950. $this->buffer = '';
  52951. return $content;
  52952. }
  52953. protected function doWrite($message, $newline)
  52954. {
  52955. $this->buffer .= $message;
  52956. if ($newline) {
  52957. $this->buffer .= PHP_EOL;
  52958. }
  52959. }
  52960. }
  52961. <?php
  52962. namespace Symfony\Component\Console\Output;
  52963. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  52964. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  52965. {
  52966. private $stderr;
  52967. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  52968. {
  52969. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  52970. $actualDecorated = $this->isDecorated();
  52971. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  52972. if (null === $decorated) {
  52973. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  52974. }
  52975. }
  52976. public function setDecorated($decorated)
  52977. {
  52978. parent::setDecorated($decorated);
  52979. $this->stderr->setDecorated($decorated);
  52980. }
  52981. public function setFormatter(OutputFormatterInterface $formatter)
  52982. {
  52983. parent::setFormatter($formatter);
  52984. $this->stderr->setFormatter($formatter);
  52985. }
  52986. public function setVerbosity($level)
  52987. {
  52988. parent::setVerbosity($level);
  52989. $this->stderr->setVerbosity($level);
  52990. }
  52991. public function getErrorOutput()
  52992. {
  52993. return $this->stderr;
  52994. }
  52995. public function setErrorOutput(OutputInterface $error)
  52996. {
  52997. $this->stderr = $error;
  52998. }
  52999. protected function hasStdoutSupport()
  53000. {
  53001. return false === $this->isRunningOS400();
  53002. }
  53003. protected function hasStderrSupport()
  53004. {
  53005. return false === $this->isRunningOS400();
  53006. }
  53007. private function isRunningOS400()
  53008. {
  53009. $checks = array(
  53010. \function_exists('php_uname') ? php_uname('s') : '',
  53011. getenv('OSTYPE'),
  53012. PHP_OS,
  53013. );
  53014. return false !== stripos(implode(';', $checks), 'OS400');
  53015. }
  53016. private function openOutputStream()
  53017. {
  53018. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  53019. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  53020. }
  53021. private function openErrorStream()
  53022. {
  53023. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  53024. return fopen($errorStream, 'w');
  53025. }
  53026. }
  53027. <?php
  53028. namespace Symfony\Component\Console\Output;
  53029. interface ConsoleOutputInterface extends OutputInterface
  53030. {
  53031. public function getErrorOutput();
  53032. public function setErrorOutput(OutputInterface $error);
  53033. }
  53034. <?php
  53035. namespace Symfony\Component\Console\Output;
  53036. use Symfony\Component\Console\Formatter\OutputFormatter;
  53037. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53038. class NullOutput implements OutputInterface
  53039. {
  53040. public function setFormatter(OutputFormatterInterface $formatter)
  53041. {
  53042. }
  53043. public function getFormatter()
  53044. {
  53045. return new OutputFormatter();
  53046. }
  53047. public function setDecorated($decorated)
  53048. {
  53049. }
  53050. public function isDecorated()
  53051. {
  53052. return false;
  53053. }
  53054. public function setVerbosity($level)
  53055. {
  53056. }
  53057. public function getVerbosity()
  53058. {
  53059. return self::VERBOSITY_QUIET;
  53060. }
  53061. public function isQuiet()
  53062. {
  53063. return true;
  53064. }
  53065. public function isVerbose()
  53066. {
  53067. return false;
  53068. }
  53069. public function isVeryVerbose()
  53070. {
  53071. return false;
  53072. }
  53073. public function isDebug()
  53074. {
  53075. return false;
  53076. }
  53077. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53078. {
  53079. }
  53080. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53081. {
  53082. }
  53083. }
  53084. <?php
  53085. namespace Symfony\Component\Console\Output;
  53086. use Symfony\Component\Console\Formatter\OutputFormatter;
  53087. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53088. abstract class Output implements OutputInterface
  53089. {
  53090. private $verbosity;
  53091. private $formatter;
  53092. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  53093. {
  53094. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  53095. $this->formatter = $formatter ?: new OutputFormatter();
  53096. $this->formatter->setDecorated($decorated);
  53097. }
  53098. public function setFormatter(OutputFormatterInterface $formatter)
  53099. {
  53100. $this->formatter = $formatter;
  53101. }
  53102. public function getFormatter()
  53103. {
  53104. return $this->formatter;
  53105. }
  53106. public function setDecorated($decorated)
  53107. {
  53108. $this->formatter->setDecorated($decorated);
  53109. }
  53110. public function isDecorated()
  53111. {
  53112. return $this->formatter->isDecorated();
  53113. }
  53114. public function setVerbosity($level)
  53115. {
  53116. $this->verbosity = (int) $level;
  53117. }
  53118. public function getVerbosity()
  53119. {
  53120. return $this->verbosity;
  53121. }
  53122. public function isQuiet()
  53123. {
  53124. return self::VERBOSITY_QUIET === $this->verbosity;
  53125. }
  53126. public function isVerbose()
  53127. {
  53128. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  53129. }
  53130. public function isVeryVerbose()
  53131. {
  53132. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  53133. }
  53134. public function isDebug()
  53135. {
  53136. return self::VERBOSITY_DEBUG <= $this->verbosity;
  53137. }
  53138. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53139. {
  53140. $this->write($messages, true, $options);
  53141. }
  53142. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53143. {
  53144. $messages = (array) $messages;
  53145. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  53146. $type = $types & $options ?: self::OUTPUT_NORMAL;
  53147. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  53148. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  53149. if ($verbosity > $this->getVerbosity()) {
  53150. return;
  53151. }
  53152. foreach ($messages as $message) {
  53153. switch ($type) {
  53154. case OutputInterface::OUTPUT_NORMAL:
  53155. $message = $this->formatter->format($message);
  53156. break;
  53157. case OutputInterface::OUTPUT_RAW:
  53158. break;
  53159. case OutputInterface::OUTPUT_PLAIN:
  53160. $message = strip_tags($this->formatter->format($message));
  53161. break;
  53162. }
  53163. $this->doWrite($message, $newline);
  53164. }
  53165. }
  53166. abstract protected function doWrite($message, $newline);
  53167. }
  53168. <?php
  53169. namespace Symfony\Component\Console\Output;
  53170. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53171. interface OutputInterface
  53172. {
  53173. const VERBOSITY_QUIET = 16;
  53174. const VERBOSITY_NORMAL = 32;
  53175. const VERBOSITY_VERBOSE = 64;
  53176. const VERBOSITY_VERY_VERBOSE = 128;
  53177. const VERBOSITY_DEBUG = 256;
  53178. const OUTPUT_NORMAL = 1;
  53179. const OUTPUT_RAW = 2;
  53180. const OUTPUT_PLAIN = 4;
  53181. public function write($messages, $newline = false, $options = 0);
  53182. public function writeln($messages, $options = 0);
  53183. public function setVerbosity($level);
  53184. public function getVerbosity();
  53185. public function setDecorated($decorated);
  53186. public function isDecorated();
  53187. public function setFormatter(OutputFormatterInterface $formatter);
  53188. public function getFormatter();
  53189. }
  53190. <?php
  53191. namespace Symfony\Component\Console\Output;
  53192. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53193. use Symfony\Component\Console\Exception\RuntimeException;
  53194. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53195. class StreamOutput extends Output
  53196. {
  53197. private $stream;
  53198. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  53199. {
  53200. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  53201. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  53202. }
  53203. $this->stream = $stream;
  53204. if (null === $decorated) {
  53205. $decorated = $this->hasColorSupport();
  53206. }
  53207. parent::__construct($verbosity, $decorated, $formatter);
  53208. }
  53209. public function getStream()
  53210. {
  53211. return $this->stream;
  53212. }
  53213. protected function doWrite($message, $newline)
  53214. {
  53215. if ($newline) {
  53216. $message .= PHP_EOL;
  53217. }
  53218. if (false === @fwrite($this->stream, $message)) {
  53219. throw new RuntimeException('Unable to write output.');
  53220. }
  53221. fflush($this->stream);
  53222. }
  53223. protected function hasColorSupport()
  53224. {
  53225. if ('Hyper' === getenv('TERM_PROGRAM')) {
  53226. return true;
  53227. }
  53228. if (\DIRECTORY_SEPARATOR === '\\') {
  53229. return (\function_exists('sapi_windows_vt100_support')
  53230. && @sapi_windows_vt100_support($this->stream))
  53231. || false !== getenv('ANSICON')
  53232. || 'ON' === getenv('ConEmuANSI')
  53233. || 'xterm' === getenv('TERM');
  53234. }
  53235. if (\function_exists('stream_isatty')) {
  53236. return @stream_isatty($this->stream);
  53237. }
  53238. if (\function_exists('posix_isatty')) {
  53239. return @posix_isatty($this->stream);
  53240. }
  53241. $stat = @fstat($this->stream);
  53242. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  53243. }
  53244. }
  53245. <?php
  53246. namespace Symfony\Component\Console\Question;
  53247. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53248. class ChoiceQuestion extends Question
  53249. {
  53250. private $choices;
  53251. private $multiselect = false;
  53252. private $prompt = ' > ';
  53253. private $errorMessage = 'Value "%s" is invalid';
  53254. public function __construct($question, array $choices, $default = null)
  53255. {
  53256. if (!$choices) {
  53257. throw new \LogicException('Choice question must have at least 1 choice available.');
  53258. }
  53259. parent::__construct($question, $default);
  53260. $this->choices = $choices;
  53261. $this->setValidator($this->getDefaultValidator());
  53262. $this->setAutocompleterValues($choices);
  53263. }
  53264. public function getChoices()
  53265. {
  53266. return $this->choices;
  53267. }
  53268. public function setMultiselect($multiselect)
  53269. {
  53270. $this->multiselect = $multiselect;
  53271. $this->setValidator($this->getDefaultValidator());
  53272. return $this;
  53273. }
  53274. public function isMultiselect()
  53275. {
  53276. return $this->multiselect;
  53277. }
  53278. public function getPrompt()
  53279. {
  53280. return $this->prompt;
  53281. }
  53282. public function setPrompt($prompt)
  53283. {
  53284. $this->prompt = $prompt;
  53285. return $this;
  53286. }
  53287. public function setErrorMessage($errorMessage)
  53288. {
  53289. $this->errorMessage = $errorMessage;
  53290. $this->setValidator($this->getDefaultValidator());
  53291. return $this;
  53292. }
  53293. private function getDefaultValidator()
  53294. {
  53295. $choices = $this->choices;
  53296. $errorMessage = $this->errorMessage;
  53297. $multiselect = $this->multiselect;
  53298. $isAssoc = $this->isAssoc($choices);
  53299. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  53300. $selectedChoices = str_replace(' ', '', $selected);
  53301. if ($multiselect) {
  53302. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  53303. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  53304. }
  53305. $selectedChoices = explode(',', $selectedChoices);
  53306. } else {
  53307. $selectedChoices = array($selected);
  53308. }
  53309. $multiselectChoices = array();
  53310. foreach ($selectedChoices as $value) {
  53311. $results = array();
  53312. foreach ($choices as $key => $choice) {
  53313. if ($choice === $value) {
  53314. $results[] = $key;
  53315. }
  53316. }
  53317. if (\count($results) > 1) {
  53318. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  53319. }
  53320. $result = array_search($value, $choices);
  53321. if (!$isAssoc) {
  53322. if (false !== $result) {
  53323. $result = $choices[$result];
  53324. } elseif (isset($choices[$value])) {
  53325. $result = $choices[$value];
  53326. }
  53327. } elseif (false === $result && isset($choices[$value])) {
  53328. $result = $value;
  53329. }
  53330. if (false === $result) {
  53331. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  53332. }
  53333. $multiselectChoices[] = (string) $result;
  53334. }
  53335. if ($multiselect) {
  53336. return $multiselectChoices;
  53337. }
  53338. return current($multiselectChoices);
  53339. };
  53340. }
  53341. }
  53342. <?php
  53343. namespace Symfony\Component\Console\Question;
  53344. class ConfirmationQuestion extends Question
  53345. {
  53346. private $trueAnswerRegex;
  53347. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  53348. {
  53349. parent::__construct($question, (bool) $default);
  53350. $this->trueAnswerRegex = $trueAnswerRegex;
  53351. $this->setNormalizer($this->getDefaultNormalizer());
  53352. }
  53353. private function getDefaultNormalizer()
  53354. {
  53355. $default = $this->getDefault();
  53356. $regex = $this->trueAnswerRegex;
  53357. return function ($answer) use ($default, $regex) {
  53358. if (\is_bool($answer)) {
  53359. return $answer;
  53360. }
  53361. $answerIsTrue = (bool) preg_match($regex, $answer);
  53362. if (false === $default) {
  53363. return $answer && $answerIsTrue;
  53364. }
  53365. return !$answer || $answerIsTrue;
  53366. };
  53367. }
  53368. }
  53369. <?php
  53370. namespace Symfony\Component\Console\Question;
  53371. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53372. use Symfony\Component\Console\Exception\LogicException;
  53373. class Question
  53374. {
  53375. private $question;
  53376. private $attempts;
  53377. private $hidden = false;
  53378. private $hiddenFallback = true;
  53379. private $autocompleterValues;
  53380. private $validator;
  53381. private $default;
  53382. private $normalizer;
  53383. public function __construct($question, $default = null)
  53384. {
  53385. $this->question = $question;
  53386. $this->default = $default;
  53387. }
  53388. public function getQuestion()
  53389. {
  53390. return $this->question;
  53391. }
  53392. public function getDefault()
  53393. {
  53394. return $this->default;
  53395. }
  53396. public function isHidden()
  53397. {
  53398. return $this->hidden;
  53399. }
  53400. public function setHidden($hidden)
  53401. {
  53402. if ($this->autocompleterValues) {
  53403. throw new LogicException('A hidden question cannot use the autocompleter.');
  53404. }
  53405. $this->hidden = (bool) $hidden;
  53406. return $this;
  53407. }
  53408. public function isHiddenFallback()
  53409. {
  53410. return $this->hiddenFallback;
  53411. }
  53412. public function setHiddenFallback($fallback)
  53413. {
  53414. $this->hiddenFallback = (bool) $fallback;
  53415. return $this;
  53416. }
  53417. public function getAutocompleterValues()
  53418. {
  53419. return $this->autocompleterValues;
  53420. }
  53421. public function setAutocompleterValues($values)
  53422. {
  53423. if (\is_array($values)) {
  53424. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  53425. }
  53426. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  53427. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  53428. }
  53429. if ($this->hidden) {
  53430. throw new LogicException('A hidden question cannot use the autocompleter.');
  53431. }
  53432. $this->autocompleterValues = $values;
  53433. return $this;
  53434. }
  53435. public function setValidator($validator)
  53436. {
  53437. $this->validator = $validator;
  53438. return $this;
  53439. }
  53440. public function getValidator()
  53441. {
  53442. return $this->validator;
  53443. }
  53444. public function setMaxAttempts($attempts)
  53445. {
  53446. if (null !== $attempts && $attempts < 1) {
  53447. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  53448. }
  53449. $this->attempts = $attempts;
  53450. return $this;
  53451. }
  53452. public function getMaxAttempts()
  53453. {
  53454. return $this->attempts;
  53455. }
  53456. public function setNormalizer($normalizer)
  53457. {
  53458. $this->normalizer = $normalizer;
  53459. return $this;
  53460. }
  53461. public function getNormalizer()
  53462. {
  53463. return $this->normalizer;
  53464. }
  53465. protected function isAssoc($array)
  53466. {
  53467. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  53468. }
  53469. }
  53470. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  53471. $�������Æ,Í;§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��������à�  ��
  53472. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  53473. ����������������� ��`.rdata����� ���
  53474. �����������������@��@.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
  53475. 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
  53476. 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
  53477. 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">
  53478. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  53479. <security>
  53480. <requestedPrivileges>
  53481. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  53482. </requestedPrivileges>
  53483. </security>
  53484. </trustInfo>
  53485. <dependency>
  53486. <dependentAssembly>
  53487. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  53488. </dependentAssembly>
  53489. </dependency>
  53490. </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
  53491. namespace Symfony\Component\Console;
  53492. use Symfony\Component\Console\Exception\RuntimeException;
  53493. use Symfony\Component\Console\Input\StringInput;
  53494. use Symfony\Component\Console\Output\ConsoleOutput;
  53495. use Symfony\Component\Process\PhpExecutableFinder;
  53496. use Symfony\Component\Process\ProcessBuilder;
  53497. class Shell
  53498. {
  53499. private $application;
  53500. private $history;
  53501. private $output;
  53502. private $hasReadline;
  53503. private $processIsolation = false;
  53504. public function __construct(Application $application)
  53505. {
  53506. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  53507. $this->hasReadline = \function_exists('readline');
  53508. $this->application = $application;
  53509. $this->history = getenv('HOME').'/.history_'.$application->getName();
  53510. $this->output = new ConsoleOutput();
  53511. }
  53512. public function run()
  53513. {
  53514. $this->application->setAutoExit(false);
  53515. $this->application->setCatchExceptions(true);
  53516. if ($this->hasReadline) {
  53517. readline_read_history($this->history);
  53518. readline_completion_function(array($this, 'autocompleter'));
  53519. }
  53520. $this->output->writeln($this->getHeader());
  53521. $php = null;
  53522. if ($this->processIsolation) {
  53523. $finder = new PhpExecutableFinder();
  53524. $php = $finder->find();
  53525. $this->output->writeln(<<<'EOF'
  53526. <info>Running with process isolation, you should consider this:</info>
  53527. * each command is executed as separate process,
  53528. * commands don't support interactivity, all params must be passed explicitly,
  53529. * commands output is not colorized.
  53530. EOF
  53531. );
  53532. }
  53533. while (true) {
  53534. $command = $this->readline();
  53535. if (false === $command) {
  53536. $this->output->writeln("\n");
  53537. break;
  53538. }
  53539. if ($this->hasReadline) {
  53540. readline_add_history($command);
  53541. readline_write_history($this->history);
  53542. }
  53543. if ($this->processIsolation) {
  53544. $pb = new ProcessBuilder();
  53545. $process = $pb
  53546. ->add($php)
  53547. ->add($_SERVER['argv'][0])
  53548. ->add($command)
  53549. ->inheritEnvironmentVariables(true)
  53550. ->getProcess()
  53551. ;
  53552. $output = $this->output;
  53553. $process->run(function ($type, $data) use ($output) {
  53554. $output->writeln($data);
  53555. });
  53556. $ret = $process->getExitCode();
  53557. } else {
  53558. $ret = $this->application->run(new StringInput($command), $this->output);
  53559. }
  53560. if (0 !== $ret) {
  53561. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  53562. }
  53563. }
  53564. }
  53565. protected function getHeader()
  53566. {
  53567. return <<<EOF
  53568. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  53569. At the prompt, type <comment>help</comment> for some help,
  53570. or <comment>list</comment> to get a list of available commands.
  53571. To exit the shell, type <comment>^D</comment>.
  53572. EOF;
  53573. }
  53574. protected function getPrompt()
  53575. {
  53576. return $this->output->getFormatter()->format($this->application->getName().' > ');
  53577. }
  53578. protected function getOutput()
  53579. {
  53580. return $this->output;
  53581. }
  53582. protected function getApplication()
  53583. {
  53584. return $this->application;
  53585. }
  53586. private function autocompleter($text)
  53587. {
  53588. $info = readline_info();
  53589. $text = substr($info['line_buffer'], 0, $info['end']);
  53590. if ($info['point'] !== $info['end']) {
  53591. return true;
  53592. }
  53593. if (false === strpos($text, ' ') || !$text) {
  53594. return array_keys($this->application->all());
  53595. }
  53596. try {
  53597. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  53598. } catch (\Exception $e) {
  53599. return true;
  53600. }
  53601. $list = array('--help');
  53602. foreach ($command->getDefinition()->getOptions() as $option) {
  53603. $list[] = '--'.$option->getName();
  53604. }
  53605. return $list;
  53606. }
  53607. private function readline()
  53608. {
  53609. if ($this->hasReadline) {
  53610. $line = readline($this->getPrompt());
  53611. } else {
  53612. $this->output->write($this->getPrompt());
  53613. $line = fgets(STDIN, 1024);
  53614. $line = (false === $line || '' === $line) ? false : rtrim($line);
  53615. }
  53616. return $line;
  53617. }
  53618. public function getProcessIsolation()
  53619. {
  53620. return $this->processIsolation;
  53621. }
  53622. public function setProcessIsolation($processIsolation)
  53623. {
  53624. $this->processIsolation = (bool) $processIsolation;
  53625. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  53626. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  53627. }
  53628. }
  53629. }
  53630. <?php
  53631. namespace Symfony\Component\Console\Style;
  53632. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53633. use Symfony\Component\Console\Helper\ProgressBar;
  53634. use Symfony\Component\Console\Output\OutputInterface;
  53635. abstract class OutputStyle implements OutputInterface, StyleInterface
  53636. {
  53637. private $output;
  53638. public function __construct(OutputInterface $output)
  53639. {
  53640. $this->output = $output;
  53641. }
  53642. public function newLine($count = 1)
  53643. {
  53644. $this->output->write(str_repeat(PHP_EOL, $count));
  53645. }
  53646. public function createProgressBar($max = 0)
  53647. {
  53648. return new ProgressBar($this->output, $max);
  53649. }
  53650. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  53651. {
  53652. $this->output->write($messages, $newline, $type);
  53653. }
  53654. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  53655. {
  53656. $this->output->writeln($messages, $type);
  53657. }
  53658. public function setVerbosity($level)
  53659. {
  53660. $this->output->setVerbosity($level);
  53661. }
  53662. public function getVerbosity()
  53663. {
  53664. return $this->output->getVerbosity();
  53665. }
  53666. public function setDecorated($decorated)
  53667. {
  53668. $this->output->setDecorated($decorated);
  53669. }
  53670. public function isDecorated()
  53671. {
  53672. return $this->output->isDecorated();
  53673. }
  53674. public function setFormatter(OutputFormatterInterface $formatter)
  53675. {
  53676. $this->output->setFormatter($formatter);
  53677. }
  53678. public function getFormatter()
  53679. {
  53680. return $this->output->getFormatter();
  53681. }
  53682. }
  53683. <?php
  53684. namespace Symfony\Component\Console\Style;
  53685. interface StyleInterface
  53686. {
  53687. public function title($message);
  53688. public function section($message);
  53689. public function listing(array $elements);
  53690. public function text($message);
  53691. public function success($message);
  53692. public function error($message);
  53693. public function warning($message);
  53694. public function note($message);
  53695. public function caution($message);
  53696. public function table(array $headers, array $rows);
  53697. public function ask($question, $default = null, $validator = null);
  53698. public function askHidden($question, $validator = null);
  53699. public function confirm($question, $default = true);
  53700. public function choice($question, array $choices, $default = null);
  53701. public function newLine($count = 1);
  53702. public function progressStart($max = 0);
  53703. public function progressAdvance($step = 1);
  53704. public function progressFinish();
  53705. }
  53706. <?php
  53707. namespace Symfony\Component\Console\Style;
  53708. use Symfony\Component\Console\Application;
  53709. use Symfony\Component\Console\Exception\RuntimeException;
  53710. use Symfony\Component\Console\Formatter\OutputFormatter;
  53711. use Symfony\Component\Console\Helper\Helper;
  53712. use Symfony\Component\Console\Helper\ProgressBar;
  53713. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  53714. use Symfony\Component\Console\Helper\Table;
  53715. use Symfony\Component\Console\Input\InputInterface;
  53716. use Symfony\Component\Console\Output\BufferedOutput;
  53717. use Symfony\Component\Console\Output\OutputInterface;
  53718. use Symfony\Component\Console\Question\ChoiceQuestion;
  53719. use Symfony\Component\Console\Question\ConfirmationQuestion;
  53720. use Symfony\Component\Console\Question\Question;
  53721. class SymfonyStyle extends OutputStyle
  53722. {
  53723. const MAX_LINE_LENGTH = 120;
  53724. private $input;
  53725. private $questionHelper;
  53726. private $progressBar;
  53727. private $lineLength;
  53728. private $bufferedOutput;
  53729. public function __construct(InputInterface $input, OutputInterface $output)
  53730. {
  53731. $this->input = $input;
  53732. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  53733. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  53734. parent::__construct($output);
  53735. }
  53736. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  53737. {
  53738. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  53739. $this->autoPrependBlock();
  53740. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  53741. $this->newLine();
  53742. }
  53743. public function title($message)
  53744. {
  53745. $this->autoPrependBlock();
  53746. $this->writeln(array(
  53747. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  53748. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  53749. ));
  53750. $this->newLine();
  53751. }
  53752. public function section($message)
  53753. {
  53754. $this->autoPrependBlock();
  53755. $this->writeln(array(
  53756. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  53757. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  53758. ));
  53759. $this->newLine();
  53760. }
  53761. public function listing(array $elements)
  53762. {
  53763. $this->autoPrependText();
  53764. $elements = array_map(function ($element) {
  53765. return sprintf(' * %s', $element);
  53766. }, $elements);
  53767. $this->writeln($elements);
  53768. $this->newLine();
  53769. }
  53770. public function text($message)
  53771. {
  53772. $this->autoPrependText();
  53773. $messages = \is_array($message) ? array_values($message) : array($message);
  53774. foreach ($messages as $message) {
  53775. $this->writeln(sprintf(' %s', $message));
  53776. }
  53777. }
  53778. public function comment($message)
  53779. {
  53780. $messages = \is_array($message) ? array_values($message) : array($message);
  53781. $this->autoPrependBlock();
  53782. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  53783. $this->newLine();
  53784. }
  53785. public function success($message)
  53786. {
  53787. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  53788. }
  53789. public function error($message)
  53790. {
  53791. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  53792. }
  53793. public function warning($message)
  53794. {
  53795. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  53796. }
  53797. public function note($message)
  53798. {
  53799. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  53800. }
  53801. public function caution($message)
  53802. {
  53803. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  53804. }
  53805. public function table(array $headers, array $rows)
  53806. {
  53807. $style = clone Table::getStyleDefinition('symfony-style-guide');
  53808. $style->setCellHeaderFormat('<info>%s</info>');
  53809. $table = new Table($this);
  53810. $table->setHeaders($headers);
  53811. $table->setRows($rows);
  53812. $table->setStyle($style);
  53813. $table->render();
  53814. $this->newLine();
  53815. }
  53816. public function ask($question, $default = null, $validator = null)
  53817. {
  53818. $question = new Question($question, $default);
  53819. $question->setValidator($validator);
  53820. return $this->askQuestion($question);
  53821. }
  53822. public function askHidden($question, $validator = null)
  53823. {
  53824. $question = new Question($question);
  53825. $question->setHidden(true);
  53826. $question->setValidator($validator);
  53827. return $this->askQuestion($question);
  53828. }
  53829. public function confirm($question, $default = true)
  53830. {
  53831. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  53832. }
  53833. public function choice($question, array $choices, $default = null)
  53834. {
  53835. if (null !== $default) {
  53836. $values = array_flip($choices);
  53837. $default = $values[$default];
  53838. }
  53839. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  53840. }
  53841. public function progressStart($max = 0)
  53842. {
  53843. $this->progressBar = $this->createProgressBar($max);
  53844. $this->progressBar->start();
  53845. }
  53846. public function progressAdvance($step = 1)
  53847. {
  53848. $this->getProgressBar()->advance($step);
  53849. }
  53850. public function progressFinish()
  53851. {
  53852. $this->getProgressBar()->finish();
  53853. $this->newLine(2);
  53854. $this->progressBar = null;
  53855. }
  53856. public function createProgressBar($max = 0)
  53857. {
  53858. $progressBar = parent::createProgressBar($max);
  53859. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  53860. $progressBar->setEmptyBarCharacter('â–‘');
  53861. $progressBar->setProgressCharacter('');
  53862. $progressBar->setBarCharacter('â–“');
  53863. }
  53864. return $progressBar;
  53865. }
  53866. public function askQuestion(Question $question)
  53867. {
  53868. if ($this->input->isInteractive()) {
  53869. $this->autoPrependBlock();
  53870. }
  53871. if (!$this->questionHelper) {
  53872. $this->questionHelper = new SymfonyQuestionHelper();
  53873. }
  53874. $answer = $this->questionHelper->ask($this->input, $this, $question);
  53875. if ($this->input->isInteractive()) {
  53876. $this->newLine();
  53877. $this->bufferedOutput->write("\n");
  53878. }
  53879. return $answer;
  53880. }
  53881. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  53882. {
  53883. parent::writeln($messages, $type);
  53884. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  53885. }
  53886. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  53887. {
  53888. parent::write($messages, $newline, $type);
  53889. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  53890. }
  53891. public function newLine($count = 1)
  53892. {
  53893. parent::newLine($count);
  53894. $this->bufferedOutput->write(str_repeat("\n", $count));
  53895. }
  53896. private function getProgressBar()
  53897. {
  53898. if (!$this->progressBar) {
  53899. throw new RuntimeException('The ProgressBar is not started.');
  53900. }
  53901. return $this->progressBar;
  53902. }
  53903. private function getTerminalWidth()
  53904. {
  53905. $application = new Application();
  53906. $dimensions = $application->getTerminalDimensions();
  53907. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  53908. }
  53909. private function autoPrependBlock()
  53910. {
  53911. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  53912. if (!isset($chars[0])) {
  53913. return $this->newLine();
  53914. }
  53915. $this->newLine(2 - substr_count($chars, "\n"));
  53916. }
  53917. private function autoPrependText()
  53918. {
  53919. $fetched = $this->bufferedOutput->fetch();
  53920. if ("\n" !== substr($fetched, -1)) {
  53921. $this->newLine();
  53922. }
  53923. }
  53924. private function reduceBuffer($messages)
  53925. {
  53926. return array_map(function ($value) {
  53927. return substr($value, -4);
  53928. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  53929. }
  53930. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  53931. {
  53932. $indentLength = 0;
  53933. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  53934. $lines = array();
  53935. if (null !== $type) {
  53936. $type = sprintf('[%s] ', $type);
  53937. $indentLength = \strlen($type);
  53938. $lineIndentation = str_repeat(' ', $indentLength);
  53939. }
  53940. foreach ($messages as $key => $message) {
  53941. if ($escape) {
  53942. $message = OutputFormatter::escape($message);
  53943. }
  53944. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  53945. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  53946. $lines[] = '';
  53947. }
  53948. }
  53949. $firstLineIndex = 0;
  53950. if ($padding && $this->isDecorated()) {
  53951. $firstLineIndex = 1;
  53952. array_unshift($lines, '');
  53953. $lines[] = '';
  53954. }
  53955. foreach ($lines as $i => &$line) {
  53956. if (null !== $type) {
  53957. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  53958. }
  53959. $line = $prefix.$line;
  53960. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  53961. if ($style) {
  53962. $line = sprintf('<%s>%s</>', $style, $line);
  53963. }
  53964. }
  53965. return $lines;
  53966. }
  53967. }
  53968. <?php
  53969. namespace Symfony\Component\Console\Tester;
  53970. use Symfony\Component\Console\Application;
  53971. use Symfony\Component\Console\Input\ArrayInput;
  53972. use Symfony\Component\Console\Input\InputInterface;
  53973. use Symfony\Component\Console\Output\OutputInterface;
  53974. use Symfony\Component\Console\Output\StreamOutput;
  53975. class ApplicationTester
  53976. {
  53977. private $application;
  53978. private $input;
  53979. private $output;
  53980. private $statusCode;
  53981. public function __construct(Application $application)
  53982. {
  53983. $this->application = $application;
  53984. }
  53985. public function run(array $input, $options = array())
  53986. {
  53987. $this->input = new ArrayInput($input);
  53988. if (isset($options['interactive'])) {
  53989. $this->input->setInteractive($options['interactive']);
  53990. }
  53991. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  53992. if (isset($options['decorated'])) {
  53993. $this->output->setDecorated($options['decorated']);
  53994. }
  53995. if (isset($options['verbosity'])) {
  53996. $this->output->setVerbosity($options['verbosity']);
  53997. }
  53998. return $this->statusCode = $this->application->run($this->input, $this->output);
  53999. }
  54000. public function getDisplay($normalize = false)
  54001. {
  54002. rewind($this->output->getStream());
  54003. $display = stream_get_contents($this->output->getStream());
  54004. if ($normalize) {
  54005. $display = str_replace(PHP_EOL, "\n", $display);
  54006. }
  54007. return $display;
  54008. }
  54009. public function getInput()
  54010. {
  54011. return $this->input;
  54012. }
  54013. public function getOutput()
  54014. {
  54015. return $this->output;
  54016. }
  54017. public function getStatusCode()
  54018. {
  54019. return $this->statusCode;
  54020. }
  54021. }
  54022. <?php
  54023. namespace Symfony\Component\Console\Tester;
  54024. use Symfony\Component\Console\Command\Command;
  54025. use Symfony\Component\Console\Input\ArrayInput;
  54026. use Symfony\Component\Console\Input\InputInterface;
  54027. use Symfony\Component\Console\Output\OutputInterface;
  54028. use Symfony\Component\Console\Output\StreamOutput;
  54029. class CommandTester
  54030. {
  54031. private $command;
  54032. private $input;
  54033. private $output;
  54034. private $statusCode;
  54035. public function __construct(Command $command)
  54036. {
  54037. $this->command = $command;
  54038. }
  54039. public function execute(array $input, array $options = array())
  54040. {
  54041. if (!isset($input['command'])
  54042. && (null !== $application = $this->command->getApplication())
  54043. && $application->getDefinition()->hasArgument('command')
  54044. ) {
  54045. $input = array_merge(array('command' => $this->command->getName()), $input);
  54046. }
  54047. $this->input = new ArrayInput($input);
  54048. if (isset($options['interactive'])) {
  54049. $this->input->setInteractive($options['interactive']);
  54050. }
  54051. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  54052. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  54053. if (isset($options['verbosity'])) {
  54054. $this->output->setVerbosity($options['verbosity']);
  54055. }
  54056. return $this->statusCode = $this->command->run($this->input, $this->output);
  54057. }
  54058. public function getDisplay($normalize = false)
  54059. {
  54060. rewind($this->output->getStream());
  54061. $display = stream_get_contents($this->output->getStream());
  54062. if ($normalize) {
  54063. $display = str_replace(PHP_EOL, "\n", $display);
  54064. }
  54065. return $display;
  54066. }
  54067. public function getInput()
  54068. {
  54069. return $this->input;
  54070. }
  54071. public function getOutput()
  54072. {
  54073. return $this->output;
  54074. }
  54075. public function getStatusCode()
  54076. {
  54077. return $this->statusCode;
  54078. }
  54079. }
  54080. <?php
  54081. namespace Symfony\Component\Debug;
  54082. use Psr\Log\AbstractLogger;
  54083. class BufferingLogger extends AbstractLogger
  54084. {
  54085. private $logs = array();
  54086. public function log($level, $message, array $context = array())
  54087. {
  54088. $this->logs[] = array($level, $message, $context);
  54089. }
  54090. public function cleanLogs()
  54091. {
  54092. $logs = $this->logs;
  54093. $this->logs = array();
  54094. return $logs;
  54095. }
  54096. }
  54097. <?php
  54098. namespace Symfony\Component\Debug;
  54099. class Debug
  54100. {
  54101. private static $enabled = false;
  54102. public static function enable($errorReportingLevel = null, $displayErrors = true)
  54103. {
  54104. if (static::$enabled) {
  54105. return;
  54106. }
  54107. static::$enabled = true;
  54108. if (null !== $errorReportingLevel) {
  54109. error_reporting($errorReportingLevel);
  54110. } else {
  54111. error_reporting(-1);
  54112. }
  54113. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  54114. ini_set('display_errors', 0);
  54115. ExceptionHandler::register();
  54116. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  54117. ini_set('display_errors', 1);
  54118. }
  54119. if ($displayErrors) {
  54120. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  54121. } else {
  54122. ErrorHandler::register()->throwAt(0, true);
  54123. }
  54124. DebugClassLoader::enable();
  54125. }
  54126. }
  54127. <?php
  54128. namespace Symfony\Component\Debug;
  54129. class DebugClassLoader
  54130. {
  54131. private $classLoader;
  54132. private $isFinder;
  54133. private $loaded = array();
  54134. private $wasFinder;
  54135. private static $caseCheck;
  54136. private static $deprecated = array();
  54137. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  54138. private static $darwinCache = array('/' => array('/', array()));
  54139. public function __construct($classLoader)
  54140. {
  54141. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  54142. if ($this->wasFinder) {
  54143. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  54144. $this->classLoader = array($classLoader, 'loadClass');
  54145. $this->isFinder = true;
  54146. } else {
  54147. $this->classLoader = $classLoader;
  54148. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  54149. }
  54150. if (!isset(self::$caseCheck)) {
  54151. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  54152. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  54153. $dir = substr($file, 0, 1 + $i);
  54154. $file = substr($file, 1 + $i);
  54155. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  54156. $test = realpath($dir.$test);
  54157. if (false === $test || false === $i) {
  54158. self::$caseCheck = 0;
  54159. } elseif (substr($test, -\strlen($file)) === $file) {
  54160. self::$caseCheck = 1;
  54161. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  54162. self::$caseCheck = 2;
  54163. } else {
  54164. self::$caseCheck = 0;
  54165. }
  54166. }
  54167. }
  54168. public function getClassLoader()
  54169. {
  54170. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  54171. }
  54172. public static function enable()
  54173. {
  54174. class_exists('Symfony\Component\Debug\ErrorHandler');
  54175. class_exists('Psr\Log\LogLevel');
  54176. if (!\is_array($functions = spl_autoload_functions())) {
  54177. return;
  54178. }
  54179. foreach ($functions as $function) {
  54180. spl_autoload_unregister($function);
  54181. }
  54182. foreach ($functions as $function) {
  54183. if (!\is_array($function) || !$function[0] instanceof self) {
  54184. $function = array(new static($function), 'loadClass');
  54185. }
  54186. spl_autoload_register($function);
  54187. }
  54188. }
  54189. public static function disable()
  54190. {
  54191. if (!\is_array($functions = spl_autoload_functions())) {
  54192. return;
  54193. }
  54194. foreach ($functions as $function) {
  54195. spl_autoload_unregister($function);
  54196. }
  54197. foreach ($functions as $function) {
  54198. if (\is_array($function) && $function[0] instanceof self) {
  54199. $function = $function[0]->getClassLoader();
  54200. }
  54201. spl_autoload_register($function);
  54202. }
  54203. }
  54204. public function findFile($class)
  54205. {
  54206. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  54207. if ($this->wasFinder) {
  54208. return $this->classLoader[0]->findFile($class);
  54209. }
  54210. }
  54211. public function loadClass($class)
  54212. {
  54213. ErrorHandler::stackErrors();
  54214. try {
  54215. if ($this->isFinder && !isset($this->loaded[$class])) {
  54216. $this->loaded[$class] = true;
  54217. if ($file = $this->classLoader[0]->findFile($class)) {
  54218. require $file;
  54219. }
  54220. } else {
  54221. \call_user_func($this->classLoader, $class);
  54222. $file = false;
  54223. }
  54224. } catch (\Exception $e) {
  54225. ErrorHandler::unstackErrors();
  54226. throw $e;
  54227. } catch (\Throwable $e) {
  54228. ErrorHandler::unstackErrors();
  54229. throw $e;
  54230. }
  54231. ErrorHandler::unstackErrors();
  54232. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  54233. if ($class && '\\' === $class[0]) {
  54234. $class = substr($class, 1);
  54235. }
  54236. if ($exists) {
  54237. $refl = new \ReflectionClass($class);
  54238. $name = $refl->getName();
  54239. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  54240. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  54241. }
  54242. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  54243. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  54244. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  54245. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  54246. } else {
  54247. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  54248. $len = 0;
  54249. $ns = '';
  54250. } else {
  54251. $ns = substr($name, 0, $len);
  54252. }
  54253. $parent = get_parent_class($class);
  54254. if (!$parent || strncmp($ns, $parent, $len)) {
  54255. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  54256. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  54257. }
  54258. $parentInterfaces = array();
  54259. $deprecatedInterfaces = array();
  54260. if ($parent) {
  54261. foreach (class_implements($parent) as $interface) {
  54262. $parentInterfaces[$interface] = 1;
  54263. }
  54264. }
  54265. foreach ($refl->getInterfaceNames() as $interface) {
  54266. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  54267. $deprecatedInterfaces[] = $interface;
  54268. }
  54269. foreach (class_implements($interface) as $interface) {
  54270. $parentInterfaces[$interface] = 1;
  54271. }
  54272. }
  54273. foreach ($deprecatedInterfaces as $interface) {
  54274. if (!isset($parentInterfaces[$interface])) {
  54275. @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);
  54276. }
  54277. }
  54278. }
  54279. }
  54280. }
  54281. if ($file) {
  54282. if (!$exists) {
  54283. if (false !== strpos($class, '/')) {
  54284. 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));
  54285. }
  54286. 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));
  54287. }
  54288. if (self::$caseCheck) {
  54289. $real = explode('\\', $class.strrchr($file, '.'));
  54290. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  54291. $i = \count($tail) - 1;
  54292. $j = \count($real) - 1;
  54293. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  54294. --$i;
  54295. --$j;
  54296. }
  54297. array_splice($tail, 0, $i + 1);
  54298. }
  54299. if (self::$caseCheck && $tail) {
  54300. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  54301. $tailLen = \strlen($tail);
  54302. $real = $refl->getFileName();
  54303. if (2 === self::$caseCheck) {
  54304. $i = 1 + strrpos($real, '/');
  54305. $file = substr($real, $i);
  54306. $real = substr($real, 0, $i);
  54307. if (isset(self::$darwinCache[$real])) {
  54308. $kDir = $real;
  54309. } else {
  54310. $kDir = strtolower($real);
  54311. if (isset(self::$darwinCache[$kDir])) {
  54312. $real = self::$darwinCache[$kDir][0];
  54313. } else {
  54314. $dir = getcwd();
  54315. chdir($real);
  54316. $real = getcwd().'/';
  54317. chdir($dir);
  54318. $dir = $real;
  54319. $k = $kDir;
  54320. $i = \strlen($dir) - 1;
  54321. while (!isset(self::$darwinCache[$k])) {
  54322. self::$darwinCache[$k] = array($dir, array());
  54323. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  54324. while ('/' !== $dir[--$i]) {
  54325. }
  54326. $k = substr($k, 0, ++$i);
  54327. $dir = substr($dir, 0, $i--);
  54328. }
  54329. }
  54330. }
  54331. $dirFiles = self::$darwinCache[$kDir][1];
  54332. if (isset($dirFiles[$file])) {
  54333. $kFile = $file;
  54334. } else {
  54335. $kFile = strtolower($file);
  54336. if (!isset($dirFiles[$kFile])) {
  54337. foreach (scandir($real, 2) as $f) {
  54338. if ('.' !== $f[0]) {
  54339. $dirFiles[$f] = $f;
  54340. if ($f === $file) {
  54341. $kFile = $k = $file;
  54342. } elseif ($f !== $k = strtolower($f)) {
  54343. $dirFiles[$k] = $f;
  54344. }
  54345. }
  54346. }
  54347. self::$darwinCache[$kDir][1] = $dirFiles;
  54348. }
  54349. }
  54350. $real .= $dirFiles[$kFile];
  54351. }
  54352. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  54353. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  54354. ) {
  54355. 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)));
  54356. }
  54357. }
  54358. return true;
  54359. }
  54360. }
  54361. }
  54362. <?php
  54363. namespace Symfony\Component\Debug;
  54364. use Psr\Log\LoggerInterface;
  54365. use Psr\Log\LogLevel;
  54366. use Symfony\Component\Debug\Exception\ContextErrorException;
  54367. use Symfony\Component\Debug\Exception\FatalErrorException;
  54368. use Symfony\Component\Debug\Exception\FatalThrowableError;
  54369. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  54370. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  54371. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  54372. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  54373. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  54374. class ErrorHandler
  54375. {
  54376. const TYPE_DEPRECATION = -100;
  54377. private $levels = array(
  54378. E_DEPRECATED => 'Deprecated',
  54379. E_USER_DEPRECATED => 'User Deprecated',
  54380. E_NOTICE => 'Notice',
  54381. E_USER_NOTICE => 'User Notice',
  54382. E_STRICT => 'Runtime Notice',
  54383. E_WARNING => 'Warning',
  54384. E_USER_WARNING => 'User Warning',
  54385. E_COMPILE_WARNING => 'Compile Warning',
  54386. E_CORE_WARNING => 'Core Warning',
  54387. E_USER_ERROR => 'User Error',
  54388. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  54389. E_COMPILE_ERROR => 'Compile Error',
  54390. E_PARSE => 'Parse Error',
  54391. E_ERROR => 'Error',
  54392. E_CORE_ERROR => 'Core Error',
  54393. );
  54394. private $loggers = array(
  54395. E_DEPRECATED => array(null, LogLevel::INFO),
  54396. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  54397. E_NOTICE => array(null, LogLevel::WARNING),
  54398. E_USER_NOTICE => array(null, LogLevel::WARNING),
  54399. E_STRICT => array(null, LogLevel::WARNING),
  54400. E_WARNING => array(null, LogLevel::WARNING),
  54401. E_USER_WARNING => array(null, LogLevel::WARNING),
  54402. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  54403. E_CORE_WARNING => array(null, LogLevel::WARNING),
  54404. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  54405. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  54406. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  54407. E_PARSE => array(null, LogLevel::CRITICAL),
  54408. E_ERROR => array(null, LogLevel::CRITICAL),
  54409. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  54410. );
  54411. private $thrownErrors = 0x1FFF;
  54412. private $scopedErrors = 0x1FFF;
  54413. private $tracedErrors = 0x77FB;
  54414. private $screamedErrors = 0x55;
  54415. private $loggedErrors = 0;
  54416. private $loggedTraces = array();
  54417. private $isRecursive = 0;
  54418. private $isRoot = false;
  54419. private $exceptionHandler;
  54420. private $bootstrappingLogger;
  54421. private static $reservedMemory;
  54422. private static $stackedErrors = array();
  54423. private static $stackedErrorLevels = array();
  54424. private static $toStringException = null;
  54425. private static $exitCode = 0;
  54426. private $displayErrors = 0x1FFF;
  54427. public static function register($handler = null, $replace = true)
  54428. {
  54429. if (null === self::$reservedMemory) {
  54430. self::$reservedMemory = str_repeat('x', 10240);
  54431. register_shutdown_function(__CLASS__.'::handleFatalError');
  54432. }
  54433. $levels = -1;
  54434. if ($handlerIsNew = !$handler instanceof self) {
  54435. if (null !== $handler) {
  54436. $levels = $replace ? $handler : 0;
  54437. $replace = true;
  54438. }
  54439. $handler = new static();
  54440. }
  54441. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  54442. restore_error_handler();
  54443. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  54444. $handler->isRoot = true;
  54445. }
  54446. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  54447. $handler = $prev[0];
  54448. $replace = false;
  54449. }
  54450. if (!$replace && $prev) {
  54451. restore_error_handler();
  54452. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  54453. } else {
  54454. $handlerIsRegistered = true;
  54455. }
  54456. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  54457. restore_exception_handler();
  54458. if (!$handlerIsRegistered) {
  54459. $handler = $prev[0];
  54460. } elseif ($handler !== $prev[0] && $replace) {
  54461. set_exception_handler(array($handler, 'handleException'));
  54462. $p = $prev[0]->setExceptionHandler(null);
  54463. $handler->setExceptionHandler($p);
  54464. $prev[0]->setExceptionHandler($p);
  54465. }
  54466. } else {
  54467. $handler->setExceptionHandler($prev);
  54468. }
  54469. $handler->throwAt($levels & $handler->thrownErrors, true);
  54470. return $handler;
  54471. }
  54472. public function __construct(BufferingLogger $bootstrappingLogger = null)
  54473. {
  54474. if ($bootstrappingLogger) {
  54475. $this->bootstrappingLogger = $bootstrappingLogger;
  54476. $this->setDefaultLogger($bootstrappingLogger);
  54477. }
  54478. }
  54479. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  54480. {
  54481. $loggers = array();
  54482. if (\is_array($levels)) {
  54483. foreach ($levels as $type => $logLevel) {
  54484. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  54485. $loggers[$type] = array($logger, $logLevel);
  54486. }
  54487. }
  54488. } else {
  54489. if (null === $levels) {
  54490. $levels = E_ALL | E_STRICT;
  54491. }
  54492. foreach ($this->loggers as $type => $log) {
  54493. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  54494. $log[0] = $logger;
  54495. $loggers[$type] = $log;
  54496. }
  54497. }
  54498. }
  54499. $this->setLoggers($loggers);
  54500. }
  54501. public function setLoggers(array $loggers)
  54502. {
  54503. $prevLogged = $this->loggedErrors;
  54504. $prev = $this->loggers;
  54505. $flush = array();
  54506. foreach ($loggers as $type => $log) {
  54507. if (!isset($prev[$type])) {
  54508. throw new \InvalidArgumentException('Unknown error type: '.$type);
  54509. }
  54510. if (!\is_array($log)) {
  54511. $log = array($log);
  54512. } elseif (!array_key_exists(0, $log)) {
  54513. throw new \InvalidArgumentException('No logger provided');
  54514. }
  54515. if (null === $log[0]) {
  54516. $this->loggedErrors &= ~$type;
  54517. } elseif ($log[0] instanceof LoggerInterface) {
  54518. $this->loggedErrors |= $type;
  54519. } else {
  54520. throw new \InvalidArgumentException('Invalid logger provided');
  54521. }
  54522. $this->loggers[$type] = $log + $prev[$type];
  54523. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  54524. $flush[$type] = $type;
  54525. }
  54526. }
  54527. $this->reRegister($prevLogged | $this->thrownErrors);
  54528. if ($flush) {
  54529. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  54530. $type = $log[2]['type'];
  54531. if (!isset($flush[$type])) {
  54532. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  54533. } elseif ($this->loggers[$type][0]) {
  54534. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  54535. }
  54536. }
  54537. }
  54538. return $prev;
  54539. }
  54540. public function setExceptionHandler($handler)
  54541. {
  54542. if (null !== $handler && !\is_callable($handler)) {
  54543. throw new \LogicException('The exception handler must be a valid PHP callable.');
  54544. }
  54545. $prev = $this->exceptionHandler;
  54546. $this->exceptionHandler = $handler;
  54547. return $prev;
  54548. }
  54549. public function throwAt($levels, $replace = false)
  54550. {
  54551. $prev = $this->thrownErrors;
  54552. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  54553. if (!$replace) {
  54554. $this->thrownErrors |= $prev;
  54555. }
  54556. $this->reRegister($prev | $this->loggedErrors);
  54557. $this->displayErrors = $this->thrownErrors;
  54558. return $prev;
  54559. }
  54560. public function scopeAt($levels, $replace = false)
  54561. {
  54562. $prev = $this->scopedErrors;
  54563. $this->scopedErrors = (int) $levels;
  54564. if (!$replace) {
  54565. $this->scopedErrors |= $prev;
  54566. }
  54567. return $prev;
  54568. }
  54569. public function traceAt($levels, $replace = false)
  54570. {
  54571. $prev = $this->tracedErrors;
  54572. $this->tracedErrors = (int) $levels;
  54573. if (!$replace) {
  54574. $this->tracedErrors |= $prev;
  54575. }
  54576. return $prev;
  54577. }
  54578. public function screamAt($levels, $replace = false)
  54579. {
  54580. $prev = $this->screamedErrors;
  54581. $this->screamedErrors = (int) $levels;
  54582. if (!$replace) {
  54583. $this->screamedErrors |= $prev;
  54584. }
  54585. return $prev;
  54586. }
  54587. private function reRegister($prev)
  54588. {
  54589. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  54590. $handler = set_error_handler('var_dump');
  54591. $handler = \is_array($handler) ? $handler[0] : null;
  54592. restore_error_handler();
  54593. if ($handler === $this) {
  54594. restore_error_handler();
  54595. if ($this->isRoot) {
  54596. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  54597. } else {
  54598. set_error_handler(array($this, 'handleError'));
  54599. }
  54600. }
  54601. }
  54602. }
  54603. public function handleError($type, $message, $file, $line)
  54604. {
  54605. $level = error_reporting();
  54606. $silenced = 0 === ($level & $type);
  54607. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  54608. $log = $this->loggedErrors & $type;
  54609. $throw = $this->thrownErrors & $type & $level;
  54610. $type &= $level | $this->screamedErrors;
  54611. if (!$type || (!$log && !$throw)) {
  54612. return !$silenced && $type && $log;
  54613. }
  54614. $scope = $this->scopedErrors & $type;
  54615. if (4 < $numArgs = \func_num_args()) {
  54616. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  54617. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  54618. } else {
  54619. $context = array();
  54620. $backtrace = null;
  54621. }
  54622. if (isset($context['GLOBALS']) && $scope) {
  54623. $e = $context;
  54624. unset($e['GLOBALS'], $context);
  54625. $context = $e;
  54626. }
  54627. if (null !== $backtrace && $type & E_ERROR) {
  54628. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  54629. return true;
  54630. }
  54631. if ($throw) {
  54632. if (null !== self::$toStringException) {
  54633. $throw = self::$toStringException;
  54634. self::$toStringException = null;
  54635. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  54636. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  54637. } else {
  54638. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  54639. }
  54640. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  54641. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  54642. }
  54643. if (E_USER_ERROR & $type) {
  54644. $backtrace = $backtrace ?: $throw->getTrace();
  54645. for ($i = 1; isset($backtrace[$i]); ++$i) {
  54646. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  54647. && '__toString' === $backtrace[$i]['function']
  54648. && '->' === $backtrace[$i]['type']
  54649. && !isset($backtrace[$i - 1]['class'])
  54650. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  54651. ) {
  54652. foreach ($context as $e) {
  54653. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  54654. if (1 === $i) {
  54655. $throw = $e;
  54656. break;
  54657. }
  54658. self::$toStringException = $e;
  54659. return true;
  54660. }
  54661. }
  54662. if (1 < $i) {
  54663. $this->handleException($throw);
  54664. return false;
  54665. }
  54666. }
  54667. }
  54668. }
  54669. throw $throw;
  54670. }
  54671. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  54672. $trace = true;
  54673. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  54674. $trace = false;
  54675. } else {
  54676. $this->loggedTraces[$e] = 1;
  54677. }
  54678. $e = compact('type', 'file', 'line', 'level');
  54679. if ($type & $level) {
  54680. if ($scope) {
  54681. $e['scope_vars'] = $context;
  54682. if ($trace) {
  54683. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  54684. }
  54685. } elseif ($trace) {
  54686. if (null === $backtrace) {
  54687. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  54688. } else {
  54689. foreach ($backtrace as &$frame) {
  54690. unset($frame['args'], $frame);
  54691. }
  54692. $e['stack'] = $backtrace;
  54693. }
  54694. }
  54695. }
  54696. if ($this->isRecursive) {
  54697. $log = 0;
  54698. } elseif (self::$stackedErrorLevels) {
  54699. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  54700. } else {
  54701. try {
  54702. $this->isRecursive = true;
  54703. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  54704. $this->isRecursive = false;
  54705. } catch (\Exception $e) {
  54706. $this->isRecursive = false;
  54707. throw $e;
  54708. } catch (\Throwable $e) {
  54709. $this->isRecursive = false;
  54710. throw $e;
  54711. }
  54712. }
  54713. return !$silenced && $type && $log;
  54714. }
  54715. public function handleException($exception, array $error = null)
  54716. {
  54717. if (null === $error) {
  54718. self::$exitCode = 255;
  54719. }
  54720. if (!$exception instanceof \Exception) {
  54721. $exception = new FatalThrowableError($exception);
  54722. }
  54723. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  54724. $handlerException = null;
  54725. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  54726. $e = array(
  54727. 'type' => $type,
  54728. 'file' => $exception->getFile(),
  54729. 'line' => $exception->getLine(),
  54730. 'level' => error_reporting(),
  54731. 'stack' => $exception->getTrace(),
  54732. );
  54733. if ($exception instanceof FatalErrorException) {
  54734. if ($exception instanceof FatalThrowableError) {
  54735. $error = array(
  54736. 'type' => $type,
  54737. 'message' => $message = $exception->getMessage(),
  54738. 'file' => $e['file'],
  54739. 'line' => $e['line'],
  54740. );
  54741. } else {
  54742. $message = 'Fatal '.$exception->getMessage();
  54743. }
  54744. } elseif ($exception instanceof \ErrorException) {
  54745. $message = 'Uncaught '.$exception->getMessage();
  54746. if ($exception instanceof ContextErrorException) {
  54747. $e['context'] = $exception->getContext();
  54748. }
  54749. } else {
  54750. $message = 'Uncaught Exception: '.$exception->getMessage();
  54751. }
  54752. }
  54753. if ($this->loggedErrors & $type) {
  54754. try {
  54755. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  54756. } catch (\Exception $handlerException) {
  54757. } catch (\Throwable $handlerException) {
  54758. }
  54759. }
  54760. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  54761. foreach ($this->getFatalErrorHandlers() as $handler) {
  54762. if ($e = $handler->handleError($error, $exception)) {
  54763. $exception = $e;
  54764. break;
  54765. }
  54766. }
  54767. }
  54768. $exceptionHandler = $this->exceptionHandler;
  54769. $this->exceptionHandler = null;
  54770. try {
  54771. if (null !== $exceptionHandler) {
  54772. return \call_user_func($exceptionHandler, $exception);
  54773. }
  54774. $handlerException = $handlerException ?: $exception;
  54775. } catch (\Exception $handlerException) {
  54776. } catch (\Throwable $handlerException) {
  54777. }
  54778. if ($exception === $handlerException) {
  54779. self::$reservedMemory = null;
  54780. throw $exception;
  54781. }
  54782. $this->handleException($handlerException);
  54783. }
  54784. public static function handleFatalError(array $error = null)
  54785. {
  54786. if (null === self::$reservedMemory) {
  54787. return;
  54788. }
  54789. $handler = self::$reservedMemory = null;
  54790. $handlers = array();
  54791. $previousHandler = null;
  54792. $sameHandlerLimit = 10;
  54793. while (!\is_array($handler) || !$handler[0] instanceof self) {
  54794. $handler = set_exception_handler('var_dump');
  54795. restore_exception_handler();
  54796. if (!$handler) {
  54797. break;
  54798. }
  54799. restore_exception_handler();
  54800. if ($handler !== $previousHandler) {
  54801. array_unshift($handlers, $handler);
  54802. $previousHandler = $handler;
  54803. } elseif (0 === --$sameHandlerLimit) {
  54804. $handler = null;
  54805. break;
  54806. }
  54807. }
  54808. foreach ($handlers as $h) {
  54809. set_exception_handler($h);
  54810. }
  54811. if (!$handler) {
  54812. return;
  54813. }
  54814. if ($handler !== $h) {
  54815. $handler[0]->setExceptionHandler($h);
  54816. }
  54817. $handler = $handler[0];
  54818. $handlers = array();
  54819. if ($exit = null === $error) {
  54820. $error = error_get_last();
  54821. }
  54822. try {
  54823. while (self::$stackedErrorLevels) {
  54824. static::unstackErrors();
  54825. }
  54826. } catch (\Exception $exception) {
  54827. } catch (\Throwable $exception) {
  54828. }
  54829. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  54830. $handler->throwAt(0, true);
  54831. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  54832. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  54833. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  54834. } else {
  54835. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  54836. }
  54837. }
  54838. try {
  54839. if (isset($exception)) {
  54840. self::$exitCode = 255;
  54841. $handler->handleException($exception, $error);
  54842. }
  54843. } catch (FatalErrorException $e) {
  54844. }
  54845. if ($exit && self::$exitCode) {
  54846. $exitCode = self::$exitCode;
  54847. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  54848. }
  54849. }
  54850. public static function stackErrors()
  54851. {
  54852. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  54853. }
  54854. public static function unstackErrors()
  54855. {
  54856. $level = array_pop(self::$stackedErrorLevels);
  54857. if (null !== $level) {
  54858. $e = error_reporting($level);
  54859. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  54860. error_reporting($e);
  54861. }
  54862. }
  54863. if (empty(self::$stackedErrorLevels)) {
  54864. $errors = self::$stackedErrors;
  54865. self::$stackedErrors = array();
  54866. foreach ($errors as $e) {
  54867. $e[0]->log($e[1], $e[2], $e[3]);
  54868. }
  54869. }
  54870. }
  54871. protected function getFatalErrorHandlers()
  54872. {
  54873. return array(
  54874. new UndefinedFunctionFatalErrorHandler(),
  54875. new UndefinedMethodFatalErrorHandler(),
  54876. new ClassNotFoundFatalErrorHandler(),
  54877. );
  54878. }
  54879. public function setLevel($level)
  54880. {
  54881. @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);
  54882. $level = null === $level ? error_reporting() : $level;
  54883. $this->throwAt($level, true);
  54884. }
  54885. public function setDisplayErrors($displayErrors)
  54886. {
  54887. @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);
  54888. if ($displayErrors) {
  54889. $this->throwAt($this->displayErrors, true);
  54890. } else {
  54891. $displayErrors = $this->displayErrors;
  54892. $this->throwAt(0, true);
  54893. $this->displayErrors = $displayErrors;
  54894. }
  54895. }
  54896. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  54897. {
  54898. @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);
  54899. $handler = set_error_handler('var_dump');
  54900. $handler = \is_array($handler) ? $handler[0] : null;
  54901. restore_error_handler();
  54902. if (!$handler instanceof self) {
  54903. return;
  54904. }
  54905. if ('deprecation' === $channel) {
  54906. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  54907. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  54908. } elseif ('scream' === $channel) {
  54909. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  54910. $handler->screamAt(E_ALL | E_STRICT);
  54911. } elseif ('emergency' === $channel) {
  54912. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  54913. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  54914. }
  54915. }
  54916. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  54917. {
  54918. $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());
  54919. return $this->handleError($level, $message, $file, $line, (array) $context);
  54920. }
  54921. public function handleFatal()
  54922. {
  54923. @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);
  54924. static::handleFatalError();
  54925. }
  54926. }
  54927. class ErrorHandlerCanary
  54928. {
  54929. private static $displayErrors = null;
  54930. public function __construct()
  54931. {
  54932. if (null === self::$displayErrors) {
  54933. self::$displayErrors = ini_set('display_errors', 1);
  54934. }
  54935. }
  54936. public function __destruct()
  54937. {
  54938. if (null !== self::$displayErrors) {
  54939. ini_set('display_errors', self::$displayErrors);
  54940. self::$displayErrors = null;
  54941. }
  54942. }
  54943. }
  54944. <?php
  54945. namespace Symfony\Component\Debug\Exception;
  54946. class ClassNotFoundException extends FatalErrorException
  54947. {
  54948. public function __construct($message, \ErrorException $previous)
  54949. {
  54950. parent::__construct(
  54951. $message,
  54952. $previous->getCode(),
  54953. $previous->getSeverity(),
  54954. $previous->getFile(),
  54955. $previous->getLine(),
  54956. null,
  54957. true,
  54958. null,
  54959. $previous->getPrevious()
  54960. );
  54961. $this->setTrace($previous->getTrace());
  54962. }
  54963. }
  54964. <?php
  54965. namespace Symfony\Component\Debug\Exception;
  54966. class ContextErrorException extends \ErrorException
  54967. {
  54968. private $context = array();
  54969. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  54970. {
  54971. parent::__construct($message, $code, $severity, $filename, $lineno);
  54972. $this->context = $context;
  54973. }
  54974. public function getContext()
  54975. {
  54976. return $this->context;
  54977. }
  54978. }
  54979. <?php
  54980. namespace Symfony\Component\Debug\Exception;
  54981. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  54982. class DummyException extends \ErrorException
  54983. {
  54984. }
  54985. <?php
  54986. namespace Symfony\Component\HttpKernel\Exception;
  54987. class FatalErrorException extends \ErrorException
  54988. {
  54989. }
  54990. namespace Symfony\Component\Debug\Exception;
  54991. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  54992. class FatalErrorException extends LegacyFatalErrorException
  54993. {
  54994. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  54995. {
  54996. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  54997. if (null !== $trace) {
  54998. if (!$traceArgs) {
  54999. foreach ($trace as &$frame) {
  55000. unset($frame['args'], $frame['this'], $frame);
  55001. }
  55002. }
  55003. $this->setTrace($trace);
  55004. } elseif (null !== $traceOffset) {
  55005. if (\function_exists('xdebug_get_function_stack')) {
  55006. $trace = xdebug_get_function_stack();
  55007. if (0 < $traceOffset) {
  55008. array_splice($trace, -$traceOffset);
  55009. }
  55010. foreach ($trace as &$frame) {
  55011. if (!isset($frame['type'])) {
  55012. if (isset($frame['class'])) {
  55013. $frame['type'] = '::';
  55014. }
  55015. } elseif ('dynamic' === $frame['type']) {
  55016. $frame['type'] = '->';
  55017. } elseif ('static' === $frame['type']) {
  55018. $frame['type'] = '::';
  55019. }
  55020. if (!$traceArgs) {
  55021. unset($frame['params'], $frame['args']);
  55022. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  55023. $frame['args'] = $frame['params'];
  55024. unset($frame['params']);
  55025. }
  55026. }
  55027. unset($frame);
  55028. $trace = array_reverse($trace);
  55029. } elseif (\function_exists('symfony_debug_backtrace')) {
  55030. $trace = symfony_debug_backtrace();
  55031. if (0 < $traceOffset) {
  55032. array_splice($trace, 0, $traceOffset);
  55033. }
  55034. } else {
  55035. $trace = array();
  55036. }
  55037. $this->setTrace($trace);
  55038. }
  55039. }
  55040. protected function setTrace($trace)
  55041. {
  55042. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  55043. $traceReflector->setAccessible(true);
  55044. $traceReflector->setValue($this, $trace);
  55045. }
  55046. }
  55047. <?php
  55048. namespace Symfony\Component\Debug\Exception;
  55049. class FatalThrowableError extends FatalErrorException
  55050. {
  55051. public function __construct(\Throwable $e)
  55052. {
  55053. if ($e instanceof \ParseError) {
  55054. $message = 'Parse error: '.$e->getMessage();
  55055. $severity = E_PARSE;
  55056. } elseif ($e instanceof \TypeError) {
  55057. $message = 'Type error: '.$e->getMessage();
  55058. $severity = E_RECOVERABLE_ERROR;
  55059. } else {
  55060. $message = $e->getMessage();
  55061. $severity = E_ERROR;
  55062. }
  55063. \ErrorException::__construct(
  55064. $message,
  55065. $e->getCode(),
  55066. $severity,
  55067. $e->getFile(),
  55068. $e->getLine(),
  55069. $e->getPrevious()
  55070. );
  55071. $this->setTrace($e->getTrace());
  55072. }
  55073. }
  55074. <?php
  55075. namespace Symfony\Component\HttpKernel\Exception;
  55076. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  55077. class FlattenException
  55078. {
  55079. private $handler;
  55080. public static function __callStatic($method, $args)
  55081. {
  55082. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  55083. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  55084. }
  55085. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  55086. }
  55087. public function __call($method, $args)
  55088. {
  55089. if (!isset($this->handler)) {
  55090. $this->handler = new DebugFlattenException();
  55091. }
  55092. if (!method_exists($this->handler, $method)) {
  55093. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  55094. }
  55095. return \call_user_func_array(array($this->handler, $method), $args);
  55096. }
  55097. }
  55098. namespace Symfony\Component\Debug\Exception;
  55099. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  55100. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  55101. class FlattenException extends LegacyFlattenException
  55102. {
  55103. private $message;
  55104. private $code;
  55105. private $previous;
  55106. private $trace;
  55107. private $class;
  55108. private $statusCode;
  55109. private $headers;
  55110. private $file;
  55111. private $line;
  55112. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  55113. {
  55114. $e = new static();
  55115. $e->setMessage($exception->getMessage());
  55116. $e->setCode($exception->getCode());
  55117. if ($exception instanceof HttpExceptionInterface) {
  55118. $statusCode = $exception->getStatusCode();
  55119. $headers = array_merge($headers, $exception->getHeaders());
  55120. }
  55121. if (null === $statusCode) {
  55122. $statusCode = 500;
  55123. }
  55124. $e->setStatusCode($statusCode);
  55125. $e->setHeaders($headers);
  55126. $e->setTraceFromException($exception);
  55127. $e->setClass(\get_class($exception));
  55128. $e->setFile($exception->getFile());
  55129. $e->setLine($exception->getLine());
  55130. $previous = $exception->getPrevious();
  55131. if ($previous instanceof \Exception) {
  55132. $e->setPrevious(static::create($previous));
  55133. } elseif ($previous instanceof \Throwable) {
  55134. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  55135. }
  55136. return $e;
  55137. }
  55138. public function toArray()
  55139. {
  55140. $exceptions = array();
  55141. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  55142. $exceptions[] = array(
  55143. 'message' => $exception->getMessage(),
  55144. 'class' => $exception->getClass(),
  55145. 'trace' => $exception->getTrace(),
  55146. );
  55147. }
  55148. return $exceptions;
  55149. }
  55150. public function getStatusCode()
  55151. {
  55152. return $this->statusCode;
  55153. }
  55154. public function setStatusCode($code)
  55155. {
  55156. $this->statusCode = $code;
  55157. }
  55158. public function getHeaders()
  55159. {
  55160. return $this->headers;
  55161. }
  55162. public function setHeaders(array $headers)
  55163. {
  55164. $this->headers = $headers;
  55165. }
  55166. public function getClass()
  55167. {
  55168. return $this->class;
  55169. }
  55170. public function setClass($class)
  55171. {
  55172. $this->class = $class;
  55173. }
  55174. public function getFile()
  55175. {
  55176. return $this->file;
  55177. }
  55178. public function setFile($file)
  55179. {
  55180. $this->file = $file;
  55181. }
  55182. public function getLine()
  55183. {
  55184. return $this->line;
  55185. }
  55186. public function setLine($line)
  55187. {
  55188. $this->line = $line;
  55189. }
  55190. public function getMessage()
  55191. {
  55192. return $this->message;
  55193. }
  55194. public function setMessage($message)
  55195. {
  55196. $this->message = $message;
  55197. }
  55198. public function getCode()
  55199. {
  55200. return $this->code;
  55201. }
  55202. public function setCode($code)
  55203. {
  55204. $this->code = $code;
  55205. }
  55206. public function getPrevious()
  55207. {
  55208. return $this->previous;
  55209. }
  55210. public function setPrevious(FlattenException $previous)
  55211. {
  55212. $this->previous = $previous;
  55213. }
  55214. public function getAllPrevious()
  55215. {
  55216. $exceptions = array();
  55217. $e = $this;
  55218. while ($e = $e->getPrevious()) {
  55219. $exceptions[] = $e;
  55220. }
  55221. return $exceptions;
  55222. }
  55223. public function getTrace()
  55224. {
  55225. return $this->trace;
  55226. }
  55227. public function setTraceFromException(\Exception $exception)
  55228. {
  55229. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  55230. }
  55231. public function setTrace($trace, $file, $line)
  55232. {
  55233. $this->trace = array();
  55234. $this->trace[] = array(
  55235. 'namespace' => '',
  55236. 'short_class' => '',
  55237. 'class' => '',
  55238. 'type' => '',
  55239. 'function' => '',
  55240. 'file' => $file,
  55241. 'line' => $line,
  55242. 'args' => array(),
  55243. );
  55244. foreach ($trace as $entry) {
  55245. $class = '';
  55246. $namespace = '';
  55247. if (isset($entry['class'])) {
  55248. $parts = explode('\\', $entry['class']);
  55249. $class = array_pop($parts);
  55250. $namespace = implode('\\', $parts);
  55251. }
  55252. $this->trace[] = array(
  55253. 'namespace' => $namespace,
  55254. 'short_class' => $class,
  55255. 'class' => isset($entry['class']) ? $entry['class'] : '',
  55256. 'type' => isset($entry['type']) ? $entry['type'] : '',
  55257. 'function' => isset($entry['function']) ? $entry['function'] : null,
  55258. 'file' => isset($entry['file']) ? $entry['file'] : null,
  55259. 'line' => isset($entry['line']) ? $entry['line'] : null,
  55260. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  55261. );
  55262. }
  55263. }
  55264. private function flattenArgs($args, $level = 0, &$count = 0)
  55265. {
  55266. $result = array();
  55267. foreach ($args as $key => $value) {
  55268. if (++$count > 1e4) {
  55269. return array('array', '*SKIPPED over 10000 entries*');
  55270. }
  55271. if ($value instanceof \__PHP_Incomplete_Class) {
  55272. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  55273. } elseif (\is_object($value)) {
  55274. $result[$key] = array('object', \get_class($value));
  55275. } elseif (\is_array($value)) {
  55276. if ($level > 10) {
  55277. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  55278. } else {
  55279. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  55280. }
  55281. } elseif (null === $value) {
  55282. $result[$key] = array('null', null);
  55283. } elseif (\is_bool($value)) {
  55284. $result[$key] = array('boolean', $value);
  55285. } elseif (\is_resource($value)) {
  55286. $result[$key] = array('resource', get_resource_type($value));
  55287. } else {
  55288. $result[$key] = array('string', (string) $value);
  55289. }
  55290. }
  55291. return $result;
  55292. }
  55293. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  55294. {
  55295. $array = new \ArrayObject($value);
  55296. return $array['__PHP_Incomplete_Class_Name'];
  55297. }
  55298. }
  55299. <?php
  55300. namespace Symfony\Component\Debug\Exception;
  55301. class OutOfMemoryException extends FatalErrorException
  55302. {
  55303. }
  55304. <?php
  55305. namespace Symfony\Component\Debug\Exception;
  55306. class UndefinedFunctionException extends FatalErrorException
  55307. {
  55308. public function __construct($message, \ErrorException $previous)
  55309. {
  55310. parent::__construct(
  55311. $message,
  55312. $previous->getCode(),
  55313. $previous->getSeverity(),
  55314. $previous->getFile(),
  55315. $previous->getLine(),
  55316. null,
  55317. true,
  55318. null,
  55319. $previous->getPrevious()
  55320. );
  55321. $this->setTrace($previous->getTrace());
  55322. }
  55323. }
  55324. <?php
  55325. namespace Symfony\Component\Debug\Exception;
  55326. class UndefinedMethodException extends FatalErrorException
  55327. {
  55328. public function __construct($message, \ErrorException $previous)
  55329. {
  55330. parent::__construct(
  55331. $message,
  55332. $previous->getCode(),
  55333. $previous->getSeverity(),
  55334. $previous->getFile(),
  55335. $previous->getLine(),
  55336. null,
  55337. true,
  55338. null,
  55339. $previous->getPrevious()
  55340. );
  55341. $this->setTrace($previous->getTrace());
  55342. }
  55343. }
  55344. <?php
  55345. namespace Symfony\Component\Debug;
  55346. use Symfony\Component\Debug\Exception\FlattenException;
  55347. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  55348. use Symfony\Component\HttpFoundation\Response;
  55349. class ExceptionHandler
  55350. {
  55351. private $debug;
  55352. private $charset;
  55353. private $handler;
  55354. private $caughtBuffer;
  55355. private $caughtLength;
  55356. private $fileLinkFormat;
  55357. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  55358. {
  55359. if (false !== strpos($charset, '%')) {
  55360. @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);
  55361. $pivot = $fileLinkFormat;
  55362. $fileLinkFormat = $charset;
  55363. $charset = $pivot;
  55364. }
  55365. $this->debug = $debug;
  55366. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  55367. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  55368. }
  55369. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  55370. {
  55371. $handler = new static($debug, $charset, $fileLinkFormat);
  55372. $prev = set_exception_handler(array($handler, 'handle'));
  55373. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  55374. restore_exception_handler();
  55375. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  55376. }
  55377. return $handler;
  55378. }
  55379. public function setHandler($handler)
  55380. {
  55381. if (null !== $handler && !\is_callable($handler)) {
  55382. throw new \LogicException('The exception handler must be a valid PHP callable.');
  55383. }
  55384. $old = $this->handler;
  55385. $this->handler = $handler;
  55386. return $old;
  55387. }
  55388. public function setFileLinkFormat($format)
  55389. {
  55390. $old = $this->fileLinkFormat;
  55391. $this->fileLinkFormat = $format;
  55392. return $old;
  55393. }
  55394. public function handle(\Exception $exception)
  55395. {
  55396. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  55397. $this->failSafeHandle($exception);
  55398. return;
  55399. }
  55400. $caughtLength = $this->caughtLength = 0;
  55401. ob_start(array($this, 'catchOutput'));
  55402. $this->failSafeHandle($exception);
  55403. while (null === $this->caughtBuffer && ob_end_flush()) {
  55404. }
  55405. if (isset($this->caughtBuffer[0])) {
  55406. ob_start(array($this, 'cleanOutput'));
  55407. echo $this->caughtBuffer;
  55408. $caughtLength = ob_get_length();
  55409. }
  55410. $this->caughtBuffer = null;
  55411. try {
  55412. \call_user_func($this->handler, $exception);
  55413. $this->caughtLength = $caughtLength;
  55414. } catch (\Exception $e) {
  55415. if (!$caughtLength) {
  55416. throw $exception;
  55417. }
  55418. }
  55419. }
  55420. private function failSafeHandle(\Exception $exception)
  55421. {
  55422. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  55423. && __CLASS__ !== \get_class($this)
  55424. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  55425. && __CLASS__ !== $reflector->class
  55426. ) {
  55427. $response = $this->createResponse($exception);
  55428. $response->sendHeaders();
  55429. $response->sendContent();
  55430. @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);
  55431. return;
  55432. }
  55433. $this->sendPhpResponse($exception);
  55434. }
  55435. public function sendPhpResponse($exception)
  55436. {
  55437. if (!$exception instanceof FlattenException) {
  55438. $exception = FlattenException::create($exception);
  55439. }
  55440. if (!headers_sent()) {
  55441. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  55442. foreach ($exception->getHeaders() as $name => $value) {
  55443. header($name.': '.$value, false);
  55444. }
  55445. header('Content-Type: text/html; charset='.$this->charset);
  55446. }
  55447. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  55448. }
  55449. public function createResponse($exception)
  55450. {
  55451. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  55452. if (!$exception instanceof FlattenException) {
  55453. $exception = FlattenException::create($exception);
  55454. }
  55455. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  55456. }
  55457. public function getHtml($exception)
  55458. {
  55459. if (!$exception instanceof FlattenException) {
  55460. $exception = FlattenException::create($exception);
  55461. }
  55462. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  55463. }
  55464. public function getContent(FlattenException $exception)
  55465. {
  55466. switch ($exception->getStatusCode()) {
  55467. case 404:
  55468. $title = 'Sorry, the page you are looking for could not be found.';
  55469. break;
  55470. default:
  55471. $title = 'Whoops, looks like something went wrong.';
  55472. }
  55473. $content = '';
  55474. if ($this->debug) {
  55475. try {
  55476. $count = \count($exception->getAllPrevious());
  55477. $total = $count + 1;
  55478. foreach ($exception->toArray() as $position => $e) {
  55479. $ind = $count - $position + 1;
  55480. $class = $this->formatClass($e['class']);
  55481. $message = nl2br($this->escapeHtml($e['message']));
  55482. $content .= sprintf(<<<'EOF'
  55483. <h2 class="block_exception clear_fix">
  55484. <span class="exception_counter">%d/%d</span>
  55485. <span class="exception_title">%s%s:</span>
  55486. <span class="exception_message">%s</span>
  55487. </h2>
  55488. <div class="block">
  55489. <ol class="traces list_exception">
  55490. EOF
  55491. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  55492. foreach ($e['trace'] as $trace) {
  55493. $content .= ' <li>';
  55494. if ($trace['function']) {
  55495. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  55496. }
  55497. if (isset($trace['file']) && isset($trace['line'])) {
  55498. $content .= $this->formatPath($trace['file'], $trace['line']);
  55499. }
  55500. $content .= "</li>\n";
  55501. }
  55502. $content .= " </ol>\n</div>\n";
  55503. }
  55504. } catch (\Exception $e) {
  55505. if ($this->debug) {
  55506. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  55507. } else {
  55508. $title = 'Whoops, looks like something went wrong.';
  55509. }
  55510. }
  55511. }
  55512. return <<<EOF
  55513. <div id="sf-resetcontent" class="sf-reset">
  55514. <h1>$title</h1>
  55515. $content
  55516. </div>
  55517. EOF;
  55518. }
  55519. public function getStylesheet(FlattenException $exception)
  55520. {
  55521. return <<<'EOF'
  55522. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  55523. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  55524. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  55525. .sf-reset .clear_fix { display:inline-block; }
  55526. .sf-reset * html .clear_fix { height:1%; }
  55527. .sf-reset .clear_fix { display:block; }
  55528. .sf-reset, .sf-reset .block { margin: auto }
  55529. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  55530. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  55531. .sf-reset strong { font-weight:bold; }
  55532. .sf-reset a { color:#6c6159; cursor: default; }
  55533. .sf-reset a img { border:none; }
  55534. .sf-reset a:hover { text-decoration:underline; }
  55535. .sf-reset em { font-style:italic; }
  55536. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  55537. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  55538. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  55539. .sf-reset .exception_message { margin-left: 3em; display: block; }
  55540. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  55541. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  55542. -webkit-border-bottom-right-radius: 16px;
  55543. -webkit-border-bottom-left-radius: 16px;
  55544. -moz-border-radius-bottomright: 16px;
  55545. -moz-border-radius-bottomleft: 16px;
  55546. border-bottom-right-radius: 16px;
  55547. border-bottom-left-radius: 16px;
  55548. border-bottom:1px solid #ccc;
  55549. border-right:1px solid #ccc;
  55550. border-left:1px solid #ccc;
  55551. word-wrap: break-word;
  55552. }
  55553. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  55554. -webkit-border-top-left-radius: 16px;
  55555. -webkit-border-top-right-radius: 16px;
  55556. -moz-border-radius-topleft: 16px;
  55557. -moz-border-radius-topright: 16px;
  55558. border-top-left-radius: 16px;
  55559. border-top-right-radius: 16px;
  55560. border-top:1px solid #ccc;
  55561. border-right:1px solid #ccc;
  55562. border-left:1px solid #ccc;
  55563. overflow: hidden;
  55564. word-wrap: break-word;
  55565. }
  55566. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  55567. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  55568. .sf-reset ol { padding: 10px 0; }
  55569. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  55570. -webkit-border-radius: 10px;
  55571. -moz-border-radius: 10px;
  55572. border-radius: 10px;
  55573. border: 1px solid #ccc;
  55574. }
  55575. EOF;
  55576. }
  55577. private function decorate($content, $css)
  55578. {
  55579. return <<<EOF
  55580. <!DOCTYPE html>
  55581. <html>
  55582. <head>
  55583. <meta charset="{$this->charset}" />
  55584. <meta name="robots" content="noindex,nofollow" />
  55585. <style>
  55586. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  55587. 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;}
  55588. html { background: #eee; padding: 10px }
  55589. img { border: 0; }
  55590. #sf-resetcontent { width:970px; margin:0 auto; }
  55591. $css
  55592. </style>
  55593. </head>
  55594. <body>
  55595. $content
  55596. </body>
  55597. </html>
  55598. EOF;
  55599. }
  55600. private function formatClass($class)
  55601. {
  55602. $parts = explode('\\', $class);
  55603. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  55604. }
  55605. private function formatPath($path, $line)
  55606. {
  55607. $path = $this->escapeHtml($path);
  55608. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  55609. if ($linkFormat = $this->fileLinkFormat) {
  55610. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  55611. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  55612. }
  55613. 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);
  55614. }
  55615. private function formatArgs(array $args)
  55616. {
  55617. $result = array();
  55618. foreach ($args as $key => $item) {
  55619. if ('object' === $item[0]) {
  55620. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  55621. } elseif ('array' === $item[0]) {
  55622. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  55623. } elseif ('string' === $item[0]) {
  55624. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  55625. } elseif ('null' === $item[0]) {
  55626. $formattedValue = '<em>null</em>';
  55627. } elseif ('boolean' === $item[0]) {
  55628. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  55629. } elseif ('resource' === $item[0]) {
  55630. $formattedValue = '<em>resource</em>';
  55631. } else {
  55632. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  55633. }
  55634. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  55635. }
  55636. return implode(', ', $result);
  55637. }
  55638. protected static function utf8Htmlize($str)
  55639. {
  55640. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  55641. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  55642. }
  55643. private function escapeHtml($str)
  55644. {
  55645. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  55646. }
  55647. public function catchOutput($buffer)
  55648. {
  55649. $this->caughtBuffer = $buffer;
  55650. return '';
  55651. }
  55652. public function cleanOutput($buffer)
  55653. {
  55654. if ($this->caughtLength) {
  55655. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  55656. if (isset($cleanBuffer[0])) {
  55657. $buffer = $cleanBuffer;
  55658. }
  55659. }
  55660. return $buffer;
  55661. }
  55662. }
  55663. <?php
  55664. namespace Symfony\Component\Debug\FatalErrorHandler;
  55665. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  55666. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  55667. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  55668. use Symfony\Component\Debug\DebugClassLoader;
  55669. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  55670. use Symfony\Component\Debug\Exception\FatalErrorException;
  55671. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  55672. {
  55673. public function handleError(array $error, FatalErrorException $exception)
  55674. {
  55675. $messageLen = \strlen($error['message']);
  55676. $notFoundSuffix = '\' not found';
  55677. $notFoundSuffixLen = \strlen($notFoundSuffix);
  55678. if ($notFoundSuffixLen > $messageLen) {
  55679. return;
  55680. }
  55681. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  55682. return;
  55683. }
  55684. foreach (array('class', 'interface', 'trait') as $typeName) {
  55685. $prefix = ucfirst($typeName).' \'';
  55686. $prefixLen = \strlen($prefix);
  55687. if (0 !== strpos($error['message'], $prefix)) {
  55688. continue;
  55689. }
  55690. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  55691. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  55692. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  55693. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  55694. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  55695. $tail = ' for another namespace?';
  55696. } else {
  55697. $className = $fullyQualifiedClassName;
  55698. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  55699. $tail = '?';
  55700. }
  55701. if ($candidates = $this->getClassCandidates($className)) {
  55702. $tail = array_pop($candidates).'"?';
  55703. if ($candidates) {
  55704. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  55705. } else {
  55706. $tail = ' for "'.$tail;
  55707. }
  55708. }
  55709. $message .= "\nDid you forget a \"use\" statement".$tail;
  55710. return new ClassNotFoundException($message, $exception);
  55711. }
  55712. }
  55713. private function getClassCandidates($class)
  55714. {
  55715. if (!\is_array($functions = spl_autoload_functions())) {
  55716. return array();
  55717. }
  55718. $classes = array();
  55719. foreach ($functions as $function) {
  55720. if (!\is_array($function)) {
  55721. continue;
  55722. }
  55723. if ($function[0] instanceof DebugClassLoader) {
  55724. $function = $function[0]->getClassLoader();
  55725. if (\is_object($function)) {
  55726. $function = array($function);
  55727. }
  55728. if (!\is_array($function)) {
  55729. continue;
  55730. }
  55731. }
  55732. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  55733. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  55734. foreach ($paths as $path) {
  55735. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  55736. }
  55737. }
  55738. }
  55739. if ($function[0] instanceof ComposerClassLoader) {
  55740. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  55741. foreach ($paths as $path) {
  55742. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  55743. }
  55744. }
  55745. }
  55746. }
  55747. return array_unique($classes);
  55748. }
  55749. private function findClassInPath($path, $class, $prefix)
  55750. {
  55751. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  55752. return array();
  55753. }
  55754. $classes = array();
  55755. $filename = $class.'.php';
  55756. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  55757. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  55758. $classes[] = $class;
  55759. }
  55760. }
  55761. return $classes;
  55762. }
  55763. private function convertFileToClass($path, $file, $prefix)
  55764. {
  55765. $candidates = array(
  55766. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  55767. $prefix.$namespacedClass,
  55768. $prefix.'\\'.$namespacedClass,
  55769. str_replace('\\', '_', $namespacedClass),
  55770. str_replace('\\', '_', $prefix.$namespacedClass),
  55771. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  55772. );
  55773. if ($prefix) {
  55774. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  55775. }
  55776. foreach ($candidates as $candidate) {
  55777. if ($this->classExists($candidate)) {
  55778. return $candidate;
  55779. }
  55780. }
  55781. require_once $file;
  55782. foreach ($candidates as $candidate) {
  55783. if ($this->classExists($candidate)) {
  55784. return $candidate;
  55785. }
  55786. }
  55787. }
  55788. private function classExists($class)
  55789. {
  55790. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  55791. }
  55792. }
  55793. <?php
  55794. namespace Symfony\Component\Debug\FatalErrorHandler;
  55795. use Symfony\Component\Debug\Exception\FatalErrorException;
  55796. interface FatalErrorHandlerInterface
  55797. {
  55798. public function handleError(array $error, FatalErrorException $exception);
  55799. }
  55800. <?php
  55801. namespace Symfony\Component\Debug\FatalErrorHandler;
  55802. use Symfony\Component\Debug\Exception\FatalErrorException;
  55803. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  55804. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  55805. {
  55806. public function handleError(array $error, FatalErrorException $exception)
  55807. {
  55808. $messageLen = \strlen($error['message']);
  55809. $notFoundSuffix = '()';
  55810. $notFoundSuffixLen = \strlen($notFoundSuffix);
  55811. if ($notFoundSuffixLen > $messageLen) {
  55812. return;
  55813. }
  55814. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  55815. return;
  55816. }
  55817. $prefix = 'Call to undefined function ';
  55818. $prefixLen = \strlen($prefix);
  55819. if (0 !== strpos($error['message'], $prefix)) {
  55820. return;
  55821. }
  55822. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  55823. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  55824. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  55825. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  55826. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  55827. } else {
  55828. $functionName = $fullyQualifiedFunctionName;
  55829. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  55830. }
  55831. $candidates = array();
  55832. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  55833. foreach ($definedFunctionNames as $definedFunctionName) {
  55834. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  55835. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  55836. } else {
  55837. $definedFunctionNameBasename = $definedFunctionName;
  55838. }
  55839. if ($definedFunctionNameBasename === $functionName) {
  55840. $candidates[] = '\\'.$definedFunctionName;
  55841. }
  55842. }
  55843. }
  55844. if ($candidates) {
  55845. sort($candidates);
  55846. $last = array_pop($candidates).'"?';
  55847. if ($candidates) {
  55848. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  55849. } else {
  55850. $candidates = '"'.$last;
  55851. }
  55852. $message .= "\nDid you mean to call ".$candidates;
  55853. }
  55854. return new UndefinedFunctionException($message, $exception);
  55855. }
  55856. }
  55857. <?php
  55858. namespace Symfony\Component\Debug\FatalErrorHandler;
  55859. use Symfony\Component\Debug\Exception\FatalErrorException;
  55860. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  55861. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  55862. {
  55863. public function handleError(array $error, FatalErrorException $exception)
  55864. {
  55865. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  55866. if (!$matches) {
  55867. return;
  55868. }
  55869. $className = $matches[1];
  55870. $methodName = $matches[2];
  55871. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  55872. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  55873. return new UndefinedMethodException($message, $exception);
  55874. }
  55875. $candidates = array();
  55876. foreach ($methods as $definedMethodName) {
  55877. $lev = levenshtein($methodName, $definedMethodName);
  55878. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  55879. $candidates[] = $definedMethodName;
  55880. }
  55881. }
  55882. if ($candidates) {
  55883. sort($candidates);
  55884. $last = array_pop($candidates).'"?';
  55885. if ($candidates) {
  55886. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  55887. } else {
  55888. $candidates = '"'.$last;
  55889. }
  55890. $message .= "\nDid you mean to call ".$candidates;
  55891. }
  55892. return new UndefinedMethodException($message, $exception);
  55893. }
  55894. }
  55895. Copyright (c) 2004-2018 Fabien Potencier
  55896. Permission is hereby granted, free of charge, to any person obtaining a copy
  55897. of this software and associated documentation files (the "Software"), to deal
  55898. in the Software without restriction, including without limitation the rights
  55899. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  55900. copies of the Software, and to permit persons to whom the Software is furnished
  55901. to do so, subject to the following conditions:
  55902. The above copyright notice and this permission notice shall be included in all
  55903. copies or substantial portions of the Software.
  55904. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  55905. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  55906. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55907. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55908. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55909. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  55910. THE SOFTWARE.
  55911. <?php
  55912. namespace Symfony\Component\Filesystem\Exception;
  55913. interface ExceptionInterface
  55914. {
  55915. }
  55916. <?php
  55917. namespace Symfony\Component\Filesystem\Exception;
  55918. class FileNotFoundException extends IOException
  55919. {
  55920. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  55921. {
  55922. if (null === $message) {
  55923. if (null === $path) {
  55924. $message = 'File could not be found.';
  55925. } else {
  55926. $message = sprintf('File "%s" could not be found.', $path);
  55927. }
  55928. }
  55929. parent::__construct($message, $code, $previous, $path);
  55930. }
  55931. }
  55932. <?php
  55933. namespace Symfony\Component\Filesystem\Exception;
  55934. class IOException extends \RuntimeException implements IOExceptionInterface
  55935. {
  55936. private $path;
  55937. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  55938. {
  55939. $this->path = $path;
  55940. parent::__construct($message, $code, $previous);
  55941. }
  55942. public function getPath()
  55943. {
  55944. return $this->path;
  55945. }
  55946. }
  55947. <?php
  55948. namespace Symfony\Component\Filesystem\Exception;
  55949. interface IOExceptionInterface extends ExceptionInterface
  55950. {
  55951. public function getPath();
  55952. }
  55953. <?php
  55954. namespace Symfony\Component\Filesystem;
  55955. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  55956. use Symfony\Component\Filesystem\Exception\IOException;
  55957. class Filesystem
  55958. {
  55959. private static $lastError;
  55960. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  55961. {
  55962. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  55963. if ($originIsLocal && !is_file($originFile)) {
  55964. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  55965. }
  55966. $this->mkdir(\dirname($targetFile));
  55967. $doCopy = true;
  55968. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  55969. $doCopy = filemtime($originFile) > filemtime($targetFile);
  55970. }
  55971. if ($doCopy) {
  55972. if (false === $source = @fopen($originFile, 'r')) {
  55973. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  55974. }
  55975. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  55976. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  55977. }
  55978. $bytesCopied = stream_copy_to_stream($source, $target);
  55979. fclose($source);
  55980. fclose($target);
  55981. unset($source, $target);
  55982. if (!is_file($targetFile)) {
  55983. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  55984. }
  55985. if ($originIsLocal) {
  55986. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  55987. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  55988. 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);
  55989. }
  55990. }
  55991. }
  55992. }
  55993. public function mkdir($dirs, $mode = 0777)
  55994. {
  55995. foreach ($this->toIterator($dirs) as $dir) {
  55996. if (is_dir($dir)) {
  55997. continue;
  55998. }
  55999. if (!self::box('mkdir', $dir, $mode, true)) {
  56000. if (!is_dir($dir)) {
  56001. if (self::$lastError) {
  56002. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  56003. }
  56004. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  56005. }
  56006. }
  56007. }
  56008. }
  56009. public function exists($files)
  56010. {
  56011. $maxPathLength = PHP_MAXPATHLEN - 2;
  56012. foreach ($this->toIterator($files) as $file) {
  56013. if (\strlen($file) > $maxPathLength) {
  56014. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  56015. }
  56016. if (!file_exists($file)) {
  56017. return false;
  56018. }
  56019. }
  56020. return true;
  56021. }
  56022. public function touch($files, $time = null, $atime = null)
  56023. {
  56024. foreach ($this->toIterator($files) as $file) {
  56025. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  56026. if (true !== $touch) {
  56027. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  56028. }
  56029. }
  56030. }
  56031. public function remove($files)
  56032. {
  56033. if ($files instanceof \Traversable) {
  56034. $files = iterator_to_array($files, false);
  56035. } elseif (!\is_array($files)) {
  56036. $files = array($files);
  56037. }
  56038. $files = array_reverse($files);
  56039. foreach ($files as $file) {
  56040. if (is_link($file)) {
  56041. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  56042. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  56043. }
  56044. } elseif (is_dir($file)) {
  56045. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  56046. if (!self::box('rmdir', $file) && file_exists($file)) {
  56047. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  56048. }
  56049. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  56050. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  56051. }
  56052. }
  56053. }
  56054. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  56055. {
  56056. foreach ($this->toIterator($files) as $file) {
  56057. if (true !== @chmod($file, $mode & ~$umask)) {
  56058. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  56059. }
  56060. if ($recursive && is_dir($file) && !is_link($file)) {
  56061. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  56062. }
  56063. }
  56064. }
  56065. public function chown($files, $user, $recursive = false)
  56066. {
  56067. foreach ($this->toIterator($files) as $file) {
  56068. if ($recursive && is_dir($file) && !is_link($file)) {
  56069. $this->chown(new \FilesystemIterator($file), $user, true);
  56070. }
  56071. if (is_link($file) && \function_exists('lchown')) {
  56072. if (true !== @lchown($file, $user)) {
  56073. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56074. }
  56075. } else {
  56076. if (true !== @chown($file, $user)) {
  56077. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56078. }
  56079. }
  56080. }
  56081. }
  56082. public function chgrp($files, $group, $recursive = false)
  56083. {
  56084. foreach ($this->toIterator($files) as $file) {
  56085. if ($recursive && is_dir($file) && !is_link($file)) {
  56086. $this->chgrp(new \FilesystemIterator($file), $group, true);
  56087. }
  56088. if (is_link($file) && \function_exists('lchgrp')) {
  56089. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  56090. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56091. }
  56092. } else {
  56093. if (true !== @chgrp($file, $group)) {
  56094. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56095. }
  56096. }
  56097. }
  56098. }
  56099. public function rename($origin, $target, $overwrite = false)
  56100. {
  56101. if (!$overwrite && $this->isReadable($target)) {
  56102. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  56103. }
  56104. if (true !== @rename($origin, $target)) {
  56105. if (is_dir($origin)) {
  56106. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  56107. $this->remove($origin);
  56108. return;
  56109. }
  56110. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  56111. }
  56112. }
  56113. private function isReadable($filename)
  56114. {
  56115. $maxPathLength = PHP_MAXPATHLEN - 2;
  56116. if (\strlen($filename) > $maxPathLength) {
  56117. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  56118. }
  56119. return is_readable($filename);
  56120. }
  56121. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  56122. {
  56123. if ('\\' === \DIRECTORY_SEPARATOR) {
  56124. $originDir = strtr($originDir, '/', '\\');
  56125. $targetDir = strtr($targetDir, '/', '\\');
  56126. if ($copyOnWindows) {
  56127. $this->mirror($originDir, $targetDir);
  56128. return;
  56129. }
  56130. }
  56131. $this->mkdir(\dirname($targetDir));
  56132. if (is_link($targetDir)) {
  56133. if (readlink($targetDir) === $originDir) {
  56134. return;
  56135. }
  56136. $this->remove($targetDir);
  56137. }
  56138. if (!self::box('symlink', $originDir, $targetDir)) {
  56139. if (null !== self::$lastError) {
  56140. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  56141. 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);
  56142. }
  56143. }
  56144. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  56145. }
  56146. }
  56147. public function makePathRelative($endPath, $startPath)
  56148. {
  56149. if ('\\' === \DIRECTORY_SEPARATOR) {
  56150. $endPath = str_replace('\\', '/', $endPath);
  56151. $startPath = str_replace('\\', '/', $startPath);
  56152. }
  56153. $stripDriveLetter = function ($path) {
  56154. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  56155. return substr($path, 2);
  56156. }
  56157. return $path;
  56158. };
  56159. $endPath = $stripDriveLetter($endPath);
  56160. $startPath = $stripDriveLetter($startPath);
  56161. $startPathArr = explode('/', trim($startPath, '/'));
  56162. $endPathArr = explode('/', trim($endPath, '/'));
  56163. $normalizePathArray = function ($pathSegments, $absolute) {
  56164. $result = array();
  56165. foreach ($pathSegments as $segment) {
  56166. if ('..' === $segment && ($absolute || \count($result))) {
  56167. array_pop($result);
  56168. } elseif ('.' !== $segment) {
  56169. $result[] = $segment;
  56170. }
  56171. }
  56172. return $result;
  56173. };
  56174. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  56175. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  56176. $index = 0;
  56177. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  56178. ++$index;
  56179. }
  56180. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  56181. $depth = 0;
  56182. } else {
  56183. $depth = \count($startPathArr) - $index;
  56184. }
  56185. $traverser = str_repeat('../', $depth);
  56186. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  56187. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  56188. return '' === $relativePath ? './' : $relativePath;
  56189. }
  56190. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  56191. {
  56192. $targetDir = rtrim($targetDir, '/\\');
  56193. $originDir = rtrim($originDir, '/\\');
  56194. $originDirLen = \strlen($originDir);
  56195. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  56196. $deleteIterator = $iterator;
  56197. if (null === $deleteIterator) {
  56198. $flags = \FilesystemIterator::SKIP_DOTS;
  56199. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  56200. }
  56201. $targetDirLen = \strlen($targetDir);
  56202. foreach ($deleteIterator as $file) {
  56203. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  56204. if (!$this->exists($origin)) {
  56205. $this->remove($file);
  56206. }
  56207. }
  56208. }
  56209. $copyOnWindows = false;
  56210. if (isset($options['copy_on_windows'])) {
  56211. $copyOnWindows = $options['copy_on_windows'];
  56212. }
  56213. if (null === $iterator) {
  56214. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  56215. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  56216. }
  56217. if ($this->exists($originDir)) {
  56218. $this->mkdir($targetDir);
  56219. }
  56220. foreach ($iterator as $file) {
  56221. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  56222. if ($copyOnWindows) {
  56223. if (is_file($file)) {
  56224. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56225. } elseif (is_dir($file)) {
  56226. $this->mkdir($target);
  56227. } else {
  56228. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56229. }
  56230. } else {
  56231. if (is_link($file)) {
  56232. $this->symlink($file->getLinkTarget(), $target);
  56233. } elseif (is_dir($file)) {
  56234. $this->mkdir($target);
  56235. } elseif (is_file($file)) {
  56236. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56237. } else {
  56238. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56239. }
  56240. }
  56241. }
  56242. }
  56243. public function isAbsolutePath($file)
  56244. {
  56245. return strspn($file, '/\\', 0, 1)
  56246. || (\strlen($file) > 3 && ctype_alpha($file[0])
  56247. && ':' === substr($file, 1, 1)
  56248. && strspn($file, '/\\', 2, 1)
  56249. )
  56250. || null !== parse_url($file, PHP_URL_SCHEME)
  56251. ;
  56252. }
  56253. public function tempnam($dir, $prefix)
  56254. {
  56255. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  56256. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  56257. $tmpFile = @tempnam($hierarchy, $prefix);
  56258. if (false !== $tmpFile) {
  56259. if (null !== $scheme && 'gs' !== $scheme) {
  56260. return $scheme.'://'.$tmpFile;
  56261. }
  56262. return $tmpFile;
  56263. }
  56264. throw new IOException('A temporary file could not be created.');
  56265. }
  56266. for ($i = 0; $i < 10; ++$i) {
  56267. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  56268. $handle = @fopen($tmpFile, 'x+');
  56269. if (false === $handle) {
  56270. continue;
  56271. }
  56272. @fclose($handle);
  56273. return $tmpFile;
  56274. }
  56275. throw new IOException('A temporary file could not be created.');
  56276. }
  56277. public function dumpFile($filename, $content, $mode = 0666)
  56278. {
  56279. $dir = \dirname($filename);
  56280. if (!is_dir($dir)) {
  56281. $this->mkdir($dir);
  56282. }
  56283. if (!is_writable($dir)) {
  56284. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  56285. }
  56286. $tmpFile = $this->tempnam($dir, basename($filename));
  56287. if (false === @file_put_contents($tmpFile, $content)) {
  56288. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  56289. }
  56290. if (null !== $mode) {
  56291. if (\func_num_args() > 2) {
  56292. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  56293. }
  56294. $this->chmod($tmpFile, $mode);
  56295. } elseif (file_exists($filename)) {
  56296. @chmod($tmpFile, fileperms($filename));
  56297. }
  56298. $this->rename($tmpFile, $filename, true);
  56299. }
  56300. private function toIterator($files)
  56301. {
  56302. if (!$files instanceof \Traversable) {
  56303. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  56304. }
  56305. return $files;
  56306. }
  56307. private function getSchemeAndHierarchy($filename)
  56308. {
  56309. $components = explode('://', $filename, 2);
  56310. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  56311. }
  56312. private static function box($func)
  56313. {
  56314. self::$lastError = null;
  56315. \set_error_handler(__CLASS__.'::handleError');
  56316. try {
  56317. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  56318. \restore_error_handler();
  56319. return $result;
  56320. } catch (\Throwable $e) {
  56321. } catch (\Exception $e) {
  56322. }
  56323. \restore_error_handler();
  56324. throw $e;
  56325. }
  56326. public static function handleError($type, $msg)
  56327. {
  56328. self::$lastError = $msg;
  56329. }
  56330. }
  56331. Copyright (c) 2004-2018 Fabien Potencier
  56332. Permission is hereby granted, free of charge, to any person obtaining a copy
  56333. of this software and associated documentation files (the "Software"), to deal
  56334. in the Software without restriction, including without limitation the rights
  56335. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56336. copies of the Software, and to permit persons to whom the Software is furnished
  56337. to do so, subject to the following conditions:
  56338. The above copyright notice and this permission notice shall be included in all
  56339. copies or substantial portions of the Software.
  56340. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56341. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56342. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56343. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56344. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56345. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56346. THE SOFTWARE.
  56347. <?php
  56348. namespace Symfony\Component\Filesystem;
  56349. use Symfony\Component\Filesystem\Exception\IOException;
  56350. class LockHandler
  56351. {
  56352. private $file;
  56353. private $handle;
  56354. public function __construct($name, $lockPath = null)
  56355. {
  56356. $lockPath = $lockPath ?: sys_get_temp_dir();
  56357. if (!is_dir($lockPath)) {
  56358. $fs = new Filesystem();
  56359. $fs->mkdir($lockPath);
  56360. }
  56361. if (!is_writable($lockPath)) {
  56362. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  56363. }
  56364. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  56365. }
  56366. public function lock($blocking = false)
  56367. {
  56368. if ($this->handle) {
  56369. return true;
  56370. }
  56371. $error = null;
  56372. set_error_handler(function ($errno, $msg) use (&$error) {
  56373. $error = $msg;
  56374. });
  56375. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56376. if ($this->handle = fopen($this->file, 'x')) {
  56377. chmod($this->file, 0666);
  56378. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56379. usleep(100);
  56380. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  56381. }
  56382. }
  56383. restore_error_handler();
  56384. if (!$this->handle) {
  56385. throw new IOException($error, 0, null, $this->file);
  56386. }
  56387. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  56388. fclose($this->handle);
  56389. $this->handle = null;
  56390. return false;
  56391. }
  56392. return true;
  56393. }
  56394. public function release()
  56395. {
  56396. if ($this->handle) {
  56397. flock($this->handle, LOCK_UN | LOCK_NB);
  56398. fclose($this->handle);
  56399. $this->handle = null;
  56400. }
  56401. }
  56402. }
  56403. <?php
  56404. namespace Symfony\Component\Finder\Adapter;
  56405. @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);
  56406. abstract class AbstractAdapter implements AdapterInterface
  56407. {
  56408. protected $followLinks = false;
  56409. protected $mode = 0;
  56410. protected $minDepth = 0;
  56411. protected $maxDepth = PHP_INT_MAX;
  56412. protected $exclude = array();
  56413. protected $names = array();
  56414. protected $notNames = array();
  56415. protected $contains = array();
  56416. protected $notContains = array();
  56417. protected $sizes = array();
  56418. protected $dates = array();
  56419. protected $filters = array();
  56420. protected $sort = false;
  56421. protected $paths = array();
  56422. protected $notPaths = array();
  56423. protected $ignoreUnreadableDirs = false;
  56424. private static $areSupported = array();
  56425. public function isSupported()
  56426. {
  56427. $name = $this->getName();
  56428. if (!array_key_exists($name, self::$areSupported)) {
  56429. self::$areSupported[$name] = $this->canBeUsed();
  56430. }
  56431. return self::$areSupported[$name];
  56432. }
  56433. public function setFollowLinks($followLinks)
  56434. {
  56435. $this->followLinks = $followLinks;
  56436. return $this;
  56437. }
  56438. public function setMode($mode)
  56439. {
  56440. $this->mode = $mode;
  56441. return $this;
  56442. }
  56443. public function setDepths(array $depths)
  56444. {
  56445. $this->minDepth = 0;
  56446. $this->maxDepth = PHP_INT_MAX;
  56447. foreach ($depths as $comparator) {
  56448. switch ($comparator->getOperator()) {
  56449. case '>':
  56450. $this->minDepth = $comparator->getTarget() + 1;
  56451. break;
  56452. case '>=':
  56453. $this->minDepth = $comparator->getTarget();
  56454. break;
  56455. case '<':
  56456. $this->maxDepth = $comparator->getTarget() - 1;
  56457. break;
  56458. case '<=':
  56459. $this->maxDepth = $comparator->getTarget();
  56460. break;
  56461. default:
  56462. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  56463. }
  56464. }
  56465. return $this;
  56466. }
  56467. public function setExclude(array $exclude)
  56468. {
  56469. $this->exclude = $exclude;
  56470. return $this;
  56471. }
  56472. public function setNames(array $names)
  56473. {
  56474. $this->names = $names;
  56475. return $this;
  56476. }
  56477. public function setNotNames(array $notNames)
  56478. {
  56479. $this->notNames = $notNames;
  56480. return $this;
  56481. }
  56482. public function setContains(array $contains)
  56483. {
  56484. $this->contains = $contains;
  56485. return $this;
  56486. }
  56487. public function setNotContains(array $notContains)
  56488. {
  56489. $this->notContains = $notContains;
  56490. return $this;
  56491. }
  56492. public function setSizes(array $sizes)
  56493. {
  56494. $this->sizes = $sizes;
  56495. return $this;
  56496. }
  56497. public function setDates(array $dates)
  56498. {
  56499. $this->dates = $dates;
  56500. return $this;
  56501. }
  56502. public function setFilters(array $filters)
  56503. {
  56504. $this->filters = $filters;
  56505. return $this;
  56506. }
  56507. public function setSort($sort)
  56508. {
  56509. $this->sort = $sort;
  56510. return $this;
  56511. }
  56512. public function setPath(array $paths)
  56513. {
  56514. $this->paths = $paths;
  56515. return $this;
  56516. }
  56517. public function setNotPath(array $notPaths)
  56518. {
  56519. $this->notPaths = $notPaths;
  56520. return $this;
  56521. }
  56522. public function ignoreUnreadableDirs($ignore = true)
  56523. {
  56524. $this->ignoreUnreadableDirs = (bool) $ignore;
  56525. return $this;
  56526. }
  56527. abstract protected function canBeUsed();
  56528. }
  56529. <?php
  56530. namespace Symfony\Component\Finder\Adapter;
  56531. @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);
  56532. use Symfony\Component\Finder\Comparator\DateComparator;
  56533. use Symfony\Component\Finder\Comparator\NumberComparator;
  56534. use Symfony\Component\Finder\Exception\AccessDeniedException;
  56535. use Symfony\Component\Finder\Expression\Expression;
  56536. use Symfony\Component\Finder\Iterator;
  56537. use Symfony\Component\Finder\Shell\Command;
  56538. use Symfony\Component\Finder\Shell\Shell;
  56539. abstract class AbstractFindAdapter extends AbstractAdapter
  56540. {
  56541. protected $shell;
  56542. public function __construct()
  56543. {
  56544. $this->shell = new Shell();
  56545. }
  56546. public function searchInDirectory($dir)
  56547. {
  56548. $dir = realpath($dir);
  56549. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  56550. return new Iterator\FilePathsIterator(array(), $dir);
  56551. }
  56552. $command = Command::create();
  56553. $find = $this->buildFindCommand($command, $dir);
  56554. if ($this->followLinks) {
  56555. $find->add('-follow');
  56556. }
  56557. $find->add('-mindepth')->add($this->minDepth + 1);
  56558. if (PHP_INT_MAX !== $this->maxDepth) {
  56559. $find->add('-maxdepth')->add($this->maxDepth + 1);
  56560. }
  56561. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  56562. $find->add('-type d');
  56563. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  56564. $find->add('-type f');
  56565. }
  56566. $this->buildNamesFiltering($find, $this->names);
  56567. $this->buildNamesFiltering($find, $this->notNames, true);
  56568. $this->buildPathsFiltering($find, $dir, $this->paths);
  56569. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  56570. $this->buildSizesFiltering($find, $this->sizes);
  56571. $this->buildDatesFiltering($find, $this->dates);
  56572. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  56573. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  56574. if ($useGrep && ($this->contains || $this->notContains)) {
  56575. $grep = $command->ins('grep');
  56576. $this->buildContentFiltering($grep, $this->contains);
  56577. $this->buildContentFiltering($grep, $this->notContains, true);
  56578. }
  56579. if ($useSort) {
  56580. $this->buildSorting($command, $this->sort);
  56581. }
  56582. $command->setErrorHandler(
  56583. $this->ignoreUnreadableDirs
  56584. ? function ($stderr) { }
  56585. : function ($stderr) { throw new AccessDeniedException($stderr); }
  56586. );
  56587. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  56588. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  56589. if ($this->exclude) {
  56590. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  56591. }
  56592. if (!$useGrep && ($this->contains || $this->notContains)) {
  56593. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  56594. }
  56595. if ($this->filters) {
  56596. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  56597. }
  56598. if (!$useSort && $this->sort) {
  56599. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  56600. $iterator = $iteratorAggregate->getIterator();
  56601. }
  56602. return $iterator;
  56603. }
  56604. protected function canBeUsed()
  56605. {
  56606. return $this->shell->testCommand('find');
  56607. }
  56608. protected function buildFindCommand(Command $command, $dir)
  56609. {
  56610. return $command
  56611. ->ins('find')
  56612. ->add('find ')
  56613. ->arg($dir)
  56614. ->add('-noleaf');
  56615. }
  56616. private function buildNamesFiltering(Command $command, array $names, $not = false)
  56617. {
  56618. if (0 === \count($names)) {
  56619. return;
  56620. }
  56621. $command->add($not ? '-not' : null)->cmd('(');
  56622. foreach ($names as $i => $name) {
  56623. $expr = Expression::create($name);
  56624. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  56625. $expr = Expression::create($expr->getGlob()->toRegex(false));
  56626. }
  56627. if ($expr->isRegex()) {
  56628. $regex = $expr->getRegex();
  56629. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  56630. ->setStartFlag(false)
  56631. ->setStartJoker(true)
  56632. ->replaceJokers('[^/]');
  56633. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  56634. $regex->setEndJoker(false)->append('[^/]*');
  56635. }
  56636. }
  56637. $command
  56638. ->add($i > 0 ? '-or' : null)
  56639. ->add($expr->isRegex()
  56640. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  56641. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  56642. )
  56643. ->arg($expr->renderPattern());
  56644. }
  56645. $command->cmd(')');
  56646. }
  56647. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  56648. {
  56649. if (0 === \count($paths)) {
  56650. return;
  56651. }
  56652. $command->add($not ? '-not' : null)->cmd('(');
  56653. foreach ($paths as $i => $path) {
  56654. $expr = Expression::create($path);
  56655. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  56656. $expr = Expression::create($expr->getGlob()->toRegex(false));
  56657. }
  56658. if ($expr->isRegex()) {
  56659. $regex = $expr->getRegex();
  56660. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  56661. } else {
  56662. $expr->prepend('*')->append('*');
  56663. }
  56664. $command
  56665. ->add($i > 0 ? '-or' : null)
  56666. ->add($expr->isRegex()
  56667. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  56668. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  56669. )
  56670. ->arg($expr->renderPattern());
  56671. }
  56672. $command->cmd(')');
  56673. }
  56674. private function buildSizesFiltering(Command $command, array $sizes)
  56675. {
  56676. foreach ($sizes as $i => $size) {
  56677. $command->add($i > 0 ? '-and' : null);
  56678. switch ($size->getOperator()) {
  56679. case '<=':
  56680. $command->add('-size -'.($size->getTarget() + 1).'c');
  56681. break;
  56682. case '>=':
  56683. $command->add('-size +'.($size->getTarget() - 1).'c');
  56684. break;
  56685. case '>':
  56686. $command->add('-size +'.$size->getTarget().'c');
  56687. break;
  56688. case '!=':
  56689. $command->add('-size -'.$size->getTarget().'c');
  56690. $command->add('-size +'.$size->getTarget().'c');
  56691. break;
  56692. case '<':
  56693. default:
  56694. $command->add('-size -'.$size->getTarget().'c');
  56695. }
  56696. }
  56697. }
  56698. private function buildDatesFiltering(Command $command, array $dates)
  56699. {
  56700. foreach ($dates as $i => $date) {
  56701. $command->add($i > 0 ? '-and' : null);
  56702. $mins = (int) round((time() - $date->getTarget()) / 60);
  56703. if (0 > $mins) {
  56704. $command->add(' -mmin -0');
  56705. return;
  56706. }
  56707. switch ($date->getOperator()) {
  56708. case '<=':
  56709. $command->add('-mmin +'.($mins - 1));
  56710. break;
  56711. case '>=':
  56712. $command->add('-mmin -'.($mins + 1));
  56713. break;
  56714. case '>':
  56715. $command->add('-mmin -'.$mins);
  56716. break;
  56717. case '!=':
  56718. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  56719. break;
  56720. case '<':
  56721. default:
  56722. $command->add('-mmin +'.$mins);
  56723. }
  56724. }
  56725. }
  56726. private function buildSorting(Command $command, $sort)
  56727. {
  56728. $this->buildFormatSorting($command, $sort);
  56729. }
  56730. abstract protected function buildFormatSorting(Command $command, $sort);
  56731. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  56732. }
  56733. <?php
  56734. namespace Symfony\Component\Finder\Adapter;
  56735. interface AdapterInterface
  56736. {
  56737. public function setFollowLinks($followLinks);
  56738. public function setMode($mode);
  56739. public function setExclude(array $exclude);
  56740. public function setDepths(array $depths);
  56741. public function setNames(array $names);
  56742. public function setNotNames(array $notNames);
  56743. public function setContains(array $contains);
  56744. public function setNotContains(array $notContains);
  56745. public function setSizes(array $sizes);
  56746. public function setDates(array $dates);
  56747. public function setFilters(array $filters);
  56748. public function setSort($sort);
  56749. public function setPath(array $paths);
  56750. public function setNotPath(array $notPaths);
  56751. public function ignoreUnreadableDirs($ignore = true);
  56752. public function searchInDirectory($dir);
  56753. public function isSupported();
  56754. public function getName();
  56755. }
  56756. <?php
  56757. namespace Symfony\Component\Finder\Adapter;
  56758. @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);
  56759. use Symfony\Component\Finder\Expression\Expression;
  56760. use Symfony\Component\Finder\Iterator\SortableIterator;
  56761. use Symfony\Component\Finder\Shell\Command;
  56762. use Symfony\Component\Finder\Shell\Shell;
  56763. class BsdFindAdapter extends AbstractFindAdapter
  56764. {
  56765. public function getName()
  56766. {
  56767. return 'bsd_find';
  56768. }
  56769. protected function canBeUsed()
  56770. {
  56771. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  56772. }
  56773. protected function buildFormatSorting(Command $command, $sort)
  56774. {
  56775. switch ($sort) {
  56776. case SortableIterator::SORT_BY_NAME:
  56777. $command->ins('sort')->add('| sort');
  56778. return;
  56779. case SortableIterator::SORT_BY_TYPE:
  56780. $format = '%HT';
  56781. break;
  56782. case SortableIterator::SORT_BY_ACCESSED_TIME:
  56783. $format = '%a';
  56784. break;
  56785. case SortableIterator::SORT_BY_CHANGED_TIME:
  56786. $format = '%c';
  56787. break;
  56788. case SortableIterator::SORT_BY_MODIFIED_TIME:
  56789. $format = '%m';
  56790. break;
  56791. default:
  56792. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  56793. }
  56794. $command
  56795. ->add('-print0 | xargs -0 stat -f')
  56796. ->arg($format.'%t%N')
  56797. ->add('| sort | cut -f 2');
  56798. }
  56799. protected function buildFindCommand(Command $command, $dir)
  56800. {
  56801. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  56802. return $command;
  56803. }
  56804. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  56805. {
  56806. foreach ($contains as $contain) {
  56807. $expr = Expression::create($contain);
  56808. $command
  56809. ->add('| grep -v \'^$\'')
  56810. ->add('| xargs -I{} grep -I')
  56811. ->add($expr->isCaseSensitive() ? null : '-i')
  56812. ->add($not ? '-L' : '-l')
  56813. ->add('-Ee')->arg($expr->renderPattern())
  56814. ->add('{}')
  56815. ;
  56816. }
  56817. }
  56818. }
  56819. <?php
  56820. namespace Symfony\Component\Finder\Adapter;
  56821. @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);
  56822. use Symfony\Component\Finder\Expression\Expression;
  56823. use Symfony\Component\Finder\Iterator\SortableIterator;
  56824. use Symfony\Component\Finder\Shell\Command;
  56825. use Symfony\Component\Finder\Shell\Shell;
  56826. class GnuFindAdapter extends AbstractFindAdapter
  56827. {
  56828. public function getName()
  56829. {
  56830. return 'gnu_find';
  56831. }
  56832. protected function buildFormatSorting(Command $command, $sort)
  56833. {
  56834. switch ($sort) {
  56835. case SortableIterator::SORT_BY_NAME:
  56836. $command->ins('sort')->add('| sort');
  56837. return;
  56838. case SortableIterator::SORT_BY_TYPE:
  56839. $format = '%y';
  56840. break;
  56841. case SortableIterator::SORT_BY_ACCESSED_TIME:
  56842. $format = '%A@';
  56843. break;
  56844. case SortableIterator::SORT_BY_CHANGED_TIME:
  56845. $format = '%C@';
  56846. break;
  56847. case SortableIterator::SORT_BY_MODIFIED_TIME:
  56848. $format = '%T@';
  56849. break;
  56850. default:
  56851. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  56852. }
  56853. $command
  56854. ->get('find')
  56855. ->add('-printf')
  56856. ->arg($format.' %h/%f\\n')
  56857. ->add('| sort | cut')
  56858. ->arg('-d ')
  56859. ->arg('-f2-')
  56860. ;
  56861. }
  56862. protected function canBeUsed()
  56863. {
  56864. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  56865. }
  56866. protected function buildFindCommand(Command $command, $dir)
  56867. {
  56868. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  56869. }
  56870. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  56871. {
  56872. foreach ($contains as $contain) {
  56873. $expr = Expression::create($contain);
  56874. $command
  56875. ->add('| xargs -I{} -r grep -I')
  56876. ->add($expr->isCaseSensitive() ? null : '-i')
  56877. ->add($not ? '-L' : '-l')
  56878. ->add('-Ee')->arg($expr->renderPattern())
  56879. ->add('{}')
  56880. ;
  56881. }
  56882. }
  56883. }
  56884. <?php
  56885. namespace Symfony\Component\Finder\Adapter;
  56886. @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);
  56887. use Symfony\Component\Finder\Iterator;
  56888. class PhpAdapter extends AbstractAdapter
  56889. {
  56890. public function searchInDirectory($dir)
  56891. {
  56892. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  56893. if ($this->followLinks) {
  56894. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  56895. }
  56896. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  56897. if ($this->exclude) {
  56898. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  56899. }
  56900. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  56901. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  56902. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  56903. }
  56904. if ($this->mode) {
  56905. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  56906. }
  56907. if ($this->names || $this->notNames) {
  56908. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  56909. }
  56910. if ($this->contains || $this->notContains) {
  56911. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  56912. }
  56913. if ($this->sizes) {
  56914. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  56915. }
  56916. if ($this->dates) {
  56917. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  56918. }
  56919. if ($this->filters) {
  56920. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  56921. }
  56922. if ($this->paths || $this->notPaths) {
  56923. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  56924. }
  56925. if ($this->sort) {
  56926. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  56927. $iterator = $iteratorAggregate->getIterator();
  56928. }
  56929. return $iterator;
  56930. }
  56931. public function getName()
  56932. {
  56933. return 'php';
  56934. }
  56935. protected function canBeUsed()
  56936. {
  56937. return true;
  56938. }
  56939. }
  56940. <?php
  56941. namespace Symfony\Component\Finder\Comparator;
  56942. class Comparator
  56943. {
  56944. private $target;
  56945. private $operator = '==';
  56946. public function getTarget()
  56947. {
  56948. return $this->target;
  56949. }
  56950. public function setTarget($target)
  56951. {
  56952. $this->target = $target;
  56953. }
  56954. public function getOperator()
  56955. {
  56956. return $this->operator;
  56957. }
  56958. public function setOperator($operator)
  56959. {
  56960. if (!$operator) {
  56961. $operator = '==';
  56962. }
  56963. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  56964. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  56965. }
  56966. $this->operator = $operator;
  56967. }
  56968. public function test($test)
  56969. {
  56970. switch ($this->operator) {
  56971. case '>':
  56972. return $test > $this->target;
  56973. case '>=':
  56974. return $test >= $this->target;
  56975. case '<':
  56976. return $test < $this->target;
  56977. case '<=':
  56978. return $test <= $this->target;
  56979. case '!=':
  56980. return $test != $this->target;
  56981. }
  56982. return $test == $this->target;
  56983. }
  56984. }
  56985. <?php
  56986. namespace Symfony\Component\Finder\Comparator;
  56987. class DateComparator extends Comparator
  56988. {
  56989. public function __construct($test)
  56990. {
  56991. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  56992. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  56993. }
  56994. try {
  56995. $date = new \DateTime($matches[2]);
  56996. $target = $date->format('U');
  56997. } catch (\Exception $e) {
  56998. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  56999. }
  57000. $operator = isset($matches[1]) ? $matches[1] : '==';
  57001. if ('since' === $operator || 'after' === $operator) {
  57002. $operator = '>';
  57003. }
  57004. if ('until' === $operator || 'before' === $operator) {
  57005. $operator = '<';
  57006. }
  57007. $this->setOperator($operator);
  57008. $this->setTarget($target);
  57009. }
  57010. }
  57011. <?php
  57012. namespace Symfony\Component\Finder\Comparator;
  57013. class NumberComparator extends Comparator
  57014. {
  57015. public function __construct($test)
  57016. {
  57017. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  57018. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  57019. }
  57020. $target = $matches[2];
  57021. if (!is_numeric($target)) {
  57022. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  57023. }
  57024. if (isset($matches[3])) {
  57025. switch (strtolower($matches[3])) {
  57026. case 'k':
  57027. $target *= 1000;
  57028. break;
  57029. case 'ki':
  57030. $target *= 1024;
  57031. break;
  57032. case 'm':
  57033. $target *= 1000000;
  57034. break;
  57035. case 'mi':
  57036. $target *= 1024 * 1024;
  57037. break;
  57038. case 'g':
  57039. $target *= 1000000000;
  57040. break;
  57041. case 'gi':
  57042. $target *= 1024 * 1024 * 1024;
  57043. break;
  57044. }
  57045. }
  57046. $this->setTarget($target);
  57047. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  57048. }
  57049. }
  57050. <?php
  57051. namespace Symfony\Component\Finder\Exception;
  57052. class AccessDeniedException extends \UnexpectedValueException
  57053. {
  57054. }
  57055. <?php
  57056. namespace Symfony\Component\Finder\Exception;
  57057. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57058. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57059. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  57060. {
  57061. private $adapter;
  57062. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  57063. {
  57064. $this->adapter = $adapter;
  57065. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  57066. }
  57067. public function getAdapter()
  57068. {
  57069. return $this->adapter;
  57070. }
  57071. }
  57072. <?php
  57073. namespace Symfony\Component\Finder\Exception;
  57074. interface ExceptionInterface
  57075. {
  57076. public function getAdapter();
  57077. }
  57078. <?php
  57079. namespace Symfony\Component\Finder\Exception;
  57080. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57081. class OperationNotPermitedException extends AdapterFailureException
  57082. {
  57083. }
  57084. <?php
  57085. namespace Symfony\Component\Finder\Exception;
  57086. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57087. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57088. use Symfony\Component\Finder\Shell\Command;
  57089. class ShellCommandFailureException extends AdapterFailureException
  57090. {
  57091. private $command;
  57092. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  57093. {
  57094. $this->command = $command;
  57095. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  57096. }
  57097. public function getCommand()
  57098. {
  57099. return $this->command;
  57100. }
  57101. }
  57102. <?php
  57103. namespace Symfony\Component\Finder\Expression;
  57104. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57105. class Expression implements ValueInterface
  57106. {
  57107. const TYPE_REGEX = 1;
  57108. const TYPE_GLOB = 2;
  57109. private $value;
  57110. public static function create($expr)
  57111. {
  57112. return new self($expr);
  57113. }
  57114. public function __construct($expr)
  57115. {
  57116. try {
  57117. $this->value = Regex::create($expr);
  57118. } catch (\InvalidArgumentException $e) {
  57119. $this->value = new Glob($expr);
  57120. }
  57121. }
  57122. public function __toString()
  57123. {
  57124. return $this->render();
  57125. }
  57126. public function render()
  57127. {
  57128. return $this->value->render();
  57129. }
  57130. public function renderPattern()
  57131. {
  57132. return $this->value->renderPattern();
  57133. }
  57134. public function isCaseSensitive()
  57135. {
  57136. return $this->value->isCaseSensitive();
  57137. }
  57138. public function getType()
  57139. {
  57140. return $this->value->getType();
  57141. }
  57142. public function prepend($expr)
  57143. {
  57144. $this->value->prepend($expr);
  57145. return $this;
  57146. }
  57147. public function append($expr)
  57148. {
  57149. $this->value->append($expr);
  57150. return $this;
  57151. }
  57152. public function isRegex()
  57153. {
  57154. return self::TYPE_REGEX === $this->value->getType();
  57155. }
  57156. public function isGlob()
  57157. {
  57158. return self::TYPE_GLOB === $this->value->getType();
  57159. }
  57160. public function getGlob()
  57161. {
  57162. if (self::TYPE_GLOB !== $this->value->getType()) {
  57163. throw new \LogicException('Regex can\'t be transformed to glob.');
  57164. }
  57165. return $this->value;
  57166. }
  57167. public function getRegex()
  57168. {
  57169. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  57170. }
  57171. }
  57172. <?php
  57173. namespace Symfony\Component\Finder\Expression;
  57174. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57175. use Symfony\Component\Finder\Glob as FinderGlob;
  57176. class Glob implements ValueInterface
  57177. {
  57178. private $pattern;
  57179. public function __construct($pattern)
  57180. {
  57181. $this->pattern = $pattern;
  57182. }
  57183. public function render()
  57184. {
  57185. return $this->pattern;
  57186. }
  57187. public function renderPattern()
  57188. {
  57189. return $this->pattern;
  57190. }
  57191. public function getType()
  57192. {
  57193. return Expression::TYPE_GLOB;
  57194. }
  57195. public function isCaseSensitive()
  57196. {
  57197. return true;
  57198. }
  57199. public function prepend($expr)
  57200. {
  57201. $this->pattern = $expr.$this->pattern;
  57202. return $this;
  57203. }
  57204. public function append($expr)
  57205. {
  57206. $this->pattern .= $expr;
  57207. return $this;
  57208. }
  57209. public function isExpandable()
  57210. {
  57211. return false !== strpos($this->pattern, '{')
  57212. && false !== strpos($this->pattern, '}');
  57213. }
  57214. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  57215. {
  57216. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  57217. return new Regex($regex);
  57218. }
  57219. }
  57220. <?php
  57221. namespace Symfony\Component\Finder\Expression;
  57222. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57223. class Regex implements ValueInterface
  57224. {
  57225. const START_FLAG = '^';
  57226. const END_FLAG = '$';
  57227. const BOUNDARY = '~';
  57228. const JOKER = '.*';
  57229. const ESCAPING = '\\';
  57230. private $pattern;
  57231. private $options;
  57232. private $startFlag;
  57233. private $endFlag;
  57234. private $startJoker;
  57235. private $endJoker;
  57236. public static function create($expr)
  57237. {
  57238. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  57239. $start = substr($m[1], 0, 1);
  57240. $end = substr($m[1], -1);
  57241. if (
  57242. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  57243. || ('{' === $start && '}' === $end)
  57244. || ('(' === $start && ')' === $end)
  57245. ) {
  57246. return new self(substr($m[1], 1, -1), $m[2], $end);
  57247. }
  57248. }
  57249. throw new \InvalidArgumentException('Given expression is not a regex.');
  57250. }
  57251. public function __construct($pattern, $options = '', $delimiter = null)
  57252. {
  57253. if (null !== $delimiter) {
  57254. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  57255. }
  57256. $this->parsePattern($pattern);
  57257. $this->options = $options;
  57258. }
  57259. public function __toString()
  57260. {
  57261. return $this->render();
  57262. }
  57263. public function render()
  57264. {
  57265. return self::BOUNDARY
  57266. .$this->renderPattern()
  57267. .self::BOUNDARY
  57268. .$this->options;
  57269. }
  57270. public function renderPattern()
  57271. {
  57272. return ($this->startFlag ? self::START_FLAG : '')
  57273. .($this->startJoker ? self::JOKER : '')
  57274. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  57275. .($this->endJoker ? self::JOKER : '')
  57276. .($this->endFlag ? self::END_FLAG : '');
  57277. }
  57278. public function isCaseSensitive()
  57279. {
  57280. return !$this->hasOption('i');
  57281. }
  57282. public function getType()
  57283. {
  57284. return Expression::TYPE_REGEX;
  57285. }
  57286. public function prepend($expr)
  57287. {
  57288. $this->pattern = $expr.$this->pattern;
  57289. return $this;
  57290. }
  57291. public function append($expr)
  57292. {
  57293. $this->pattern .= $expr;
  57294. return $this;
  57295. }
  57296. public function hasOption($option)
  57297. {
  57298. return false !== strpos($this->options, $option);
  57299. }
  57300. public function addOption($option)
  57301. {
  57302. if (!$this->hasOption($option)) {
  57303. $this->options .= $option;
  57304. }
  57305. return $this;
  57306. }
  57307. public function removeOption($option)
  57308. {
  57309. $this->options = str_replace($option, '', $this->options);
  57310. return $this;
  57311. }
  57312. public function setStartFlag($startFlag)
  57313. {
  57314. $this->startFlag = $startFlag;
  57315. return $this;
  57316. }
  57317. public function hasStartFlag()
  57318. {
  57319. return $this->startFlag;
  57320. }
  57321. public function setEndFlag($endFlag)
  57322. {
  57323. $this->endFlag = (bool) $endFlag;
  57324. return $this;
  57325. }
  57326. public function hasEndFlag()
  57327. {
  57328. return $this->endFlag;
  57329. }
  57330. public function setStartJoker($startJoker)
  57331. {
  57332. $this->startJoker = $startJoker;
  57333. return $this;
  57334. }
  57335. public function hasStartJoker()
  57336. {
  57337. return $this->startJoker;
  57338. }
  57339. public function setEndJoker($endJoker)
  57340. {
  57341. $this->endJoker = (bool) $endJoker;
  57342. return $this;
  57343. }
  57344. public function hasEndJoker()
  57345. {
  57346. return $this->endJoker;
  57347. }
  57348. public function replaceJokers($replacement)
  57349. {
  57350. $replace = function ($subject) use ($replacement) {
  57351. $subject = $subject[0];
  57352. $replace = 0 === substr_count($subject, '\\') % 2;
  57353. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  57354. };
  57355. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  57356. return $this;
  57357. }
  57358. private function parsePattern($pattern)
  57359. {
  57360. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  57361. $pattern = substr($pattern, 1);
  57362. }
  57363. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  57364. $pattern = substr($pattern, 2);
  57365. }
  57366. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  57367. $pattern = substr($pattern, 0, -1);
  57368. }
  57369. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  57370. $pattern = substr($pattern, 0, -2);
  57371. }
  57372. $this->pattern = $pattern;
  57373. }
  57374. }
  57375. <?php
  57376. namespace Symfony\Component\Finder\Expression;
  57377. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57378. interface ValueInterface
  57379. {
  57380. public function render();
  57381. public function renderPattern();
  57382. public function isCaseSensitive();
  57383. public function getType();
  57384. public function prepend($expr);
  57385. public function append($expr);
  57386. }
  57387. <?php
  57388. namespace Symfony\Component\Finder;
  57389. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57390. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  57391. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  57392. use Symfony\Component\Finder\Adapter\PhpAdapter;
  57393. use Symfony\Component\Finder\Comparator\DateComparator;
  57394. use Symfony\Component\Finder\Comparator\NumberComparator;
  57395. use Symfony\Component\Finder\Exception\ExceptionInterface;
  57396. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  57397. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  57398. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  57399. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  57400. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  57401. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  57402. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  57403. use Symfony\Component\Finder\Iterator\SortableIterator;
  57404. class Finder implements \IteratorAggregate, \Countable
  57405. {
  57406. const IGNORE_VCS_FILES = 1;
  57407. const IGNORE_DOT_FILES = 2;
  57408. private $mode = 0;
  57409. private $names = array();
  57410. private $notNames = array();
  57411. private $exclude = array();
  57412. private $filters = array();
  57413. private $depths = array();
  57414. private $sizes = array();
  57415. private $followLinks = false;
  57416. private $sort = false;
  57417. private $ignore = 0;
  57418. private $dirs = array();
  57419. private $dates = array();
  57420. private $iterators = array();
  57421. private $contains = array();
  57422. private $notContains = array();
  57423. private $adapters = null;
  57424. private $paths = array();
  57425. private $notPaths = array();
  57426. private $ignoreUnreadableDirs = false;
  57427. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  57428. public function __construct()
  57429. {
  57430. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  57431. }
  57432. public static function create()
  57433. {
  57434. return new static();
  57435. }
  57436. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  57437. {
  57438. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57439. $this->initDefaultAdapters();
  57440. $this->adapters[$adapter->getName()] = array(
  57441. 'adapter' => $adapter,
  57442. 'priority' => $priority,
  57443. 'selected' => false,
  57444. );
  57445. return $this->sortAdapters();
  57446. }
  57447. public function useBestAdapter()
  57448. {
  57449. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57450. $this->initDefaultAdapters();
  57451. $this->resetAdapterSelection();
  57452. return $this->sortAdapters();
  57453. }
  57454. public function setAdapter($name)
  57455. {
  57456. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57457. $this->initDefaultAdapters();
  57458. if (!isset($this->adapters[$name])) {
  57459. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  57460. }
  57461. $this->resetAdapterSelection();
  57462. $this->adapters[$name]['selected'] = true;
  57463. return $this->sortAdapters();
  57464. }
  57465. public function removeAdapters()
  57466. {
  57467. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57468. $this->adapters = array();
  57469. return $this;
  57470. }
  57471. public function getAdapters()
  57472. {
  57473. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57474. $this->initDefaultAdapters();
  57475. return array_values(array_map(function (array $adapter) {
  57476. return $adapter['adapter'];
  57477. }, $this->adapters));
  57478. }
  57479. public function directories()
  57480. {
  57481. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  57482. return $this;
  57483. }
  57484. public function files()
  57485. {
  57486. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  57487. return $this;
  57488. }
  57489. public function depth($level)
  57490. {
  57491. $this->depths[] = new Comparator\NumberComparator($level);
  57492. return $this;
  57493. }
  57494. public function date($date)
  57495. {
  57496. $this->dates[] = new Comparator\DateComparator($date);
  57497. return $this;
  57498. }
  57499. public function name($pattern)
  57500. {
  57501. $this->names[] = $pattern;
  57502. return $this;
  57503. }
  57504. public function notName($pattern)
  57505. {
  57506. $this->notNames[] = $pattern;
  57507. return $this;
  57508. }
  57509. public function contains($pattern)
  57510. {
  57511. $this->contains[] = $pattern;
  57512. return $this;
  57513. }
  57514. public function notContains($pattern)
  57515. {
  57516. $this->notContains[] = $pattern;
  57517. return $this;
  57518. }
  57519. public function path($pattern)
  57520. {
  57521. $this->paths[] = $pattern;
  57522. return $this;
  57523. }
  57524. public function notPath($pattern)
  57525. {
  57526. $this->notPaths[] = $pattern;
  57527. return $this;
  57528. }
  57529. public function size($size)
  57530. {
  57531. $this->sizes[] = new Comparator\NumberComparator($size);
  57532. return $this;
  57533. }
  57534. public function exclude($dirs)
  57535. {
  57536. $this->exclude = array_merge($this->exclude, (array) $dirs);
  57537. return $this;
  57538. }
  57539. public function ignoreDotFiles($ignoreDotFiles)
  57540. {
  57541. if ($ignoreDotFiles) {
  57542. $this->ignore |= static::IGNORE_DOT_FILES;
  57543. } else {
  57544. $this->ignore &= ~static::IGNORE_DOT_FILES;
  57545. }
  57546. return $this;
  57547. }
  57548. public function ignoreVCS($ignoreVCS)
  57549. {
  57550. if ($ignoreVCS) {
  57551. $this->ignore |= static::IGNORE_VCS_FILES;
  57552. } else {
  57553. $this->ignore &= ~static::IGNORE_VCS_FILES;
  57554. }
  57555. return $this;
  57556. }
  57557. public static function addVCSPattern($pattern)
  57558. {
  57559. foreach ((array) $pattern as $p) {
  57560. self::$vcsPatterns[] = $p;
  57561. }
  57562. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  57563. }
  57564. public function sort(\Closure $closure)
  57565. {
  57566. $this->sort = $closure;
  57567. return $this;
  57568. }
  57569. public function sortByName()
  57570. {
  57571. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  57572. return $this;
  57573. }
  57574. public function sortByType()
  57575. {
  57576. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  57577. return $this;
  57578. }
  57579. public function sortByAccessedTime()
  57580. {
  57581. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  57582. return $this;
  57583. }
  57584. public function sortByChangedTime()
  57585. {
  57586. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  57587. return $this;
  57588. }
  57589. public function sortByModifiedTime()
  57590. {
  57591. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  57592. return $this;
  57593. }
  57594. public function filter(\Closure $closure)
  57595. {
  57596. $this->filters[] = $closure;
  57597. return $this;
  57598. }
  57599. public function followLinks()
  57600. {
  57601. $this->followLinks = true;
  57602. return $this;
  57603. }
  57604. public function ignoreUnreadableDirs($ignore = true)
  57605. {
  57606. $this->ignoreUnreadableDirs = (bool) $ignore;
  57607. return $this;
  57608. }
  57609. public function in($dirs)
  57610. {
  57611. $resolvedDirs = array();
  57612. foreach ((array) $dirs as $dir) {
  57613. if (is_dir($dir)) {
  57614. $resolvedDirs[] = $this->normalizeDir($dir);
  57615. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  57616. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  57617. } else {
  57618. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  57619. }
  57620. }
  57621. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  57622. return $this;
  57623. }
  57624. public function getIterator()
  57625. {
  57626. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  57627. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  57628. }
  57629. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  57630. return $this->searchInDirectory($this->dirs[0]);
  57631. }
  57632. $iterator = new \AppendIterator();
  57633. foreach ($this->dirs as $dir) {
  57634. $iterator->append($this->searchInDirectory($dir));
  57635. }
  57636. foreach ($this->iterators as $it) {
  57637. $iterator->append($it);
  57638. }
  57639. return $iterator;
  57640. }
  57641. public function append($iterator)
  57642. {
  57643. if ($iterator instanceof \IteratorAggregate) {
  57644. $this->iterators[] = $iterator->getIterator();
  57645. } elseif ($iterator instanceof \Iterator) {
  57646. $this->iterators[] = $iterator;
  57647. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  57648. $it = new \ArrayIterator();
  57649. foreach ($iterator as $file) {
  57650. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  57651. }
  57652. $this->iterators[] = $it;
  57653. } else {
  57654. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  57655. }
  57656. return $this;
  57657. }
  57658. public function count()
  57659. {
  57660. return iterator_count($this->getIterator());
  57661. }
  57662. private function sortAdapters()
  57663. {
  57664. uasort($this->adapters, function (array $a, array $b) {
  57665. if ($a['selected'] || $b['selected']) {
  57666. return $a['selected'] ? -1 : 1;
  57667. }
  57668. return $a['priority'] > $b['priority'] ? -1 : 1;
  57669. });
  57670. return $this;
  57671. }
  57672. private function searchInDirectory($dir)
  57673. {
  57674. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  57675. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  57676. }
  57677. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  57678. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  57679. }
  57680. if ($this->adapters) {
  57681. foreach ($this->adapters as $adapter) {
  57682. if ($adapter['adapter']->isSupported()) {
  57683. try {
  57684. return $this
  57685. ->buildAdapter($adapter['adapter'])
  57686. ->searchInDirectory($dir);
  57687. } catch (ExceptionInterface $e) {
  57688. }
  57689. }
  57690. }
  57691. }
  57692. $minDepth = 0;
  57693. $maxDepth = PHP_INT_MAX;
  57694. foreach ($this->depths as $comparator) {
  57695. switch ($comparator->getOperator()) {
  57696. case '>':
  57697. $minDepth = $comparator->getTarget() + 1;
  57698. break;
  57699. case '>=':
  57700. $minDepth = $comparator->getTarget();
  57701. break;
  57702. case '<':
  57703. $maxDepth = $comparator->getTarget() - 1;
  57704. break;
  57705. case '<=':
  57706. $maxDepth = $comparator->getTarget();
  57707. break;
  57708. default:
  57709. $minDepth = $maxDepth = $comparator->getTarget();
  57710. }
  57711. }
  57712. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  57713. if ($this->followLinks) {
  57714. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  57715. }
  57716. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  57717. if ($this->exclude) {
  57718. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  57719. }
  57720. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  57721. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  57722. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  57723. }
  57724. if ($this->mode) {
  57725. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  57726. }
  57727. if ($this->names || $this->notNames) {
  57728. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  57729. }
  57730. if ($this->contains || $this->notContains) {
  57731. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  57732. }
  57733. if ($this->sizes) {
  57734. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  57735. }
  57736. if ($this->dates) {
  57737. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  57738. }
  57739. if ($this->filters) {
  57740. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  57741. }
  57742. if ($this->paths || $this->notPaths) {
  57743. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  57744. }
  57745. if ($this->sort) {
  57746. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  57747. $iterator = $iteratorAggregate->getIterator();
  57748. }
  57749. return $iterator;
  57750. }
  57751. private function buildAdapter(AdapterInterface $adapter)
  57752. {
  57753. return $adapter
  57754. ->setFollowLinks($this->followLinks)
  57755. ->setDepths($this->depths)
  57756. ->setMode($this->mode)
  57757. ->setExclude($this->exclude)
  57758. ->setNames($this->names)
  57759. ->setNotNames($this->notNames)
  57760. ->setContains($this->contains)
  57761. ->setNotContains($this->notContains)
  57762. ->setSizes($this->sizes)
  57763. ->setDates($this->dates)
  57764. ->setFilters($this->filters)
  57765. ->setSort($this->sort)
  57766. ->setPath($this->paths)
  57767. ->setNotPath($this->notPaths)
  57768. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  57769. }
  57770. private function resetAdapterSelection()
  57771. {
  57772. $this->adapters = array_map(function (array $properties) {
  57773. $properties['selected'] = false;
  57774. return $properties;
  57775. }, $this->adapters);
  57776. }
  57777. private function initDefaultAdapters()
  57778. {
  57779. if (null === $this->adapters) {
  57780. $this->adapters = array();
  57781. $this
  57782. ->addAdapter(new GnuFindAdapter())
  57783. ->addAdapter(new BsdFindAdapter())
  57784. ->addAdapter(new PhpAdapter(), -50)
  57785. ->setAdapter('php')
  57786. ;
  57787. }
  57788. }
  57789. private function normalizeDir($dir)
  57790. {
  57791. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  57792. }
  57793. }
  57794. <?php
  57795. namespace Symfony\Component\Finder;
  57796. class Glob
  57797. {
  57798. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  57799. {
  57800. $firstByte = true;
  57801. $escaping = false;
  57802. $inCurlies = 0;
  57803. $regex = '';
  57804. $sizeGlob = \strlen($glob);
  57805. for ($i = 0; $i < $sizeGlob; ++$i) {
  57806. $car = $glob[$i];
  57807. if ($firstByte) {
  57808. if ($strictLeadingDot && '.' !== $car) {
  57809. $regex .= '(?=[^\.])';
  57810. }
  57811. $firstByte = false;
  57812. }
  57813. if ('/' === $car) {
  57814. $firstByte = true;
  57815. }
  57816. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  57817. $regex .= "\\$car";
  57818. } elseif ('*' === $car) {
  57819. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  57820. } elseif ('?' === $car) {
  57821. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  57822. } elseif ('{' === $car) {
  57823. $regex .= $escaping ? '\\{' : '(';
  57824. if (!$escaping) {
  57825. ++$inCurlies;
  57826. }
  57827. } elseif ('}' === $car && $inCurlies) {
  57828. $regex .= $escaping ? '}' : ')';
  57829. if (!$escaping) {
  57830. --$inCurlies;
  57831. }
  57832. } elseif (',' === $car && $inCurlies) {
  57833. $regex .= $escaping ? ',' : '|';
  57834. } elseif ('\\' === $car) {
  57835. if ($escaping) {
  57836. $regex .= '\\\\';
  57837. $escaping = false;
  57838. } else {
  57839. $escaping = true;
  57840. }
  57841. continue;
  57842. } else {
  57843. $regex .= $car;
  57844. }
  57845. $escaping = false;
  57846. }
  57847. return $delimiter.'^'.$regex.'$'.$delimiter;
  57848. }
  57849. }
  57850. <?php
  57851. namespace Symfony\Component\Finder\Iterator;
  57852. class CustomFilterIterator extends FilterIterator
  57853. {
  57854. private $filters = array();
  57855. public function __construct(\Iterator $iterator, array $filters)
  57856. {
  57857. foreach ($filters as $filter) {
  57858. if (!\is_callable($filter)) {
  57859. throw new \InvalidArgumentException('Invalid PHP callback.');
  57860. }
  57861. }
  57862. $this->filters = $filters;
  57863. parent::__construct($iterator);
  57864. }
  57865. public function accept()
  57866. {
  57867. $fileinfo = $this->current();
  57868. foreach ($this->filters as $filter) {
  57869. if (false === \call_user_func($filter, $fileinfo)) {
  57870. return false;
  57871. }
  57872. }
  57873. return true;
  57874. }
  57875. }
  57876. <?php
  57877. namespace Symfony\Component\Finder\Iterator;
  57878. use Symfony\Component\Finder\Comparator\DateComparator;
  57879. class DateRangeFilterIterator extends FilterIterator
  57880. {
  57881. private $comparators = array();
  57882. public function __construct(\Iterator $iterator, array $comparators)
  57883. {
  57884. $this->comparators = $comparators;
  57885. parent::__construct($iterator);
  57886. }
  57887. public function accept()
  57888. {
  57889. $fileinfo = $this->current();
  57890. if (!file_exists($fileinfo->getPathname())) {
  57891. return false;
  57892. }
  57893. $filedate = $fileinfo->getMTime();
  57894. foreach ($this->comparators as $compare) {
  57895. if (!$compare->test($filedate)) {
  57896. return false;
  57897. }
  57898. }
  57899. return true;
  57900. }
  57901. }
  57902. <?php
  57903. namespace Symfony\Component\Finder\Iterator;
  57904. class DepthRangeFilterIterator extends FilterIterator
  57905. {
  57906. private $minDepth = 0;
  57907. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  57908. {
  57909. $this->minDepth = $minDepth;
  57910. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  57911. parent::__construct($iterator);
  57912. }
  57913. public function accept()
  57914. {
  57915. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  57916. }
  57917. }
  57918. <?php
  57919. namespace Symfony\Component\Finder\Iterator;
  57920. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  57921. {
  57922. private $iterator;
  57923. private $isRecursive;
  57924. private $excludedDirs = array();
  57925. private $excludedPattern;
  57926. public function __construct(\Iterator $iterator, array $directories)
  57927. {
  57928. $this->iterator = $iterator;
  57929. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  57930. $patterns = array();
  57931. foreach ($directories as $directory) {
  57932. $directory = rtrim($directory, '/');
  57933. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  57934. $patterns[] = preg_quote($directory, '#');
  57935. } else {
  57936. $this->excludedDirs[$directory] = true;
  57937. }
  57938. }
  57939. if ($patterns) {
  57940. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  57941. }
  57942. parent::__construct($iterator);
  57943. }
  57944. public function accept()
  57945. {
  57946. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  57947. return false;
  57948. }
  57949. if ($this->excludedPattern) {
  57950. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  57951. $path = str_replace('\\', '/', $path);
  57952. return !preg_match($this->excludedPattern, $path);
  57953. }
  57954. return true;
  57955. }
  57956. public function hasChildren()
  57957. {
  57958. return $this->isRecursive && $this->iterator->hasChildren();
  57959. }
  57960. public function getChildren()
  57961. {
  57962. $children = new self($this->iterator->getChildren(), array());
  57963. $children->excludedDirs = $this->excludedDirs;
  57964. $children->excludedPattern = $this->excludedPattern;
  57965. return $children;
  57966. }
  57967. }
  57968. <?php
  57969. namespace Symfony\Component\Finder\Iterator;
  57970. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57971. use Symfony\Component\Finder\SplFileInfo;
  57972. class FilePathsIterator extends \ArrayIterator
  57973. {
  57974. private $baseDir;
  57975. private $baseDirLength;
  57976. private $subPath;
  57977. private $subPathname;
  57978. private $current;
  57979. public function __construct(array $paths, $baseDir)
  57980. {
  57981. $this->baseDir = $baseDir;
  57982. $this->baseDirLength = \strlen($baseDir);
  57983. parent::__construct($paths);
  57984. }
  57985. public function __call($name, array $arguments)
  57986. {
  57987. return \call_user_func_array(array($this->current(), $name), $arguments);
  57988. }
  57989. public function current()
  57990. {
  57991. return $this->current;
  57992. }
  57993. public function key()
  57994. {
  57995. return $this->current->getPathname();
  57996. }
  57997. public function next()
  57998. {
  57999. parent::next();
  58000. $this->buildProperties();
  58001. }
  58002. public function rewind()
  58003. {
  58004. parent::rewind();
  58005. $this->buildProperties();
  58006. }
  58007. public function getSubPath()
  58008. {
  58009. return $this->subPath;
  58010. }
  58011. public function getSubPathname()
  58012. {
  58013. return $this->subPathname;
  58014. }
  58015. private function buildProperties()
  58016. {
  58017. $absolutePath = parent::current();
  58018. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  58019. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  58020. $dir = \dirname($this->subPathname);
  58021. $this->subPath = '.' === $dir ? '' : $dir;
  58022. } else {
  58023. $this->subPath = $this->subPathname = '';
  58024. }
  58025. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  58026. }
  58027. }
  58028. <?php
  58029. namespace Symfony\Component\Finder\Iterator;
  58030. class FileTypeFilterIterator extends FilterIterator
  58031. {
  58032. const ONLY_FILES = 1;
  58033. const ONLY_DIRECTORIES = 2;
  58034. private $mode;
  58035. public function __construct(\Iterator $iterator, $mode)
  58036. {
  58037. $this->mode = $mode;
  58038. parent::__construct($iterator);
  58039. }
  58040. public function accept()
  58041. {
  58042. $fileinfo = $this->current();
  58043. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  58044. return false;
  58045. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  58046. return false;
  58047. }
  58048. return true;
  58049. }
  58050. }
  58051. <?php
  58052. namespace Symfony\Component\Finder\Iterator;
  58053. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  58054. {
  58055. public function accept()
  58056. {
  58057. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  58058. return true;
  58059. }
  58060. $fileinfo = $this->current();
  58061. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  58062. return false;
  58063. }
  58064. $content = $fileinfo->getContents();
  58065. if (!$content) {
  58066. return false;
  58067. }
  58068. return $this->isAccepted($content);
  58069. }
  58070. protected function toRegex($str)
  58071. {
  58072. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58073. }
  58074. }
  58075. <?php
  58076. namespace Symfony\Component\Finder\Iterator;
  58077. use Symfony\Component\Finder\Glob;
  58078. class FilenameFilterIterator extends MultiplePcreFilterIterator
  58079. {
  58080. public function accept()
  58081. {
  58082. return $this->isAccepted($this->current()->getFilename());
  58083. }
  58084. protected function toRegex($str)
  58085. {
  58086. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  58087. }
  58088. }
  58089. <?php
  58090. namespace Symfony\Component\Finder\Iterator;
  58091. abstract class FilterIterator extends \FilterIterator
  58092. {
  58093. public function rewind()
  58094. {
  58095. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  58096. parent::rewind();
  58097. return;
  58098. }
  58099. $iterator = $this;
  58100. while ($iterator instanceof \OuterIterator) {
  58101. $innerIterator = $iterator->getInnerIterator();
  58102. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  58103. if ($innerIterator->isRewindable()) {
  58104. $innerIterator->next();
  58105. $innerIterator->rewind();
  58106. }
  58107. } elseif ($innerIterator instanceof \FilesystemIterator) {
  58108. $innerIterator->next();
  58109. $innerIterator->rewind();
  58110. }
  58111. $iterator = $innerIterator;
  58112. }
  58113. parent::rewind();
  58114. }
  58115. }
  58116. <?php
  58117. namespace Symfony\Component\Finder\Iterator;
  58118. abstract class MultiplePcreFilterIterator extends FilterIterator
  58119. {
  58120. protected $matchRegexps = array();
  58121. protected $noMatchRegexps = array();
  58122. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  58123. {
  58124. foreach ($matchPatterns as $pattern) {
  58125. $this->matchRegexps[] = $this->toRegex($pattern);
  58126. }
  58127. foreach ($noMatchPatterns as $pattern) {
  58128. $this->noMatchRegexps[] = $this->toRegex($pattern);
  58129. }
  58130. parent::__construct($iterator);
  58131. }
  58132. protected function isAccepted($string)
  58133. {
  58134. foreach ($this->noMatchRegexps as $regex) {
  58135. if (preg_match($regex, $string)) {
  58136. return false;
  58137. }
  58138. }
  58139. if ($this->matchRegexps) {
  58140. foreach ($this->matchRegexps as $regex) {
  58141. if (preg_match($regex, $string)) {
  58142. return true;
  58143. }
  58144. }
  58145. return false;
  58146. }
  58147. return true;
  58148. }
  58149. protected function isRegex($str)
  58150. {
  58151. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  58152. $start = substr($m[1], 0, 1);
  58153. $end = substr($m[1], -1);
  58154. if ($start === $end) {
  58155. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  58156. }
  58157. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  58158. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  58159. return true;
  58160. }
  58161. }
  58162. }
  58163. return false;
  58164. }
  58165. abstract protected function toRegex($str);
  58166. }
  58167. <?php
  58168. namespace Symfony\Component\Finder\Iterator;
  58169. class PathFilterIterator extends MultiplePcreFilterIterator
  58170. {
  58171. public function accept()
  58172. {
  58173. $filename = $this->current()->getRelativePathname();
  58174. if ('\\' === \DIRECTORY_SEPARATOR) {
  58175. $filename = str_replace('\\', '/', $filename);
  58176. }
  58177. return $this->isAccepted($filename);
  58178. }
  58179. protected function toRegex($str)
  58180. {
  58181. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58182. }
  58183. }
  58184. <?php
  58185. namespace Symfony\Component\Finder\Iterator;
  58186. use Symfony\Component\Finder\Exception\AccessDeniedException;
  58187. use Symfony\Component\Finder\SplFileInfo;
  58188. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  58189. {
  58190. private $ignoreUnreadableDirs;
  58191. private $rewindable;
  58192. private $rootPath;
  58193. private $subPath;
  58194. private $directorySeparator = '/';
  58195. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  58196. {
  58197. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  58198. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  58199. }
  58200. parent::__construct($path, $flags);
  58201. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  58202. $this->rootPath = (string) $path;
  58203. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  58204. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  58205. }
  58206. }
  58207. public function current()
  58208. {
  58209. if (null === $subPathname = $this->subPath) {
  58210. $subPathname = $this->subPath = (string) $this->getSubPath();
  58211. }
  58212. if ('' !== $subPathname) {
  58213. $subPathname .= $this->directorySeparator;
  58214. }
  58215. $subPathname .= $this->getFilename();
  58216. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  58217. }
  58218. public function getChildren()
  58219. {
  58220. try {
  58221. $children = parent::getChildren();
  58222. if ($children instanceof self) {
  58223. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  58224. $children->rewindable = &$this->rewindable;
  58225. $children->rootPath = $this->rootPath;
  58226. }
  58227. return $children;
  58228. } catch (\UnexpectedValueException $e) {
  58229. if ($this->ignoreUnreadableDirs) {
  58230. return new \RecursiveArrayIterator(array());
  58231. } else {
  58232. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  58233. }
  58234. }
  58235. }
  58236. public function rewind()
  58237. {
  58238. if (false === $this->isRewindable()) {
  58239. return;
  58240. }
  58241. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  58242. parent::next();
  58243. }
  58244. parent::rewind();
  58245. }
  58246. public function isRewindable()
  58247. {
  58248. if (null !== $this->rewindable) {
  58249. return $this->rewindable;
  58250. }
  58251. if ('' === $this->getPath()) {
  58252. return $this->rewindable = false;
  58253. }
  58254. if (false !== $stream = @opendir($this->getPath())) {
  58255. $infos = stream_get_meta_data($stream);
  58256. closedir($stream);
  58257. if ($infos['seekable']) {
  58258. return $this->rewindable = true;
  58259. }
  58260. }
  58261. return $this->rewindable = false;
  58262. }
  58263. }
  58264. <?php
  58265. namespace Symfony\Component\Finder\Iterator;
  58266. use Symfony\Component\Finder\Comparator\NumberComparator;
  58267. class SizeRangeFilterIterator extends FilterIterator
  58268. {
  58269. private $comparators = array();
  58270. public function __construct(\Iterator $iterator, array $comparators)
  58271. {
  58272. $this->comparators = $comparators;
  58273. parent::__construct($iterator);
  58274. }
  58275. public function accept()
  58276. {
  58277. $fileinfo = $this->current();
  58278. if (!$fileinfo->isFile()) {
  58279. return true;
  58280. }
  58281. $filesize = $fileinfo->getSize();
  58282. foreach ($this->comparators as $compare) {
  58283. if (!$compare->test($filesize)) {
  58284. return false;
  58285. }
  58286. }
  58287. return true;
  58288. }
  58289. }
  58290. <?php
  58291. namespace Symfony\Component\Finder\Iterator;
  58292. class SortableIterator implements \IteratorAggregate
  58293. {
  58294. const SORT_BY_NAME = 1;
  58295. const SORT_BY_TYPE = 2;
  58296. const SORT_BY_ACCESSED_TIME = 3;
  58297. const SORT_BY_CHANGED_TIME = 4;
  58298. const SORT_BY_MODIFIED_TIME = 5;
  58299. private $iterator;
  58300. private $sort;
  58301. public function __construct(\Traversable $iterator, $sort)
  58302. {
  58303. $this->iterator = $iterator;
  58304. if (self::SORT_BY_NAME === $sort) {
  58305. $this->sort = function ($a, $b) {
  58306. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58307. };
  58308. } elseif (self::SORT_BY_TYPE === $sort) {
  58309. $this->sort = function ($a, $b) {
  58310. if ($a->isDir() && $b->isFile()) {
  58311. return -1;
  58312. } elseif ($a->isFile() && $b->isDir()) {
  58313. return 1;
  58314. }
  58315. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58316. };
  58317. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  58318. $this->sort = function ($a, $b) {
  58319. return $a->getATime() - $b->getATime();
  58320. };
  58321. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  58322. $this->sort = function ($a, $b) {
  58323. return $a->getCTime() - $b->getCTime();
  58324. };
  58325. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  58326. $this->sort = function ($a, $b) {
  58327. return $a->getMTime() - $b->getMTime();
  58328. };
  58329. } elseif (\is_callable($sort)) {
  58330. $this->sort = $sort;
  58331. } else {
  58332. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  58333. }
  58334. }
  58335. public function getIterator()
  58336. {
  58337. $array = iterator_to_array($this->iterator, true);
  58338. uasort($array, $this->sort);
  58339. return new \ArrayIterator($array);
  58340. }
  58341. }
  58342. Copyright (c) 2004-2018 Fabien Potencier
  58343. Permission is hereby granted, free of charge, to any person obtaining a copy
  58344. of this software and associated documentation files (the "Software"), to deal
  58345. in the Software without restriction, including without limitation the rights
  58346. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58347. copies of the Software, and to permit persons to whom the Software is furnished
  58348. to do so, subject to the following conditions:
  58349. The above copyright notice and this permission notice shall be included in all
  58350. copies or substantial portions of the Software.
  58351. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58352. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58353. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58354. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58355. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58356. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58357. THE SOFTWARE.
  58358. <?php
  58359. namespace Symfony\Component\Finder\Shell;
  58360. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58361. class Command
  58362. {
  58363. private $parent;
  58364. private $bits = array();
  58365. private $labels = array();
  58366. private $errorHandler;
  58367. public function __construct(Command $parent = null)
  58368. {
  58369. $this->parent = $parent;
  58370. }
  58371. public function __toString()
  58372. {
  58373. return $this->join();
  58374. }
  58375. public static function create(Command $parent = null)
  58376. {
  58377. return new self($parent);
  58378. }
  58379. public static function escape($input)
  58380. {
  58381. return escapeshellcmd($input);
  58382. }
  58383. public static function quote($input)
  58384. {
  58385. return escapeshellarg($input);
  58386. }
  58387. public function add($bit)
  58388. {
  58389. $this->bits[] = $bit;
  58390. return $this;
  58391. }
  58392. public function top($bit)
  58393. {
  58394. array_unshift($this->bits, $bit);
  58395. foreach ($this->labels as $label => $index) {
  58396. ++$this->labels[$label];
  58397. }
  58398. return $this;
  58399. }
  58400. public function arg($arg)
  58401. {
  58402. $this->bits[] = self::quote($arg);
  58403. return $this;
  58404. }
  58405. public function cmd($esc)
  58406. {
  58407. $this->bits[] = self::escape($esc);
  58408. return $this;
  58409. }
  58410. public function ins($label)
  58411. {
  58412. if (isset($this->labels[$label])) {
  58413. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  58414. }
  58415. $this->bits[] = self::create($this);
  58416. $this->labels[$label] = \count($this->bits) - 1;
  58417. return $this->bits[$this->labels[$label]];
  58418. }
  58419. public function get($label)
  58420. {
  58421. if (!isset($this->labels[$label])) {
  58422. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  58423. }
  58424. return $this->bits[$this->labels[$label]];
  58425. }
  58426. public function end()
  58427. {
  58428. if (null === $this->parent) {
  58429. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  58430. }
  58431. return $this->parent;
  58432. }
  58433. public function length()
  58434. {
  58435. return \count($this->bits);
  58436. }
  58437. public function setErrorHandler(\Closure $errorHandler)
  58438. {
  58439. $this->errorHandler = $errorHandler;
  58440. return $this;
  58441. }
  58442. public function getErrorHandler()
  58443. {
  58444. return $this->errorHandler;
  58445. }
  58446. public function execute()
  58447. {
  58448. if (null === $errorHandler = $this->errorHandler) {
  58449. exec($this->join(), $output);
  58450. } else {
  58451. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  58452. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  58453. if ($error = stream_get_contents($pipes[2])) {
  58454. $errorHandler($error);
  58455. }
  58456. proc_close($process);
  58457. }
  58458. return $output ?: array();
  58459. }
  58460. public function join()
  58461. {
  58462. return implode(' ', array_filter(
  58463. array_map(function ($bit) {
  58464. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  58465. }, $this->bits),
  58466. function ($bit) { return null !== $bit; }
  58467. ));
  58468. }
  58469. public function addAtIndex($bit, $index)
  58470. {
  58471. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  58472. return $this;
  58473. }
  58474. }
  58475. <?php
  58476. namespace Symfony\Component\Finder\Shell;
  58477. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58478. class Shell
  58479. {
  58480. const TYPE_UNIX = 1;
  58481. const TYPE_DARWIN = 2;
  58482. const TYPE_CYGWIN = 3;
  58483. const TYPE_WINDOWS = 4;
  58484. const TYPE_BSD = 5;
  58485. private $type;
  58486. public function getType()
  58487. {
  58488. if (null === $this->type) {
  58489. $this->type = $this->guessType();
  58490. }
  58491. return $this->type;
  58492. }
  58493. public function testCommand($command)
  58494. {
  58495. if (!\function_exists('exec')) {
  58496. return false;
  58497. }
  58498. $testCommand = 'which ';
  58499. if (self::TYPE_WINDOWS === $this->type) {
  58500. $testCommand = 'where ';
  58501. }
  58502. $command = escapeshellcmd($command);
  58503. exec($testCommand.$command, $output, $code);
  58504. return 0 === $code && \count($output) > 0;
  58505. }
  58506. private function guessType()
  58507. {
  58508. $os = strtolower(PHP_OS);
  58509. if (false !== strpos($os, 'cygwin')) {
  58510. return self::TYPE_CYGWIN;
  58511. }
  58512. if (false !== strpos($os, 'darwin')) {
  58513. return self::TYPE_DARWIN;
  58514. }
  58515. if (false !== strpos($os, 'bsd')) {
  58516. return self::TYPE_BSD;
  58517. }
  58518. if (0 === strpos($os, 'win')) {
  58519. return self::TYPE_WINDOWS;
  58520. }
  58521. return self::TYPE_UNIX;
  58522. }
  58523. }
  58524. <?php
  58525. namespace Symfony\Component\Finder;
  58526. class SplFileInfo extends \SplFileInfo
  58527. {
  58528. private $relativePath;
  58529. private $relativePathname;
  58530. public function __construct($file, $relativePath, $relativePathname)
  58531. {
  58532. parent::__construct($file);
  58533. $this->relativePath = $relativePath;
  58534. $this->relativePathname = $relativePathname;
  58535. }
  58536. public function getRelativePath()
  58537. {
  58538. return $this->relativePath;
  58539. }
  58540. public function getRelativePathname()
  58541. {
  58542. return $this->relativePathname;
  58543. }
  58544. public function getContents()
  58545. {
  58546. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  58547. $content = file_get_contents($this->getPathname());
  58548. restore_error_handler();
  58549. if (false === $content) {
  58550. throw new \RuntimeException($error);
  58551. }
  58552. return $content;
  58553. }
  58554. }
  58555. <?php
  58556. namespace Symfony\Polyfill\Ctype;
  58557. final class Ctype
  58558. {
  58559. public static function ctype_alnum($text)
  58560. {
  58561. $text = self::convert_int_to_char_for_ctype($text);
  58562. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  58563. }
  58564. public static function ctype_alpha($text)
  58565. {
  58566. $text = self::convert_int_to_char_for_ctype($text);
  58567. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  58568. }
  58569. public static function ctype_cntrl($text)
  58570. {
  58571. $text = self::convert_int_to_char_for_ctype($text);
  58572. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  58573. }
  58574. public static function ctype_digit($text)
  58575. {
  58576. $text = self::convert_int_to_char_for_ctype($text);
  58577. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  58578. }
  58579. public static function ctype_graph($text)
  58580. {
  58581. $text = self::convert_int_to_char_for_ctype($text);
  58582. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  58583. }
  58584. public static function ctype_lower($text)
  58585. {
  58586. $text = self::convert_int_to_char_for_ctype($text);
  58587. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  58588. }
  58589. public static function ctype_print($text)
  58590. {
  58591. $text = self::convert_int_to_char_for_ctype($text);
  58592. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  58593. }
  58594. public static function ctype_punct($text)
  58595. {
  58596. $text = self::convert_int_to_char_for_ctype($text);
  58597. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  58598. }
  58599. public static function ctype_space($text)
  58600. {
  58601. $text = self::convert_int_to_char_for_ctype($text);
  58602. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  58603. }
  58604. public static function ctype_upper($text)
  58605. {
  58606. $text = self::convert_int_to_char_for_ctype($text);
  58607. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  58608. }
  58609. public static function ctype_xdigit($text)
  58610. {
  58611. $text = self::convert_int_to_char_for_ctype($text);
  58612. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  58613. }
  58614. private static function convert_int_to_char_for_ctype($int)
  58615. {
  58616. if (!\is_int($int)) {
  58617. return $int;
  58618. }
  58619. if ($int < -128 || $int > 255) {
  58620. return (string) $int;
  58621. }
  58622. if ($int < 0) {
  58623. $int += 256;
  58624. }
  58625. return \chr($int);
  58626. }
  58627. }
  58628. Copyright (c) 2018-2019 Fabien Potencier
  58629. Permission is hereby granted, free of charge, to any person obtaining a copy
  58630. of this software and associated documentation files (the "Software"), to deal
  58631. in the Software without restriction, including without limitation the rights
  58632. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58633. copies of the Software, and to permit persons to whom the Software is furnished
  58634. to do so, subject to the following conditions:
  58635. The above copyright notice and this permission notice shall be included in all
  58636. copies or substantial portions of the Software.
  58637. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58638. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58639. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58640. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58641. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58642. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58643. THE SOFTWARE.
  58644. <?php
  58645. use Symfony\Polyfill\Ctype as p;
  58646. if (!function_exists('ctype_alnum')) {
  58647. function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); }
  58648. }
  58649. if (!function_exists('ctype_alpha')) {
  58650. function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); }
  58651. }
  58652. if (!function_exists('ctype_cntrl')) {
  58653. function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); }
  58654. }
  58655. if (!function_exists('ctype_digit')) {
  58656. function ctype_digit($input) { return p\Ctype::ctype_digit($input); }
  58657. }
  58658. if (!function_exists('ctype_graph')) {
  58659. function ctype_graph($input) { return p\Ctype::ctype_graph($input); }
  58660. }
  58661. if (!function_exists('ctype_lower')) {
  58662. function ctype_lower($input) { return p\Ctype::ctype_lower($input); }
  58663. }
  58664. if (!function_exists('ctype_print')) {
  58665. function ctype_print($input) { return p\Ctype::ctype_print($input); }
  58666. }
  58667. if (!function_exists('ctype_punct')) {
  58668. function ctype_punct($input) { return p\Ctype::ctype_punct($input); }
  58669. }
  58670. if (!function_exists('ctype_space')) {
  58671. function ctype_space($input) { return p\Ctype::ctype_space($input); }
  58672. }
  58673. if (!function_exists('ctype_upper')) {
  58674. function ctype_upper($input) { return p\Ctype::ctype_upper($input); }
  58675. }
  58676. if (!function_exists('ctype_xdigit')) {
  58677. function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); }
  58678. }
  58679. Copyright (c) 2015-2019 Fabien Potencier
  58680. Permission is hereby granted, free of charge, to any person obtaining a copy
  58681. of this software and associated documentation files (the "Software"), to deal
  58682. in the Software without restriction, including without limitation the rights
  58683. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58684. copies of the Software, and to permit persons to whom the Software is furnished
  58685. to do so, subject to the following conditions:
  58686. The above copyright notice and this permission notice shall be included in all
  58687. copies or substantial portions of the Software.
  58688. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58689. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58690. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58691. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58692. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58693. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58694. THE SOFTWARE.
  58695. <?php
  58696. namespace Symfony\Polyfill\Mbstring;
  58697. final class Mbstring
  58698. {
  58699. const MB_CASE_FOLD = PHP_INT_MAX;
  58700. private static $encodingList = array('ASCII', 'UTF-8');
  58701. private static $language = 'neutral';
  58702. private static $internalEncoding = 'UTF-8';
  58703. private static $caseFold = array(
  58704. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  58705. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  58706. );
  58707. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  58708. {
  58709. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  58710. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  58711. } else {
  58712. $fromEncoding = self::getEncoding($fromEncoding);
  58713. }
  58714. $toEncoding = self::getEncoding($toEncoding);
  58715. if ('BASE64' === $fromEncoding) {
  58716. $s = base64_decode($s);
  58717. $fromEncoding = $toEncoding;
  58718. }
  58719. if ('BASE64' === $toEncoding) {
  58720. return base64_encode($s);
  58721. }
  58722. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  58723. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  58724. $fromEncoding = 'Windows-1252';
  58725. }
  58726. if ('UTF-8' !== $fromEncoding) {
  58727. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  58728. }
  58729. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  58730. }
  58731. if ('HTML-ENTITIES' === $fromEncoding) {
  58732. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  58733. $fromEncoding = 'UTF-8';
  58734. }
  58735. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  58736. }
  58737. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  58738. {
  58739. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  58740. $ok = true;
  58741. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  58742. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  58743. $ok = false;
  58744. }
  58745. });
  58746. return $ok ? $fromEncoding : false;
  58747. }
  58748. public static function mb_decode_mimeheader($s)
  58749. {
  58750. return iconv_mime_decode($s, 2, self::$internalEncoding);
  58751. }
  58752. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  58753. {
  58754. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  58755. }
  58756. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  58757. {
  58758. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  58759. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  58760. return null;
  58761. }
  58762. if (!\is_array($convmap) || !$convmap) {
  58763. return false;
  58764. }
  58765. if (null !== $encoding && !\is_scalar($encoding)) {
  58766. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  58767. return '';
  58768. }
  58769. $s = (string) $s;
  58770. if ('' === $s) {
  58771. return '';
  58772. }
  58773. $encoding = self::getEncoding($encoding);
  58774. if ('UTF-8' === $encoding) {
  58775. $encoding = null;
  58776. if (!preg_match('//u', $s)) {
  58777. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  58778. }
  58779. } else {
  58780. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  58781. }
  58782. $cnt = floor(\count($convmap) / 4) * 4;
  58783. for ($i = 0; $i < $cnt; $i += 4) {
  58784. $convmap[$i] += $convmap[$i + 2];
  58785. $convmap[$i + 1] += $convmap[$i + 2];
  58786. }
  58787. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  58788. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  58789. for ($i = 0; $i < $cnt; $i += 4) {
  58790. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  58791. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  58792. }
  58793. }
  58794. return $m[0];
  58795. }, $s);
  58796. if (null === $encoding) {
  58797. return $s;
  58798. }
  58799. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  58800. }
  58801. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  58802. {
  58803. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  58804. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  58805. return null;
  58806. }
  58807. if (!\is_array($convmap) || !$convmap) {
  58808. return false;
  58809. }
  58810. if (null !== $encoding && !\is_scalar($encoding)) {
  58811. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  58812. return null;
  58813. }
  58814. if (null !== $is_hex && !\is_scalar($is_hex)) {
  58815. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  58816. return null;
  58817. }
  58818. $s = (string) $s;
  58819. if ('' === $s) {
  58820. return '';
  58821. }
  58822. $encoding = self::getEncoding($encoding);
  58823. if ('UTF-8' === $encoding) {
  58824. $encoding = null;
  58825. if (!preg_match('//u', $s)) {
  58826. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  58827. }
  58828. } else {
  58829. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  58830. }
  58831. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  58832. $cnt = floor(\count($convmap) / 4) * 4;
  58833. $i = 0;
  58834. $len = \strlen($s);
  58835. $result = '';
  58836. while ($i < $len) {
  58837. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  58838. $uchr = substr($s, $i, $ulen);
  58839. $i += $ulen;
  58840. $c = self::mb_ord($uchr);
  58841. for ($j = 0; $j < $cnt; $j += 4) {
  58842. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  58843. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  58844. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  58845. continue 2;
  58846. }
  58847. }
  58848. $result .= $uchr;
  58849. }
  58850. if (null === $encoding) {
  58851. return $result;
  58852. }
  58853. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  58854. }
  58855. public static function mb_convert_case($s, $mode, $encoding = null)
  58856. {
  58857. $s = (string) $s;
  58858. if ('' === $s) {
  58859. return '';
  58860. }
  58861. $encoding = self::getEncoding($encoding);
  58862. if ('UTF-8' === $encoding) {
  58863. $encoding = null;
  58864. if (!preg_match('//u', $s)) {
  58865. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  58866. }
  58867. } else {
  58868. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  58869. }
  58870. if (MB_CASE_TITLE == $mode) {
  58871. static $titleRegexp = null;
  58872. if (null === $titleRegexp) {
  58873. $titleRegexp = self::getData('titleCaseRegexp');
  58874. }
  58875. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  58876. } else {
  58877. if (MB_CASE_UPPER == $mode) {
  58878. static $upper = null;
  58879. if (null === $upper) {
  58880. $upper = self::getData('upperCase');
  58881. }
  58882. $map = $upper;
  58883. } else {
  58884. if (self::MB_CASE_FOLD === $mode) {
  58885. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  58886. }
  58887. static $lower = null;
  58888. if (null === $lower) {
  58889. $lower = self::getData('lowerCase');
  58890. }
  58891. $map = $lower;
  58892. }
  58893. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  58894. $i = 0;
  58895. $len = \strlen($s);
  58896. while ($i < $len) {
  58897. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  58898. $uchr = substr($s, $i, $ulen);
  58899. $i += $ulen;
  58900. if (isset($map[$uchr])) {
  58901. $uchr = $map[$uchr];
  58902. $nlen = \strlen($uchr);
  58903. if ($nlen == $ulen) {
  58904. $nlen = $i;
  58905. do {
  58906. $s[--$nlen] = $uchr[--$ulen];
  58907. } while ($ulen);
  58908. } else {
  58909. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  58910. $len += $nlen - $ulen;
  58911. $i += $nlen - $ulen;
  58912. }
  58913. }
  58914. }
  58915. }
  58916. if (null === $encoding) {
  58917. return $s;
  58918. }
  58919. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  58920. }
  58921. public static function mb_internal_encoding($encoding = null)
  58922. {
  58923. if (null === $encoding) {
  58924. return self::$internalEncoding;
  58925. }
  58926. $encoding = self::getEncoding($encoding);
  58927. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  58928. self::$internalEncoding = $encoding;
  58929. return true;
  58930. }
  58931. return false;
  58932. }
  58933. public static function mb_language($lang = null)
  58934. {
  58935. if (null === $lang) {
  58936. return self::$language;
  58937. }
  58938. switch ($lang = strtolower($lang)) {
  58939. case 'uni':
  58940. case 'neutral':
  58941. self::$language = $lang;
  58942. return true;
  58943. }
  58944. return false;
  58945. }
  58946. public static function mb_list_encodings()
  58947. {
  58948. return array('UTF-8');
  58949. }
  58950. public static function mb_encoding_aliases($encoding)
  58951. {
  58952. switch (strtoupper($encoding)) {
  58953. case 'UTF8':
  58954. case 'UTF-8':
  58955. return array('utf8');
  58956. }
  58957. return false;
  58958. }
  58959. public static function mb_check_encoding($var = null, $encoding = null)
  58960. {
  58961. if (null === $encoding) {
  58962. if (null === $var) {
  58963. return false;
  58964. }
  58965. $encoding = self::$internalEncoding;
  58966. }
  58967. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  58968. }
  58969. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  58970. {
  58971. if (null === $encodingList) {
  58972. $encodingList = self::$encodingList;
  58973. } else {
  58974. if (!\is_array($encodingList)) {
  58975. $encodingList = array_map('trim', explode(',', $encodingList));
  58976. }
  58977. $encodingList = array_map('strtoupper', $encodingList);
  58978. }
  58979. foreach ($encodingList as $enc) {
  58980. switch ($enc) {
  58981. case 'ASCII':
  58982. if (!preg_match('/[\x80-\xFF]/', $str)) {
  58983. return $enc;
  58984. }
  58985. break;
  58986. case 'UTF8':
  58987. case 'UTF-8':
  58988. if (preg_match('//u', $str)) {
  58989. return 'UTF-8';
  58990. }
  58991. break;
  58992. default:
  58993. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  58994. return $enc;
  58995. }
  58996. }
  58997. }
  58998. return false;
  58999. }
  59000. public static function mb_detect_order($encodingList = null)
  59001. {
  59002. if (null === $encodingList) {
  59003. return self::$encodingList;
  59004. }
  59005. if (!\is_array($encodingList)) {
  59006. $encodingList = array_map('trim', explode(',', $encodingList));
  59007. }
  59008. $encodingList = array_map('strtoupper', $encodingList);
  59009. foreach ($encodingList as $enc) {
  59010. switch ($enc) {
  59011. default:
  59012. if (strncmp($enc, 'ISO-8859-', 9)) {
  59013. return false;
  59014. }
  59015. case 'ASCII':
  59016. case 'UTF8':
  59017. case 'UTF-8':
  59018. }
  59019. }
  59020. self::$encodingList = $encodingList;
  59021. return true;
  59022. }
  59023. public static function mb_strlen($s, $encoding = null)
  59024. {
  59025. $encoding = self::getEncoding($encoding);
  59026. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59027. return \strlen($s);
  59028. }
  59029. return @iconv_strlen($s, $encoding);
  59030. }
  59031. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  59032. {
  59033. $encoding = self::getEncoding($encoding);
  59034. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59035. return strpos($haystack, $needle, $offset);
  59036. }
  59037. $needle = (string) $needle;
  59038. if ('' === $needle) {
  59039. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  59040. return false;
  59041. }
  59042. return iconv_strpos($haystack, $needle, $offset, $encoding);
  59043. }
  59044. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  59045. {
  59046. $encoding = self::getEncoding($encoding);
  59047. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59048. return strrpos($haystack, $needle, $offset);
  59049. }
  59050. if ($offset != (int) $offset) {
  59051. $offset = 0;
  59052. } elseif ($offset = (int) $offset) {
  59053. if ($offset < 0) {
  59054. if (0 > $offset += self::mb_strlen($needle)) {
  59055. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  59056. }
  59057. $offset = 0;
  59058. } else {
  59059. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  59060. }
  59061. }
  59062. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59063. return false !== $pos ? $offset + $pos : false;
  59064. }
  59065. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  59066. {
  59067. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
  59068. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
  59069. return null;
  59070. }
  59071. if (1 > $split_length = (int) $split_length) {
  59072. trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
  59073. return false;
  59074. }
  59075. if (null === $encoding) {
  59076. $encoding = mb_internal_encoding();
  59077. }
  59078. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  59079. $rx = '/(';
  59080. while (65535 < $split_length) {
  59081. $rx .= '.{65535}';
  59082. $split_length -= 65535;
  59083. }
  59084. $rx .= '.{'.$split_length.'})/us';
  59085. return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  59086. }
  59087. $result = array();
  59088. $length = mb_strlen($string, $encoding);
  59089. for ($i = 0; $i < $length; $i += $split_length) {
  59090. $result[] = mb_substr($string, $i, $split_length, $encoding);
  59091. }
  59092. return $result;
  59093. }
  59094. public static function mb_strtolower($s, $encoding = null)
  59095. {
  59096. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  59097. }
  59098. public static function mb_strtoupper($s, $encoding = null)
  59099. {
  59100. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  59101. }
  59102. public static function mb_substitute_character($c = null)
  59103. {
  59104. if (0 === strcasecmp($c, 'none')) {
  59105. return true;
  59106. }
  59107. return null !== $c ? false : 'none';
  59108. }
  59109. public static function mb_substr($s, $start, $length = null, $encoding = null)
  59110. {
  59111. $encoding = self::getEncoding($encoding);
  59112. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59113. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  59114. }
  59115. if ($start < 0) {
  59116. $start = iconv_strlen($s, $encoding) + $start;
  59117. if ($start < 0) {
  59118. $start = 0;
  59119. }
  59120. }
  59121. if (null === $length) {
  59122. $length = 2147483647;
  59123. } elseif ($length < 0) {
  59124. $length = iconv_strlen($s, $encoding) + $length - $start;
  59125. if ($length < 0) {
  59126. return '';
  59127. }
  59128. }
  59129. return (string) iconv_substr($s, $start, $length, $encoding);
  59130. }
  59131. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  59132. {
  59133. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59134. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59135. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  59136. }
  59137. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  59138. {
  59139. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  59140. return self::getSubpart($pos, $part, $haystack, $encoding);
  59141. }
  59142. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  59143. {
  59144. $encoding = self::getEncoding($encoding);
  59145. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59146. $pos = strrpos($haystack, $needle);
  59147. } else {
  59148. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59149. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59150. }
  59151. return self::getSubpart($pos, $part, $haystack, $encoding);
  59152. }
  59153. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  59154. {
  59155. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59156. $pos = self::mb_strripos($haystack, $needle, $encoding);
  59157. return self::getSubpart($pos, $part, $haystack, $encoding);
  59158. }
  59159. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  59160. {
  59161. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59162. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59163. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  59164. }
  59165. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  59166. {
  59167. $pos = strpos($haystack, $needle);
  59168. if (false === $pos) {
  59169. return false;
  59170. }
  59171. if ($part) {
  59172. return substr($haystack, 0, $pos);
  59173. }
  59174. return substr($haystack, $pos);
  59175. }
  59176. public static function mb_get_info($type = 'all')
  59177. {
  59178. $info = array(
  59179. 'internal_encoding' => self::$internalEncoding,
  59180. 'http_output' => 'pass',
  59181. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  59182. 'func_overload' => 0,
  59183. 'func_overload_list' => 'no overload',
  59184. 'mail_charset' => 'UTF-8',
  59185. 'mail_header_encoding' => 'BASE64',
  59186. 'mail_body_encoding' => 'BASE64',
  59187. 'illegal_chars' => 0,
  59188. 'encoding_translation' => 'Off',
  59189. 'language' => self::$language,
  59190. 'detect_order' => self::$encodingList,
  59191. 'substitute_character' => 'none',
  59192. 'strict_detection' => 'Off',
  59193. );
  59194. if ('all' === $type) {
  59195. return $info;
  59196. }
  59197. if (isset($info[$type])) {
  59198. return $info[$type];
  59199. }
  59200. return false;
  59201. }
  59202. public static function mb_http_input($type = '')
  59203. {
  59204. return false;
  59205. }
  59206. public static function mb_http_output($encoding = null)
  59207. {
  59208. return null !== $encoding ? 'pass' === $encoding : 'pass';
  59209. }
  59210. public static function mb_strwidth($s, $encoding = null)
  59211. {
  59212. $encoding = self::getEncoding($encoding);
  59213. if ('UTF-8' !== $encoding) {
  59214. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59215. }
  59216. $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);
  59217. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  59218. }
  59219. public static function mb_substr_count($haystack, $needle, $encoding = null)
  59220. {
  59221. return substr_count($haystack, $needle);
  59222. }
  59223. public static function mb_output_handler($contents, $status)
  59224. {
  59225. return $contents;
  59226. }
  59227. public static function mb_chr($code, $encoding = null)
  59228. {
  59229. if (0x80 > $code %= 0x200000) {
  59230. $s = \chr($code);
  59231. } elseif (0x800 > $code) {
  59232. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  59233. } elseif (0x10000 > $code) {
  59234. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59235. } else {
  59236. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59237. }
  59238. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59239. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  59240. }
  59241. return $s;
  59242. }
  59243. public static function mb_ord($s, $encoding = null)
  59244. {
  59245. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59246. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  59247. }
  59248. if (1 === \strlen($s)) {
  59249. return \ord($s);
  59250. }
  59251. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  59252. if (0xF0 <= $code) {
  59253. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  59254. }
  59255. if (0xE0 <= $code) {
  59256. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  59257. }
  59258. if (0xC0 <= $code) {
  59259. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  59260. }
  59261. return $code;
  59262. }
  59263. private static function getSubpart($pos, $part, $haystack, $encoding)
  59264. {
  59265. if (false === $pos) {
  59266. return false;
  59267. }
  59268. if ($part) {
  59269. return self::mb_substr($haystack, 0, $pos, $encoding);
  59270. }
  59271. return self::mb_substr($haystack, $pos, null, $encoding);
  59272. }
  59273. private static function html_encoding_callback(array $m)
  59274. {
  59275. $i = 1;
  59276. $entities = '';
  59277. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  59278. while (isset($m[$i])) {
  59279. if (0x80 > $m[$i]) {
  59280. $entities .= \chr($m[$i++]);
  59281. continue;
  59282. }
  59283. if (0xF0 <= $m[$i]) {
  59284. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59285. } elseif (0xE0 <= $m[$i]) {
  59286. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59287. } else {
  59288. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  59289. }
  59290. $entities .= '&#'.$c.';';
  59291. }
  59292. return $entities;
  59293. }
  59294. private static function title_case(array $s)
  59295. {
  59296. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  59297. }
  59298. private static function getData($file)
  59299. {
  59300. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  59301. return require $file;
  59302. }
  59303. return false;
  59304. }
  59305. private static function getEncoding($encoding)
  59306. {
  59307. if (null === $encoding) {
  59308. return self::$internalEncoding;
  59309. }
  59310. if ('UTF-8' === $encoding) {
  59311. return 'UTF-8';
  59312. }
  59313. $encoding = strtoupper($encoding);
  59314. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  59315. return 'CP850';
  59316. }
  59317. if ('UTF8' === $encoding) {
  59318. return 'UTF-8';
  59319. }
  59320. return $encoding;
  59321. }
  59322. }
  59323. <?php
  59324. use Symfony\Polyfill\Mbstring as p;
  59325. if (!function_exists('mb_convert_variables')) {
  59326. function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
  59327. {
  59328. $vars = [&$var, ...$vars];
  59329. $ok = true;
  59330. array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
  59331. if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
  59332. $ok = false;
  59333. }
  59334. });
  59335. return $ok ? $from_encoding : false;
  59336. }
  59337. }
  59338. <?php
  59339. return array (
  59340. 'A' => 'a',
  59341. 'B' => 'b',
  59342. 'C' => 'c',
  59343. 'D' => 'd',
  59344. 'E' => 'e',
  59345. 'F' => 'f',
  59346. 'G' => 'g',
  59347. 'H' => 'h',
  59348. 'I' => 'i',
  59349. 'J' => 'j',
  59350. 'K' => 'k',
  59351. 'L' => 'l',
  59352. 'M' => 'm',
  59353. 'N' => 'n',
  59354. 'O' => 'o',
  59355. 'P' => 'p',
  59356. 'Q' => 'q',
  59357. 'R' => 'r',
  59358. 'S' => 's',
  59359. 'T' => 't',
  59360. 'U' => 'u',
  59361. 'V' => 'v',
  59362. 'W' => 'w',
  59363. 'X' => 'x',
  59364. 'Y' => 'y',
  59365. 'Z' => 'z',
  59366. 'À' => 'à',
  59367. '�' => 'á',
  59368. 'Â' => 'â',
  59369. 'Ã' => 'ã',
  59370. 'Ä' => 'ä',
  59371. 'Ã…' => 'Ã¥',
  59372. 'Æ' => 'æ',
  59373. 'Ç' => 'ç',
  59374. 'È' => 'è',
  59375. 'É' => 'é',
  59376. 'Ê' => 'ê',
  59377. 'Ë' => 'ë',
  59378. 'Ì' => 'ì',
  59379. '�' => 'í',
  59380. 'Î' => 'î',
  59381. '�' => 'ï',
  59382. '�' => 'ð',
  59383. 'Ñ' => 'ñ',
  59384. 'Ò' => 'ò',
  59385. 'Ó' => 'ó',
  59386. 'Ô' => 'ô',
  59387. 'Õ' => 'õ',
  59388. 'Ö' => 'ö',
  59389. 'Ø' => 'ø',
  59390. 'Ù' => 'ù',
  59391. 'Ú' => 'ú',
  59392. 'Û' => 'û',
  59393. 'Ü' => 'ü',
  59394. '�' => 'ý',
  59395. 'Þ' => 'þ',
  59396. 'Ā' => '�',
  59397. 'Ă' => 'ă',
  59398. 'Ä„' => 'Ä…',
  59399. 'Ć' => 'ć',
  59400. 'Ĉ' => 'ĉ',
  59401. 'ÄŠ' => 'Ä‹',
  59402. 'Č' => '�',
  59403. 'Ď' => '�',
  59404. '�' => 'đ',
  59405. 'Ä’' => 'Ä“',
  59406. 'Ä”' => 'Ä•',
  59407. 'Ä–' => 'Ä—',
  59408. 'Ę' => 'ę',
  59409. 'Äš' => 'Ä›',
  59410. 'Ĝ' => '�',
  59411. 'Äž' => 'ÄŸ',
  59412. 'Ä ' => 'Ä¡',
  59413. 'Ä¢' => 'Ä£',
  59414. 'Ĥ' => 'ĥ',
  59415. 'Ħ' => 'ħ',
  59416. 'Ĩ' => 'ĩ',
  59417. 'Ī' => 'ī',
  59418. 'Ĭ' => 'ĭ',
  59419. 'Į' => 'į',
  59420. 'İ' => 'i',
  59421. 'IJ' => 'ij',
  59422. 'Ĵ' => 'ĵ',
  59423. 'Ķ' => 'ķ',
  59424. 'Ĺ' => 'ĺ',
  59425. 'Ļ' => 'ļ',
  59426. 'Ľ' => 'ľ',
  59427. 'Ä¿' => 'Å€',
  59428. '�' => 'ł',
  59429. 'Ń' => 'ń',
  59430. 'Ņ' => 'ņ',
  59431. 'Ň' => 'ň',
  59432. 'ÅŠ' => 'Å‹',
  59433. 'Ō' => '�',
  59434. 'Ŏ' => '�',
  59435. '�' => 'ő',
  59436. 'Å’' => 'Å“',
  59437. 'Å”' => 'Å•',
  59438. 'Å–' => 'Å—',
  59439. 'Ř' => 'ř',
  59440. 'Åš' => 'Å›',
  59441. 'Ŝ' => '�',
  59442. 'Åž' => 'ÅŸ',
  59443. 'Å ' => 'Å¡',
  59444. 'Å¢' => 'Å£',
  59445. 'Ť' => 'ť',
  59446. 'Ŧ' => 'ŧ',
  59447. 'Ũ' => 'ũ',
  59448. 'Ū' => 'ū',
  59449. 'Ŭ' => 'ŭ',
  59450. 'Ů' => 'ů',
  59451. 'Ű' => 'ű',
  59452. 'Ų' => 'ų',
  59453. 'Ŵ' => 'ŵ',
  59454. 'Ŷ' => 'ŷ',
  59455. 'Ÿ' => 'ÿ',
  59456. 'Ź' => 'ź',
  59457. 'Ż' => 'ż',
  59458. 'Ž' => 'ž',
  59459. '�' => 'ɓ',
  59460. 'Ƃ' => 'ƃ',
  59461. 'Æ„' => 'Æ…',
  59462. 'Ɔ' => 'ɔ',
  59463. 'Ƈ' => 'ƈ',
  59464. 'Ɖ' => 'ɖ',
  59465. 'ÆŠ' => 'É—',
  59466. 'Ƌ' => 'ƌ',
  59467. 'Ǝ' => '�',
  59468. '�' => 'ə',
  59469. '�' => 'ɛ',
  59470. 'Æ‘' => 'Æ’',
  59471. 'Æ“' => 'É ',
  59472. 'Æ”' => 'É£',
  59473. 'Æ–' => 'É©',
  59474. 'Ɨ' => 'ɨ',
  59475. 'Ƙ' => 'ƙ',
  59476. 'Ɯ' => 'ɯ',
  59477. '�' => 'ɲ',
  59478. 'Ɵ' => 'ɵ',
  59479. 'Æ ' => 'Æ¡',
  59480. 'Æ¢' => 'Æ£',
  59481. 'Ƥ' => 'ƥ',
  59482. 'Ʀ' => 'ʀ',
  59483. 'Ƨ' => 'ƨ',
  59484. 'Ʃ' => 'ʃ',
  59485. 'Ƭ' => 'ƭ',
  59486. 'Ʈ' => 'ʈ',
  59487. 'Ư' => 'ư',
  59488. 'Ʊ' => 'ʊ',
  59489. 'Ʋ' => 'ʋ',
  59490. 'Ƴ' => 'ƴ',
  59491. 'Ƶ' => 'ƶ',
  59492. 'Æ·' => 'Ê’',
  59493. 'Ƹ' => 'ƹ',
  59494. 'Ƽ' => 'ƽ',
  59495. 'DŽ' => 'dž',
  59496. 'Dž' => 'dž',
  59497. 'LJ' => 'lj',
  59498. 'Lj' => 'lj',
  59499. 'NJ' => 'nj',
  59500. 'Nj' => 'nj',
  59501. '�' => 'ǎ',
  59502. '�' => '�',
  59503. 'Ç‘' => 'Ç’',
  59504. 'Ç“' => 'Ç”',
  59505. 'Ç•' => 'Ç–',
  59506. 'Ǘ' => 'ǘ',
  59507. 'Ç™' => 'Çš',
  59508. 'Ǜ' => 'ǜ',
  59509. 'Çž' => 'ÇŸ',
  59510. 'Ç ' => 'Ç¡',
  59511. 'Ç¢' => 'Ç£',
  59512. 'Ǥ' => 'ǥ',
  59513. 'Ǧ' => 'ǧ',
  59514. 'Ǩ' => 'ǩ',
  59515. 'Ǫ' => 'ǫ',
  59516. 'Ǭ' => 'ǭ',
  59517. 'Ǯ' => 'ǯ',
  59518. 'DZ' => 'dz',
  59519. 'Dz' => 'dz',
  59520. 'Ǵ' => 'ǵ',
  59521. 'Ƕ' => 'ƕ',
  59522. 'Ç·' => 'Æ¿',
  59523. 'Ǹ' => 'ǹ',
  59524. 'Ǻ' => 'ǻ',
  59525. 'Ǽ' => 'ǽ',
  59526. 'Ǿ' => 'ǿ',
  59527. 'Ȁ' => '�',
  59528. 'Ȃ' => 'ȃ',
  59529. 'È„' => 'È…',
  59530. 'Ȇ' => 'ȇ',
  59531. 'Ȉ' => 'ȉ',
  59532. 'ÈŠ' => 'È‹',
  59533. 'Ȍ' => '�',
  59534. 'Ȏ' => '�',
  59535. '�' => 'ȑ',
  59536. 'È’' => 'È“',
  59537. 'È”' => 'È•',
  59538. 'È–' => 'È—',
  59539. 'Ș' => 'ș',
  59540. 'Èš' => 'È›',
  59541. 'Ȝ' => '�',
  59542. 'Èž' => 'ÈŸ',
  59543. 'È ' => 'Æž',
  59544. 'È¢' => 'È£',
  59545. 'Ȥ' => 'ȥ',
  59546. 'Ȧ' => 'ȧ',
  59547. 'Ȩ' => 'ȩ',
  59548. 'Ȫ' => 'ȫ',
  59549. 'Ȭ' => 'ȭ',
  59550. 'Ȯ' => 'ȯ',
  59551. 'Ȱ' => 'ȱ',
  59552. 'Ȳ' => 'ȳ',
  59553. 'Ⱥ' => 'ⱥ',
  59554. 'Ȼ' => 'ȼ',
  59555. 'Ƚ' => 'ƚ',
  59556. 'Ⱦ' => 'ⱦ',
  59557. '�' => 'ɂ',
  59558. 'Ƀ' => 'ƀ',
  59559. 'Ʉ' => 'ʉ',
  59560. 'Ʌ' => 'ʌ',
  59561. 'Ɇ' => 'ɇ',
  59562. 'Ɉ' => 'ɉ',
  59563. 'ÉŠ' => 'É‹',
  59564. 'Ɍ' => '�',
  59565. 'Ɏ' => '�',
  59566. 'Ͱ' => 'ͱ',
  59567. 'Ͳ' => 'ͳ',
  59568. 'Ͷ' => 'ͷ',
  59569. 'Ϳ' => 'ϳ',
  59570. 'Ά' => 'ά',
  59571. 'Έ' => 'έ',
  59572. 'Ή' => 'ή',
  59573. 'Ί' => 'ί',
  59574. 'Ό' => 'ό',
  59575. 'Ύ' => '�',
  59576. '�' => 'ώ',
  59577. 'Α' => 'α',
  59578. 'Β' => 'β',
  59579. 'Γ' => 'γ',
  59580. 'Δ' => 'δ',
  59581. 'Ε' => 'ε',
  59582. 'Ζ' => 'ζ',
  59583. 'Η' => 'η',
  59584. 'Θ' => 'θ',
  59585. 'Ι' => 'ι',
  59586. 'Κ' => 'κ',
  59587. 'Λ' => 'λ',
  59588. 'Μ' => 'μ',
  59589. '�' => 'ν',
  59590. 'Ξ' => 'ξ',
  59591. 'Ο' => 'ο',
  59592. 'Π' => 'π',
  59593. 'Ρ' => '�',
  59594. 'Σ' => 'σ',
  59595. 'Τ' => 'τ',
  59596. 'Î¥' => 'Ï…',
  59597. 'Φ' => 'φ',
  59598. 'Χ' => 'χ',
  59599. 'Ψ' => 'ψ',
  59600. 'Ω' => 'ω',
  59601. 'Ϊ' => 'ϊ',
  59602. 'Ϋ' => 'ϋ',
  59603. '�' => 'ϗ',
  59604. 'Ϙ' => 'ϙ',
  59605. 'Ïš' => 'Ï›',
  59606. 'Ϝ' => '�',
  59607. 'Ïž' => 'ÏŸ',
  59608. 'Ï ' => 'Ï¡',
  59609. 'Ï¢' => 'Ï£',
  59610. 'Ϥ' => 'ϥ',
  59611. 'Ϧ' => 'ϧ',
  59612. 'Ϩ' => 'ϩ',
  59613. 'Ϫ' => 'ϫ',
  59614. 'Ϭ' => 'ϭ',
  59615. 'Ϯ' => 'ϯ',
  59616. 'ϴ' => 'θ',
  59617. 'Ϸ' => 'ϸ',
  59618. 'Ϲ' => 'ϲ',
  59619. 'Ϻ' => 'ϻ',
  59620. 'Ͻ' => 'ͻ',
  59621. 'Ͼ' => 'ͼ',
  59622. 'Ͽ' => 'ͽ',
  59623. 'Ѐ' => '�',
  59624. '�' => 'ё',
  59625. 'Ђ' => 'ђ',
  59626. 'Ѓ' => 'ѓ',
  59627. 'Є' => 'є',
  59628. 'Ð…' => 'Ñ•',
  59629. 'І' => 'і',
  59630. 'Ї' => 'ї',
  59631. 'Ј' => 'ј',
  59632. 'Љ' => 'љ',
  59633. 'Њ' => 'њ',
  59634. 'Ћ' => 'ћ',
  59635. 'Ќ' => 'ќ',
  59636. '�' => '�',
  59637. 'ÐŽ' => 'Ñž',
  59638. '�' => 'џ',
  59639. '�' => 'а',
  59640. 'Б' => 'б',
  59641. 'В' => 'в',
  59642. 'Г' => 'г',
  59643. 'Д' => 'д',
  59644. 'Е' => 'е',
  59645. 'Ж' => 'ж',
  59646. 'З' => 'з',
  59647. 'И' => 'и',
  59648. 'Й' => 'й',
  59649. 'К' => 'к',
  59650. 'Л' => 'л',
  59651. 'М' => 'м',
  59652. '�' => 'н',
  59653. 'О' => 'о',
  59654. 'П' => 'п',
  59655. 'Р' => 'р',
  59656. 'С' => '�',
  59657. 'Т' => 'т',
  59658. 'У' => 'у',
  59659. 'Ф' => 'ф',
  59660. 'Ð¥' => 'Ñ…',
  59661. 'Ц' => 'ц',
  59662. 'Ч' => 'ч',
  59663. 'Ш' => 'ш',
  59664. 'Щ' => 'щ',
  59665. 'Ъ' => 'ъ',
  59666. 'Ы' => 'ы',
  59667. 'Ь' => 'ь',
  59668. 'Э' => '�',
  59669. 'Ю' => 'ю',
  59670. 'Я' => '�',
  59671. 'Ñ ' => 'Ñ¡',
  59672. 'Ñ¢' => 'Ñ£',
  59673. 'Ѥ' => 'ѥ',
  59674. 'Ѧ' => 'ѧ',
  59675. 'Ѩ' => 'ѩ',
  59676. 'Ѫ' => 'ѫ',
  59677. 'Ѭ' => 'ѭ',
  59678. 'Ѯ' => 'ѯ',
  59679. 'Ѱ' => 'ѱ',
  59680. 'Ѳ' => 'ѳ',
  59681. 'Ѵ' => 'ѵ',
  59682. 'Ѷ' => 'ѷ',
  59683. 'Ѹ' => 'ѹ',
  59684. 'Ѻ' => 'ѻ',
  59685. 'Ѽ' => 'ѽ',
  59686. 'Ѿ' => 'ѿ',
  59687. 'Ò€' => 'Ò�',
  59688. 'ÒŠ' => 'Ò‹',
  59689. 'Ҍ' => '�',
  59690. 'ÒŽ' => 'Ò�',
  59691. 'Ò�' => 'Ò‘',
  59692. 'Ò’' => 'Ò“',
  59693. 'Ò”' => 'Ò•',
  59694. 'Ò–' => 'Ò—',
  59695. 'Ò˜' => 'Ò™',
  59696. 'Òš' => 'Ò›',
  59697. 'Ҝ' => '�',
  59698. 'Òž' => 'ÒŸ',
  59699. 'Ò ' => 'Ò¡',
  59700. 'Ò¢' => 'Ò£',
  59701. 'Ò¤' => 'Ò¥',
  59702. 'Ò¦' => 'Ò§',
  59703. 'Ò¨' => 'Ò©',
  59704. 'Òª' => 'Ò«',
  59705. 'Ò¬' => 'Ò­',
  59706. 'Ò®' => 'Ò¯',
  59707. 'Ò°' => 'Ò±',
  59708. 'Ò²' => 'Ò³',
  59709. 'Ò´' => 'Òµ',
  59710. 'Ò¶' => 'Ò·',
  59711. 'Ò¸' => 'Ò¹',
  59712. 'Òº' => 'Ò»',
  59713. 'Ò¼' => 'Ò½',
  59714. 'Ò¾' => 'Ò¿',
  59715. 'Ó€' => 'Ó�',
  59716. 'Ó�' => 'Ó‚',
  59717. 'Óƒ' => 'Ó„',
  59718. 'Ó…' => 'Ó†',
  59719. 'Ó‡' => 'Óˆ',
  59720. 'Ó‰' => 'ÓŠ',
  59721. 'Ӌ' => 'ӌ',
  59722. 'Ó�' => 'ÓŽ',
  59723. 'Ó�' => 'Ó‘',
  59724. 'Ó’' => 'Ó“',
  59725. 'Ó”' => 'Ó•',
  59726. 'Ó–' => 'Ó—',
  59727. 'Ó˜' => 'Ó™',
  59728. 'Óš' => 'Ó›',
  59729. 'Ӝ' => '�',
  59730. 'Óž' => 'ÓŸ',
  59731. 'Ó ' => 'Ó¡',
  59732. 'Ó¢' => 'Ó£',
  59733. 'Ó¤' => 'Ó¥',
  59734. 'Ó¦' => 'Ó§',
  59735. 'Ó¨' => 'Ó©',
  59736. 'Óª' => 'Ó«',
  59737. 'Ó¬' => 'Ó­',
  59738. 'Ó®' => 'Ó¯',
  59739. 'Ó°' => 'Ó±',
  59740. 'Ó²' => 'Ó³',
  59741. 'Ó´' => 'Óµ',
  59742. 'Ó¶' => 'Ó·',
  59743. 'Ó¸' => 'Ó¹',
  59744. 'Óº' => 'Ó»',
  59745. 'Ó¼' => 'Ó½',
  59746. 'Ó¾' => 'Ó¿',
  59747. 'Ô€' => 'Ô�',
  59748. 'Ô‚' => 'Ôƒ',
  59749. 'Ô„' => 'Ô…',
  59750. 'Ô†' => 'Ô‡',
  59751. 'Ôˆ' => 'Ô‰',
  59752. 'ÔŠ' => 'Ô‹',
  59753. 'Ԍ' => '�',
  59754. 'ÔŽ' => 'Ô�',
  59755. 'Ô�' => 'Ô‘',
  59756. 'Ô’' => 'Ô“',
  59757. 'Ô”' => 'Ô•',
  59758. 'Ô–' => 'Ô—',
  59759. 'Ô˜' => 'Ô™',
  59760. 'Ôš' => 'Ô›',
  59761. 'Ԝ' => '�',
  59762. 'Ôž' => 'ÔŸ',
  59763. 'Ô ' => 'Ô¡',
  59764. 'Ô¢' => 'Ô£',
  59765. 'Ô¤' => 'Ô¥',
  59766. 'Ô¦' => 'Ô§',
  59767. 'Ô¨' => 'Ô©',
  59768. 'Ôª' => 'Ô«',
  59769. 'Ô¬' => 'Ô­',
  59770. 'Ô®' => 'Ô¯',
  59771. 'Ô±' => 'Õ¡',
  59772. 'Ô²' => 'Õ¢',
  59773. 'Ô³' => 'Õ£',
  59774. 'Ô´' => 'Õ¤',
  59775. 'Ôµ' => 'Õ¥',
  59776. 'Ô¶' => 'Õ¦',
  59777. 'Ô·' => 'Õ§',
  59778. 'Ô¸' => 'Õ¨',
  59779. 'Ô¹' => 'Õ©',
  59780. 'Ôº' => 'Õª',
  59781. 'Ô»' => 'Õ«',
  59782. 'Ô¼' => 'Õ¬',
  59783. 'Ô½' => 'Õ­',
  59784. 'Ô¾' => 'Õ®',
  59785. 'Ô¿' => 'Õ¯',
  59786. 'Õ€' => 'Õ°',
  59787. 'Õ�' => 'Õ±',
  59788. 'Õ‚' => 'Õ²',
  59789. 'Õƒ' => 'Õ³',
  59790. 'Õ„' => 'Õ´',
  59791. 'Õ…' => 'Õµ',
  59792. 'Õ†' => 'Õ¶',
  59793. 'Õ‡' => 'Õ·',
  59794. 'Õˆ' => 'Õ¸',
  59795. 'Õ‰' => 'Õ¹',
  59796. 'ÕŠ' => 'Õº',
  59797. 'Õ‹' => 'Õ»',
  59798. 'Ռ' => 'ռ',
  59799. 'Õ�' => 'Õ½',
  59800. 'ÕŽ' => 'Õ¾',
  59801. 'Õ�' => 'Õ¿',
  59802. 'Õ�' => 'Ö€',
  59803. 'Õ‘' => 'Ö�',
  59804. 'Õ’' => 'Ö‚',
  59805. 'Õ“' => 'Öƒ',
  59806. 'Õ”' => 'Ö„',
  59807. 'Õ•' => 'Ö…',
  59808. 'Õ–' => 'Ö†',
  59809. 'á‚ ' => 'â´€',
  59810. 'á‚¡' => 'â´�',
  59811. 'á‚¢' => 'â´‚',
  59812. 'á‚£' => 'â´ƒ',
  59813. 'Ⴄ' => 'ⴄ',
  59814. 'á‚¥' => 'â´…',
  59815. 'Ⴆ' => 'ⴆ',
  59816. 'á‚§' => 'â´‡',
  59817. 'Ⴈ' => 'ⴈ',
  59818. 'á‚©' => 'â´‰',
  59819. 'Ⴊ' => 'ⴊ',
  59820. 'á‚«' => 'â´‹',
  59821. 'Ⴌ' => 'ⴌ',
  59822. 'á‚­' => 'â´�',
  59823. 'á‚®' => 'â´Ž',
  59824. 'Ⴏ' => '�',
  59825. 'á‚°' => 'â´�',
  59826. 'Ⴑ' => 'ⴑ',
  59827. 'Ⴒ' => 'ⴒ',
  59828. 'Ⴓ' => 'ⴓ',
  59829. 'á‚´' => 'â´”',
  59830. 'Ⴕ' => 'ⴕ',
  59831. 'á‚¶' => 'â´–',
  59832. 'á‚·' => 'â´—',
  59833. 'Ⴘ' => 'ⴘ',
  59834. 'Ⴙ' => 'ⴙ',
  59835. 'Ⴚ' => 'ⴚ',
  59836. 'á‚»' => 'â´›',
  59837. 'Ⴜ' => 'ⴜ',
  59838. 'Ⴝ' => '�',
  59839. 'Ⴞ' => 'ⴞ',
  59840. 'á‚¿' => 'â´Ÿ',
  59841. 'Ⴠ' => 'ⴠ',
  59842. '�' => 'ⴡ',
  59843. 'Ⴢ' => 'ⴢ',
  59844. 'Ⴣ' => 'ⴣ',
  59845. 'Ⴤ' => 'ⴤ',
  59846. 'Ⴥ' => 'ⴥ',
  59847. 'Ⴧ' => 'ⴧ',
  59848. '�' => 'ⴭ',
  59849. 'Ꭰ' => 'ꭰ',
  59850. 'Ꭱ' => 'ꭱ',
  59851. 'Ꭲ' => 'ꭲ',
  59852. 'Ꭳ' => 'ꭳ',
  59853. 'Ꭴ' => 'ꭴ',
  59854. 'Ꭵ' => 'ꭵ',
  59855. 'Ꭶ' => 'ꭶ',
  59856. 'Ꭷ' => 'ꭷ',
  59857. 'Ꭸ' => 'ꭸ',
  59858. 'Ꭹ' => 'ꭹ',
  59859. 'Ꭺ' => 'ꭺ',
  59860. 'Ꭻ' => 'ꭻ',
  59861. 'Ꭼ' => 'ꭼ',
  59862. 'Ꭽ' => 'ꭽ',
  59863. 'Ꭾ' => 'ꭾ',
  59864. 'Ꭿ' => 'ꭿ',
  59865. 'Ꮀ' => 'ꮀ',
  59866. 'Ꮁ' => '�',
  59867. 'Ꮂ' => 'ꮂ',
  59868. 'Ꮃ' => 'ꮃ',
  59869. 'Ꮄ' => 'ꮄ',
  59870. 'Ꮅ' => 'ꮅ',
  59871. 'Ꮆ' => 'ꮆ',
  59872. 'Ꮇ' => 'ꮇ',
  59873. 'Ꮈ' => 'ꮈ',
  59874. 'Ꮉ' => 'ꮉ',
  59875. 'Ꮊ' => 'ꮊ',
  59876. 'Ꮋ' => 'ꮋ',
  59877. 'Ꮌ' => 'ꮌ',
  59878. 'Ꮍ' => '�',
  59879. 'Ꮎ' => 'ꮎ',
  59880. 'Ꮏ' => '�',
  59881. '�' => '�',
  59882. '�' => 'ꮑ',
  59883. '�' => 'ꮒ',
  59884. '�' => 'ꮓ',
  59885. '�' => 'ꮔ',
  59886. '�' => 'ꮕ',
  59887. '�' => 'ꮖ',
  59888. '�' => 'ꮗ',
  59889. '�' => 'ꮘ',
  59890. '�' => 'ꮙ',
  59891. '�' => 'ꮚ',
  59892. '�' => 'ꮛ',
  59893. '�' => 'ꮜ',
  59894. '�' => '�',
  59895. '�' => 'ꮞ',
  59896. '�' => 'ꮟ',
  59897. '�' => 'ꮠ',
  59898. '�' => 'ꮡ',
  59899. '�' => 'ꮢ',
  59900. '�' => 'ꮣ',
  59901. '�' => 'ꮤ',
  59902. '�' => 'ꮥ',
  59903. '�' => 'ꮦ',
  59904. '�' => 'ꮧ',
  59905. '�' => 'ꮨ',
  59906. '�' => 'ꮩ',
  59907. '�' => 'ꮪ',
  59908. '�' => 'ꮫ',
  59909. '�' => 'ꮬ',
  59910. '�' => 'ꮭ',
  59911. '�' => 'ꮮ',
  59912. '�' => 'ꮯ',
  59913. '�' => 'ꮰ',
  59914. '�' => 'ꮱ',
  59915. '�' => 'ꮲ',
  59916. '�' => 'ꮳ',
  59917. '�' => 'ꮴ',
  59918. '�' => 'ꮵ',
  59919. '�' => 'ꮶ',
  59920. '�' => 'ꮷ',
  59921. '�' => 'ꮸ',
  59922. '�' => 'ꮹ',
  59923. '�' => 'ꮺ',
  59924. '�' => 'ꮻ',
  59925. '�' => 'ꮼ',
  59926. '�' => 'ꮽ',
  59927. '�' => 'ꮾ',
  59928. '�' => 'ꮿ',
  59929. '�' => '�',
  59930. '�' => '�',
  59931. '�' => '�',
  59932. '�' => '�',
  59933. '�' => '�',
  59934. '�' => '�',
  59935. '�' => '�',
  59936. 'Ბ' => 'ბ',
  59937. 'Გ' => 'გ',
  59938. 'Დ' => 'დ',
  59939. 'Ე' => 'ე',
  59940. 'Ვ' => 'ვ',
  59941. 'Ზ' => 'ზ',
  59942. 'Თ' => 'თ',
  59943. 'Ი' => 'ი',
  59944. 'Კ' => 'კ',
  59945. 'Ლ' => 'ლ',
  59946. 'Მ' => 'მ',
  59947. 'Ნ' => 'ნ',
  59948. '�' => '�',
  59949. 'Პ' => 'პ',
  59950. 'Ჟ' => 'ჟ',
  59951. 'Რ' => 'რ',
  59952. 'Ს' => 'ს',
  59953. 'Ტ' => 'ტ',
  59954. 'Უ' => 'უ',
  59955. 'Ფ' => 'ფ',
  59956. 'Ქ' => 'ქ',
  59957. 'Ღ' => 'ღ',
  59958. 'Ყ' => 'ყ',
  59959. 'Შ' => 'შ',
  59960. 'Ჩ' => 'ჩ',
  59961. 'Ც' => 'ც',
  59962. 'Ძ' => 'ძ',
  59963. 'Წ' => 'წ',
  59964. 'Ჭ' => 'ჭ',
  59965. 'Ხ' => 'ხ',
  59966. 'Ჯ' => 'ჯ',
  59967. 'Ჰ' => 'ჰ',
  59968. 'Ჱ' => 'ჱ',
  59969. 'Ჲ' => 'ჲ',
  59970. 'Ჳ' => 'ჳ',
  59971. 'Ჴ' => 'ჴ',
  59972. 'Ჵ' => 'ჵ',
  59973. 'Ჶ' => 'ჶ',
  59974. 'Ჷ' => 'ჷ',
  59975. 'Ჸ' => 'ჸ',
  59976. 'Ჹ' => 'ჹ',
  59977. 'Ჺ' => 'ჺ',
  59978. 'Ჽ' => 'ჽ',
  59979. 'Ჾ' => 'ჾ',
  59980. 'Ჿ' => 'ჿ',
  59981. 'Ḁ' => '�',
  59982. 'Ḃ' => 'ḃ',
  59983. 'Ḅ' => 'ḅ',
  59984. 'Ḇ' => 'ḇ',
  59985. 'Ḉ' => 'ḉ',
  59986. 'Ḋ' => 'ḋ',
  59987. 'Ḍ' => '�',
  59988. 'Ḏ' => '�',
  59989. '�' => 'ḑ',
  59990. 'Ḓ' => 'ḓ',
  59991. 'Ḕ' => 'ḕ',
  59992. 'Ḗ' => 'ḗ',
  59993. 'Ḙ' => 'ḙ',
  59994. 'Ḛ' => 'ḛ',
  59995. 'Ḝ' => '�',
  59996. 'Ḟ' => 'ḟ',
  59997. 'Ḡ' => 'ḡ',
  59998. 'Ḣ' => 'ḣ',
  59999. 'Ḥ' => 'ḥ',
  60000. 'Ḧ' => 'ḧ',
  60001. 'Ḩ' => 'ḩ',
  60002. 'Ḫ' => 'ḫ',
  60003. 'Ḭ' => 'ḭ',
  60004. 'Ḯ' => 'ḯ',
  60005. 'Ḱ' => 'ḱ',
  60006. 'Ḳ' => 'ḳ',
  60007. 'Ḵ' => 'ḵ',
  60008. 'Ḷ' => 'ḷ',
  60009. 'Ḹ' => 'ḹ',
  60010. 'Ḻ' => 'ḻ',
  60011. 'Ḽ' => 'ḽ',
  60012. 'Ḿ' => 'ḿ',
  60013. 'Ṁ' => '�',
  60014. 'Ṃ' => 'ṃ',
  60015. 'Ṅ' => 'ṅ',
  60016. 'Ṇ' => 'ṇ',
  60017. 'Ṉ' => 'ṉ',
  60018. 'Ṋ' => 'ṋ',
  60019. 'Ṍ' => '�',
  60020. 'Ṏ' => '�',
  60021. '�' => 'ṑ',
  60022. 'Ṓ' => 'ṓ',
  60023. 'Ṕ' => 'ṕ',
  60024. 'á¹–' => 'á¹—',
  60025. 'Ṙ' => 'ṙ',
  60026. 'Ṛ' => 'ṛ',
  60027. 'Ṝ' => '�',
  60028. 'Ṟ' => 'ṟ',
  60029. 'Ṡ' => 'ṡ',
  60030. 'á¹¢' => 'á¹£',
  60031. 'Ṥ' => 'ṥ',
  60032. 'Ṧ' => 'ṧ',
  60033. 'Ṩ' => 'ṩ',
  60034. 'Ṫ' => 'ṫ',
  60035. 'Ṭ' => 'ṭ',
  60036. 'Ṯ' => 'ṯ',
  60037. 'á¹°' => 'á¹±',
  60038. 'á¹²' => 'á¹³',
  60039. 'á¹´' => 'á¹µ',
  60040. 'á¹¶' => 'á¹·',
  60041. 'Ṹ' => 'ṹ',
  60042. 'Ṻ' => 'ṻ',
  60043. 'á¹¼' => 'á¹½',
  60044. 'Ṿ' => 'ṿ',
  60045. 'Ẁ' => '�',
  60046. 'Ẃ' => 'ẃ',
  60047. 'Ẅ' => 'ẅ',
  60048. 'Ẇ' => 'ẇ',
  60049. 'Ẉ' => 'ẉ',
  60050. 'Ẋ' => 'ẋ',
  60051. 'Ẍ' => '�',
  60052. 'Ẏ' => '�',
  60053. '�' => 'ẑ',
  60054. 'Ẓ' => 'ẓ',
  60055. 'Ẕ' => 'ẕ',
  60056. 'ẞ' => 'ß',
  60057. 'Ạ' => 'ạ',
  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. 'Ἒ' => 'ἒ',
  60116. 'Ἓ' => 'ἓ',
  60117. 'Ἔ' => 'ἔ',
  60118. '�' => 'ἕ',
  60119. 'Ἠ' => 'ἠ',
  60120. 'Ἡ' => 'ἡ',
  60121. 'Ἢ' => 'ἢ',
  60122. 'Ἣ' => 'ἣ',
  60123. 'Ἤ' => 'ἤ',
  60124. 'á¼­' => 'á¼¥',
  60125. 'Ἦ' => 'ἦ',
  60126. 'Ἧ' => 'ἧ',
  60127. 'Ἰ' => 'ἰ',
  60128. 'á¼¹' => 'á¼±',
  60129. 'Ἲ' => 'ἲ',
  60130. 'á¼»' => 'á¼³',
  60131. 'á¼¼' => 'á¼´',
  60132. 'á¼½' => 'á¼µ',
  60133. 'á¼¾' => 'á¼¶',
  60134. 'Ἷ' => 'ἷ',
  60135. 'Ὀ' => 'ὀ',
  60136. 'Ὁ' => '�',
  60137. 'Ὂ' => 'ὂ',
  60138. 'Ὃ' => 'ὃ',
  60139. 'Ὄ' => 'ὄ',
  60140. '�' => 'ὅ',
  60141. 'Ὑ' => 'ὑ',
  60142. 'Ὓ' => 'ὓ',
  60143. '�' => 'ὕ',
  60144. 'Ὗ' => 'ὗ',
  60145. 'Ὠ' => 'ὠ',
  60146. 'Ὡ' => 'ὡ',
  60147. 'Ὢ' => 'ὢ',
  60148. 'Ὣ' => 'ὣ',
  60149. 'Ὤ' => 'ὤ',
  60150. 'á½­' => 'á½¥',
  60151. 'Ὦ' => 'ὦ',
  60152. 'Ὧ' => 'ὧ',
  60153. 'ᾈ' => 'ᾀ',
  60154. 'ᾉ' => '�',
  60155. 'ᾊ' => 'ᾂ',
  60156. 'ᾋ' => 'ᾃ',
  60157. 'ᾌ' => 'ᾄ',
  60158. '�' => 'ᾅ',
  60159. 'ᾎ' => 'ᾆ',
  60160. '�' => 'ᾇ',
  60161. 'ᾘ' => '�',
  60162. 'ᾙ' => 'ᾑ',
  60163. 'ᾚ' => 'ᾒ',
  60164. 'ᾛ' => 'ᾓ',
  60165. 'ᾜ' => 'ᾔ',
  60166. '�' => 'ᾕ',
  60167. 'ᾞ' => 'ᾖ',
  60168. 'ᾟ' => 'ᾗ',
  60169. 'ᾨ' => 'ᾠ',
  60170. 'ᾩ' => 'ᾡ',
  60171. 'ᾪ' => 'ᾢ',
  60172. 'ᾫ' => 'ᾣ',
  60173. 'ᾬ' => 'ᾤ',
  60174. 'á¾­' => 'á¾¥',
  60175. 'ᾮ' => 'ᾦ',
  60176. 'ᾯ' => 'ᾧ',
  60177. 'Ᾰ' => 'ᾰ',
  60178. 'á¾¹' => 'á¾±',
  60179. 'Ὰ' => 'ὰ',
  60180. 'á¾»' => 'á½±',
  60181. 'á¾¼' => 'á¾³',
  60182. 'Ὲ' => 'ὲ',
  60183. 'Έ' => 'έ',
  60184. 'Ὴ' => 'ὴ',
  60185. 'á¿‹' => 'á½µ',
  60186. 'ῌ' => 'ῃ',
  60187. 'Ῐ' => '�',
  60188. 'á¿™' => 'á¿‘',
  60189. 'Ὶ' => 'ὶ',
  60190. 'á¿›' => 'á½·',
  60191. 'Ῠ' => 'ῠ',
  60192. 'á¿©' => 'á¿¡',
  60193. 'Ὺ' => 'ὺ',
  60194. 'á¿«' => 'á½»',
  60195. 'Ῥ' => 'ῥ',
  60196. 'Ὸ' => 'ὸ',
  60197. 'Ό' => 'ό',
  60198. 'Ὼ' => 'ὼ',
  60199. 'á¿»' => 'á½½',
  60200. 'ῼ' => 'ῳ',
  60201. 'Ω' => 'ω',
  60202. 'K' => 'k',
  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. 'A' => '�',
  60483. 'B' => 'b',
  60484. 'C' => 'c',
  60485. 'D' => 'd',
  60486. 'ï¼¥' => 'ï½…',
  60487. 'F' => 'f',
  60488. 'G' => 'g',
  60489. 'H' => 'h',
  60490. 'I' => 'i',
  60491. 'J' => 'j',
  60492. 'K' => 'k',
  60493. 'L' => 'l',
  60494. 'M' => '�',
  60495. 'N' => 'n',
  60496. 'O' => '�',
  60497. 'P' => '�',
  60498. 'Q' => 'q',
  60499. 'ï¼²' => 'ï½’',
  60500. 'S' => 's',
  60501. 'ï¼´' => 'ï½”',
  60502. 'U' => 'u',
  60503. 'ï¼¶' => 'ï½–',
  60504. 'ï¼·' => 'ï½—',
  60505. 'X' => 'x',
  60506. 'ï¼¹' => 'ï½™',
  60507. 'Z' => 'z',
  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. <?php
  60735. 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';
  60736. <?php
  60737. return array (
  60738. 'a' => 'A',
  60739. 'b' => 'B',
  60740. 'c' => 'C',
  60741. 'd' => 'D',
  60742. 'e' => 'E',
  60743. 'f' => 'F',
  60744. 'g' => 'G',
  60745. 'h' => 'H',
  60746. 'i' => 'I',
  60747. 'j' => 'J',
  60748. 'k' => 'K',
  60749. 'l' => 'L',
  60750. 'm' => 'M',
  60751. 'n' => 'N',
  60752. 'o' => 'O',
  60753. 'p' => 'P',
  60754. 'q' => 'Q',
  60755. 'r' => 'R',
  60756. 's' => 'S',
  60757. 't' => 'T',
  60758. 'u' => 'U',
  60759. 'v' => 'V',
  60760. 'w' => 'W',
  60761. 'x' => 'X',
  60762. 'y' => 'Y',
  60763. 'z' => 'Z',
  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. 'ı' => 'I',
  60821. 'ij' => 'IJ',
  60822. 'ĵ' => 'Ĵ',
  60823. 'ķ' => 'Ķ',
  60824. 'ĺ' => 'Ĺ',
  60825. 'ļ' => 'Ļ',
  60826. 'ľ' => 'Ľ',
  60827. 'Å€' => 'Ä¿',
  60828. 'ł' => '�',
  60829. 'ń' => 'Ń',
  60830. 'ņ' => 'Ņ',
  60831. 'ň' => 'Ň',
  60832. 'Å‹' => 'ÅŠ',
  60833. '�' => 'Ō',
  60834. '�' => 'Ŏ',
  60835. 'ő' => '�',
  60836. 'Å“' => 'Å’',
  60837. 'Å•' => 'Å”',
  60838. 'Å—' => 'Å–',
  60839. 'ř' => 'Ř',
  60840. 'Å›' => 'Åš',
  60841. '�' => 'Ŝ',
  60842. 'ÅŸ' => 'Åž',
  60843. 'Å¡' => 'Å ',
  60844. 'Å£' => 'Å¢',
  60845. 'ť' => 'Ť',
  60846. 'ŧ' => 'Ŧ',
  60847. 'ũ' => 'Ũ',
  60848. 'ū' => 'Ū',
  60849. 'ŭ' => 'Ŭ',
  60850. 'ů' => 'Ů',
  60851. 'ű' => 'Ű',
  60852. 'ų' => 'Ų',
  60853. 'ŵ' => 'Ŵ',
  60854. 'ŷ' => 'Ŷ',
  60855. 'ź' => 'Ź',
  60856. 'ż' => 'Ż',
  60857. 'ž' => 'Ž',
  60858. 'Å¿' => 'S',
  60859. 'ƀ' => 'Ƀ',
  60860. 'ƃ' => 'Ƃ',
  60861. 'Æ…' => 'Æ„',
  60862. 'ƈ' => 'Ƈ',
  60863. 'ƌ' => 'Ƌ',
  60864. 'Æ’' => 'Æ‘',
  60865. 'ƕ' => 'Ƕ',
  60866. 'ƙ' => 'Ƙ',
  60867. 'ƚ' => 'Ƚ',
  60868. 'Æž' => 'È ',
  60869. 'Æ¡' => 'Æ ',
  60870. 'Æ£' => 'Æ¢',
  60871. 'ƥ' => 'Ƥ',
  60872. 'ƨ' => 'Ƨ',
  60873. 'ƭ' => 'Ƭ',
  60874. 'ư' => 'Ư',
  60875. 'ƴ' => 'Ƴ',
  60876. 'ƶ' => 'Ƶ',
  60877. 'ƹ' => 'Ƹ',
  60878. 'ƽ' => 'Ƽ',
  60879. 'Æ¿' => 'Ç·',
  60880. 'Ç…' => 'Ç„',
  60881. 'dž' => 'DŽ',
  60882. 'Lj' => 'LJ',
  60883. 'lj' => 'LJ',
  60884. 'Ç‹' => 'ÇŠ',
  60885. 'nj' => 'NJ',
  60886. 'ǎ' => '�',
  60887. '�' => '�',
  60888. 'Ç’' => 'Ç‘',
  60889. 'Ç”' => 'Ç“',
  60890. 'Ç–' => 'Ç•',
  60891. 'ǘ' => 'Ǘ',
  60892. 'Çš' => 'Ç™',
  60893. 'ǜ' => 'Ǜ',
  60894. '�' => 'Ǝ',
  60895. 'ÇŸ' => 'Çž',
  60896. 'Ç¡' => 'Ç ',
  60897. 'Ç£' => 'Ç¢',
  60898. 'ǥ' => 'Ǥ',
  60899. 'ǧ' => 'Ǧ',
  60900. 'ǩ' => 'Ǩ',
  60901. 'ǫ' => 'Ǫ',
  60902. 'ǭ' => 'Ǭ',
  60903. 'ǯ' => 'Ǯ',
  60904. 'Dz' => 'DZ',
  60905. 'dz' => 'DZ',
  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. 'ѯ' => 'Ѯ',
  61103. 'ѱ' => 'Ѱ',
  61104. 'ѳ' => 'Ѳ',
  61105. 'ѵ' => 'Ѵ',
  61106. 'ѷ' => 'Ѷ',
  61107. 'ѹ' => 'Ѹ',
  61108. 'ѻ' => 'Ѻ',
  61109. 'ѽ' => 'Ѽ',
  61110. 'ѿ' => 'Ѿ',
  61111. 'Ò�' => 'Ò€',
  61112. 'Ò‹' => 'ÒŠ',
  61113. '�' => 'Ҍ',
  61114. 'Ò�' => 'ÒŽ',
  61115. 'Ò‘' => 'Ò�',
  61116. 'Ò“' => 'Ò’',
  61117. 'Ò•' => 'Ò”',
  61118. 'Ò—' => 'Ò–',
  61119. 'Ò™' => 'Ò˜',
  61120. 'Ò›' => 'Òš',
  61121. '�' => 'Ҝ',
  61122. 'ÒŸ' => 'Òž',
  61123. 'Ò¡' => 'Ò ',
  61124. 'Ò£' => 'Ò¢',
  61125. 'Ò¥' => 'Ò¤',
  61126. 'Ò§' => 'Ò¦',
  61127. 'Ò©' => 'Ò¨',
  61128. 'Ò«' => 'Òª',
  61129. 'Ò­' => 'Ò¬',
  61130. 'Ò¯' => 'Ò®',
  61131. 'Ò±' => 'Ò°',
  61132. 'Ò³' => 'Ò²',
  61133. 'Òµ' => 'Ò´',
  61134. 'Ò·' => 'Ò¶',
  61135. 'Ò¹' => 'Ò¸',
  61136. 'Ò»' => 'Òº',
  61137. 'Ò½' => 'Ò¼',
  61138. 'Ò¿' => 'Ò¾',
  61139. 'Ó‚' => 'Ó�',
  61140. 'Ó„' => 'Óƒ',
  61141. 'Ó†' => 'Ó…',
  61142. 'Óˆ' => 'Ó‡',
  61143. 'ÓŠ' => 'Ó‰',
  61144. 'ӌ' => 'Ӌ',
  61145. 'ÓŽ' => 'Ó�',
  61146. 'Ó�' => 'Ó€',
  61147. 'Ó‘' => 'Ó�',
  61148. 'Ó“' => 'Ó’',
  61149. 'Ó•' => 'Ó”',
  61150. 'Ó—' => 'Ó–',
  61151. 'Ó™' => 'Ó˜',
  61152. 'Ó›' => 'Óš',
  61153. '�' => 'Ӝ',
  61154. 'ÓŸ' => 'Óž',
  61155. 'Ó¡' => 'Ó ',
  61156. 'Ó£' => 'Ó¢',
  61157. 'Ó¥' => 'Ó¤',
  61158. 'Ó§' => 'Ó¦',
  61159. 'Ó©' => 'Ó¨',
  61160. 'Ó«' => 'Óª',
  61161. 'Ó­' => 'Ó¬',
  61162. 'Ó¯' => 'Ó®',
  61163. 'Ó±' => 'Ó°',
  61164. 'Ó³' => 'Ó²',
  61165. 'Óµ' => 'Ó´',
  61166. 'Ó·' => 'Ó¶',
  61167. 'Ó¹' => 'Ó¸',
  61168. 'Ó»' => 'Óº',
  61169. 'Ó½' => 'Ó¼',
  61170. 'Ó¿' => 'Ó¾',
  61171. 'Ô�' => 'Ô€',
  61172. 'Ôƒ' => 'Ô‚',
  61173. 'Ô…' => 'Ô„',
  61174. 'Ô‡' => 'Ô†',
  61175. 'Ô‰' => 'Ôˆ',
  61176. 'Ô‹' => 'ÔŠ',
  61177. '�' => 'Ԍ',
  61178. 'Ô�' => 'ÔŽ',
  61179. 'Ô‘' => 'Ô�',
  61180. 'Ô“' => 'Ô’',
  61181. 'Ô•' => 'Ô”',
  61182. 'Ô—' => 'Ô–',
  61183. 'Ô™' => 'Ô˜',
  61184. 'Ô›' => 'Ôš',
  61185. '�' => 'Ԝ',
  61186. 'ÔŸ' => 'Ôž',
  61187. 'Ô¡' => 'Ô ',
  61188. 'Ô£' => 'Ô¢',
  61189. 'Ô¥' => 'Ô¤',
  61190. 'Ô§' => 'Ô¦',
  61191. 'Ô©' => 'Ô¨',
  61192. 'Ô«' => 'Ôª',
  61193. 'Ô­' => 'Ô¬',
  61194. 'Ô¯' => 'Ô®',
  61195. 'Õ¡' => 'Ô±',
  61196. 'Õ¢' => 'Ô²',
  61197. 'Õ£' => 'Ô³',
  61198. 'Õ¤' => 'Ô´',
  61199. 'Õ¥' => 'Ôµ',
  61200. 'Õ¦' => 'Ô¶',
  61201. 'Õ§' => 'Ô·',
  61202. 'Õ¨' => 'Ô¸',
  61203. 'Õ©' => 'Ô¹',
  61204. 'Õª' => 'Ôº',
  61205. 'Õ«' => 'Ô»',
  61206. 'Õ¬' => 'Ô¼',
  61207. 'Õ­' => 'Ô½',
  61208. 'Õ®' => 'Ô¾',
  61209. 'Õ¯' => 'Ô¿',
  61210. 'Õ°' => 'Õ€',
  61211. 'Õ±' => 'Õ�',
  61212. 'Õ²' => 'Õ‚',
  61213. 'Õ³' => 'Õƒ',
  61214. 'Õ´' => 'Õ„',
  61215. 'Õµ' => 'Õ…',
  61216. 'Õ¶' => 'Õ†',
  61217. 'Õ·' => 'Õ‡',
  61218. 'Õ¸' => 'Õˆ',
  61219. 'Õ¹' => 'Õ‰',
  61220. 'Õº' => 'ÕŠ',
  61221. 'Õ»' => 'Õ‹',
  61222. 'ռ' => 'Ռ',
  61223. 'Õ½' => 'Õ�',
  61224. 'Õ¾' => 'ÕŽ',
  61225. 'Õ¿' => 'Õ�',
  61226. 'Ö€' => 'Õ�',
  61227. 'Ö�' => 'Õ‘',
  61228. 'Ö‚' => 'Õ’',
  61229. 'Öƒ' => 'Õ“',
  61230. 'Ö„' => 'Õ”',
  61231. 'Ö…' => 'Õ•',
  61232. 'Ö†' => 'Õ–',
  61233. '�' => '�',
  61234. 'ბ' => 'Ბ',
  61235. 'გ' => 'Გ',
  61236. 'დ' => 'Დ',
  61237. 'ე' => 'Ე',
  61238. 'ვ' => 'Ვ',
  61239. 'ზ' => 'Ზ',
  61240. 'თ' => 'Თ',
  61241. 'ი' => 'Ი',
  61242. 'კ' => 'Კ',
  61243. 'ლ' => 'Ლ',
  61244. 'მ' => 'Მ',
  61245. 'ნ' => 'Ნ',
  61246. '�' => '�',
  61247. 'პ' => 'Პ',
  61248. 'ჟ' => 'Ჟ',
  61249. 'რ' => 'Რ',
  61250. 'ს' => 'Ს',
  61251. 'ტ' => 'Ტ',
  61252. 'უ' => 'Უ',
  61253. 'ფ' => 'Ფ',
  61254. 'ქ' => 'Ქ',
  61255. 'ღ' => 'Ღ',
  61256. 'ყ' => 'Ყ',
  61257. 'შ' => 'Შ',
  61258. 'ჩ' => 'Ჩ',
  61259. 'ც' => 'Ც',
  61260. 'ძ' => 'Ძ',
  61261. 'წ' => 'Წ',
  61262. 'ჭ' => 'Ჭ',
  61263. 'ხ' => 'Ხ',
  61264. 'ჯ' => 'Ჯ',
  61265. 'ჰ' => 'Ჰ',
  61266. 'ჱ' => 'Ჱ',
  61267. 'ჲ' => 'Ჲ',
  61268. 'ჳ' => 'Ჳ',
  61269. 'ჴ' => 'Ჴ',
  61270. 'ჵ' => 'Ჵ',
  61271. 'ჶ' => 'Ჶ',
  61272. 'ჷ' => 'Ჷ',
  61273. 'ჸ' => 'Ჸ',
  61274. 'ჹ' => 'Ჹ',
  61275. 'ჺ' => 'Ჺ',
  61276. 'ჽ' => 'Ჽ',
  61277. 'ჾ' => 'Ჾ',
  61278. 'ჿ' => 'Ჿ',
  61279. '�' => '�',
  61280. '�' => '�',
  61281. '�' => '�',
  61282. '�' => '�',
  61283. '�' => '�',
  61284. '�' => '�',
  61285. 'á²€' => 'Ð’',
  61286. '�' => 'Д',
  61287. 'ᲂ' => 'О',
  61288. 'ᲃ' => 'С',
  61289. 'ᲄ' => 'Т',
  61290. 'ᲅ' => 'Т',
  61291. 'ᲆ' => 'Ъ',
  61292. 'ᲇ' => 'Ѣ',
  61293. 'ᲈ' => 'Ꙋ',
  61294. 'ᵹ' => '�',
  61295. 'áµ½' => 'â±£',
  61296. 'ᶎ' => 'Ᶎ',
  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. 'á¹³' => 'á¹²',
  61355. 'á¹µ' => 'á¹´',
  61356. 'á¹·' => 'á¹¶',
  61357. 'ṹ' => 'Ṹ',
  61358. 'ṻ' => 'Ṻ',
  61359. 'á¹½' => 'á¹¼',
  61360. 'ṿ' => 'Ṿ',
  61361. '�' => 'Ẁ',
  61362. 'ẃ' => 'Ẃ',
  61363. 'ẅ' => 'Ẅ',
  61364. 'ẇ' => 'Ẇ',
  61365. 'ẉ' => 'Ẉ',
  61366. 'ẋ' => 'Ẋ',
  61367. '�' => 'Ẍ',
  61368. '�' => 'Ẏ',
  61369. 'ẑ' => '�',
  61370. 'ẓ' => 'Ẓ',
  61371. 'ẕ' => 'Ẕ',
  61372. 'ẛ' => 'Ṡ',
  61373. 'ạ' => 'Ạ',
  61374. 'ả' => 'Ả',
  61375. 'ấ' => 'Ấ',
  61376. 'ầ' => 'Ầ',
  61377. 'ẩ' => 'Ẩ',
  61378. 'ẫ' => 'Ẫ',
  61379. 'ậ' => 'Ậ',
  61380. 'ắ' => 'Ắ',
  61381. 'ằ' => 'Ằ',
  61382. 'ẳ' => 'Ẳ',
  61383. 'ẵ' => 'Ẵ',
  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. 'á¼¥' => 'á¼­',
  61441. 'ἦ' => 'Ἦ',
  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. 'ό' => 'Ό',
  61479. 'ὺ' => 'Ὺ',
  61480. 'á½»' => 'á¿«',
  61481. 'ὼ' => 'Ὼ',
  61482. 'á½½' => 'á¿»',
  61483. 'ᾀ' => 'ᾈ',
  61484. '�' => 'ᾉ',
  61485. 'ᾂ' => 'ᾊ',
  61486. 'ᾃ' => 'ᾋ',
  61487. 'ᾄ' => 'ᾌ',
  61488. 'ᾅ' => '�',
  61489. 'ᾆ' => 'ᾎ',
  61490. 'ᾇ' => '�',
  61491. '�' => 'ᾘ',
  61492. 'ᾑ' => 'ᾙ',
  61493. 'ᾒ' => 'ᾚ',
  61494. 'ᾓ' => 'ᾛ',
  61495. 'ᾔ' => 'ᾜ',
  61496. 'ᾕ' => '�',
  61497. 'ᾖ' => 'ᾞ',
  61498. 'ᾗ' => 'ᾟ',
  61499. 'ᾠ' => 'ᾨ',
  61500. 'ᾡ' => 'ᾩ',
  61501. 'ᾢ' => 'ᾪ',
  61502. 'ᾣ' => 'ᾫ',
  61503. 'ᾤ' => 'ᾬ',
  61504. 'á¾¥' => 'á¾­',
  61505. 'ᾦ' => 'ᾮ',
  61506. 'ᾧ' => 'ᾯ',
  61507. 'ᾰ' => 'Ᾰ',
  61508. 'á¾±' => 'á¾¹',
  61509. 'á¾³' => 'á¾¼',
  61510. 'ι' => 'Ι',
  61511. 'ῃ' => 'ῌ',
  61512. '�' => 'Ῐ',
  61513. 'á¿‘' => 'á¿™',
  61514. 'ῠ' => 'Ῠ',
  61515. 'á¿¡' => 'á¿©',
  61516. 'ῥ' => 'Ῥ',
  61517. 'ῳ' => 'ῼ',
  61518. 'ⅎ' => 'Ⅎ',
  61519. 'â…°' => 'â… ',
  61520. 'â…±' => 'â…¡',
  61521. 'â…²' => 'â…¢',
  61522. 'â…³' => 'â…£',
  61523. 'â…´' => 'â…¤',
  61524. 'â…µ' => 'â…¥',
  61525. 'â…¶' => 'â…¦',
  61526. 'â…·' => 'â…§',
  61527. 'â…¸' => 'â…¨',
  61528. 'â…¹' => 'â…©',
  61529. 'â…º' => 'â…ª',
  61530. 'â…»' => 'â…«',
  61531. 'â…¼' => 'â…¬',
  61532. 'â…½' => 'â…­',
  61533. 'â…¾' => 'â…®',
  61534. 'â…¿' => 'â…¯',
  61535. 'ↄ' => 'Ↄ',
  61536. '�' => 'Ⓐ',
  61537. 'â“‘' => 'â’·',
  61538. 'â“’' => 'â’¸',
  61539. 'â““' => 'â’¹',
  61540. 'â“”' => 'â’º',
  61541. 'â“•' => 'â’»',
  61542. 'â“–' => 'â’¼',
  61543. 'â“—' => 'â’½',
  61544. 'ⓘ' => 'Ⓘ',
  61545. 'â“™' => 'â’¿',
  61546. 'ⓚ' => 'Ⓚ',
  61547. 'ⓛ' => '�',
  61548. 'ⓜ' => 'Ⓜ',
  61549. '�' => 'Ⓝ',
  61550. 'ⓞ' => 'Ⓞ',
  61551. 'ⓟ' => 'Ⓟ',
  61552. 'ⓠ' => 'Ⓠ',
  61553. 'ⓡ' => 'Ⓡ',
  61554. 'ⓢ' => 'Ⓢ',
  61555. 'ⓣ' => 'Ⓣ',
  61556. 'ⓤ' => 'Ⓤ',
  61557. 'â“¥' => 'â“‹',
  61558. 'ⓦ' => 'Ⓦ',
  61559. 'ⓧ' => '�',
  61560. 'ⓨ' => 'Ⓨ',
  61561. 'ⓩ' => '�',
  61562. 'â°°' => 'â°€',
  61563. 'â°±' => 'â°�',
  61564. 'â°²' => 'â°‚',
  61565. 'â°³' => 'â°ƒ',
  61566. 'â°´' => 'â°„',
  61567. 'â°µ' => 'â°…',
  61568. 'â°¶' => 'â°†',
  61569. 'â°·' => 'â°‡',
  61570. 'â°¸' => 'â°ˆ',
  61571. 'â°¹' => 'â°‰',
  61572. 'â°º' => 'â°Š',
  61573. 'â°»' => 'â°‹',
  61574. 'ⰼ' => 'Ⰼ',
  61575. 'â°½' => 'â°�',
  61576. 'â°¾' => 'â°Ž',
  61577. 'â°¿' => 'â°�',
  61578. 'â±€' => 'â°�',
  61579. '�' => 'Ⱁ',
  61580. 'ⱂ' => 'Ⱂ',
  61581. 'ⱃ' => 'Ⱃ',
  61582. 'ⱄ' => 'Ⱄ',
  61583. 'â±…' => 'â°•',
  61584. 'ⱆ' => 'Ⱆ',
  61585. 'ⱇ' => 'Ⱇ',
  61586. 'ⱈ' => 'Ⱈ',
  61587. 'ⱉ' => 'Ⱉ',
  61588. 'ⱊ' => 'Ⱊ',
  61589. 'ⱋ' => 'Ⱋ',
  61590. 'ⱌ' => 'Ⱌ',
  61591. '�' => '�',
  61592. 'ⱎ' => 'Ⱎ',
  61593. '�' => 'Ⱏ',
  61594. '�' => 'Ⱐ',
  61595. 'ⱑ' => 'Ⱑ',
  61596. 'â±’' => 'â°¢',
  61597. 'ⱓ' => 'Ⱓ',
  61598. 'â±”' => 'â°¤',
  61599. 'ⱕ' => 'Ⱕ',
  61600. 'â±–' => 'â°¦',
  61601. 'â±—' => 'â°§',
  61602. 'ⱘ' => 'Ⱘ',
  61603. 'â±™' => 'â°©',
  61604. 'ⱚ' => 'Ⱚ',
  61605. 'â±›' => 'â°«',
  61606. 'ⱜ' => 'Ⱜ',
  61607. '�' => 'Ⱝ',
  61608. 'ⱞ' => 'Ⱞ',
  61609. 'ⱡ' => 'Ⱡ',
  61610. 'ⱥ' => 'Ⱥ',
  61611. 'ⱦ' => 'Ⱦ',
  61612. 'ⱨ' => 'Ⱨ',
  61613. 'ⱪ' => 'Ⱪ',
  61614. 'ⱬ' => 'Ⱬ',
  61615. 'â±³' => 'â±²',
  61616. 'â±¶' => 'â±µ',
  61617. '�' => 'Ⲁ',
  61618. 'ⲃ' => 'Ⲃ',
  61619. 'ⲅ' => 'Ⲅ',
  61620. 'ⲇ' => 'Ⲇ',
  61621. 'ⲉ' => 'Ⲉ',
  61622. 'ⲋ' => 'Ⲋ',
  61623. '�' => 'Ⲍ',
  61624. '�' => 'Ⲏ',
  61625. 'ⲑ' => '�',
  61626. 'ⲓ' => 'Ⲓ',
  61627. 'ⲕ' => 'Ⲕ',
  61628. 'â²—' => 'â²–',
  61629. 'ⲙ' => 'Ⲙ',
  61630. 'ⲛ' => 'Ⲛ',
  61631. '�' => 'Ⲝ',
  61632. 'ⲟ' => 'Ⲟ',
  61633. 'ⲡ' => 'Ⲡ',
  61634. 'â²£' => 'â²¢',
  61635. 'ⲥ' => 'Ⲥ',
  61636. 'ⲧ' => 'Ⲧ',
  61637. 'ⲩ' => 'Ⲩ',
  61638. 'ⲫ' => 'Ⲫ',
  61639. 'ⲭ' => 'Ⲭ',
  61640. 'ⲯ' => 'Ⲯ',
  61641. 'â²±' => 'â²°',
  61642. 'â²³' => 'â²²',
  61643. 'â²µ' => 'â²´',
  61644. 'â²·' => 'â²¶',
  61645. 'ⲹ' => 'Ⲹ',
  61646. 'ⲻ' => 'Ⲻ',
  61647. 'â²½' => 'â²¼',
  61648. 'ⲿ' => 'Ⲿ',
  61649. '�' => 'Ⳁ',
  61650. 'ⳃ' => 'Ⳃ',
  61651. 'ⳅ' => 'Ⳅ',
  61652. 'ⳇ' => 'Ⳇ',
  61653. 'ⳉ' => 'Ⳉ',
  61654. 'ⳋ' => 'Ⳋ',
  61655. '�' => 'Ⳍ',
  61656. '�' => 'Ⳏ',
  61657. 'ⳑ' => '�',
  61658. 'ⳓ' => 'Ⳓ',
  61659. 'ⳕ' => 'Ⳕ',
  61660. 'â³—' => 'â³–',
  61661. 'ⳙ' => 'Ⳙ',
  61662. 'ⳛ' => 'Ⳛ',
  61663. '�' => 'Ⳝ',
  61664. 'ⳟ' => 'Ⳟ',
  61665. 'ⳡ' => 'Ⳡ',
  61666. 'â³£' => 'â³¢',
  61667. 'ⳬ' => 'Ⳬ',
  61668. 'â³®' => 'â³­',
  61669. 'â³³' => 'â³²',
  61670. 'â´€' => 'á‚ ',
  61671. 'â´�' => 'á‚¡',
  61672. 'â´‚' => 'á‚¢',
  61673. 'â´ƒ' => 'á‚£',
  61674. 'ⴄ' => 'Ⴄ',
  61675. 'â´…' => 'á‚¥',
  61676. 'ⴆ' => 'Ⴆ',
  61677. 'â´‡' => 'á‚§',
  61678. 'ⴈ' => 'Ⴈ',
  61679. 'â´‰' => 'á‚©',
  61680. 'ⴊ' => 'Ⴊ',
  61681. 'â´‹' => 'á‚«',
  61682. 'ⴌ' => 'Ⴌ',
  61683. 'â´�' => 'á‚­',
  61684. 'â´Ž' => 'á‚®',
  61685. '�' => 'Ⴏ',
  61686. 'â´�' => 'á‚°',
  61687. 'ⴑ' => 'Ⴑ',
  61688. 'ⴒ' => 'Ⴒ',
  61689. 'ⴓ' => 'Ⴓ',
  61690. 'â´”' => 'á‚´',
  61691. 'ⴕ' => 'Ⴕ',
  61692. 'â´–' => 'á‚¶',
  61693. 'â´—' => 'á‚·',
  61694. 'ⴘ' => 'Ⴘ',
  61695. 'ⴙ' => 'Ⴙ',
  61696. 'ⴚ' => 'Ⴚ',
  61697. 'â´›' => 'á‚»',
  61698. 'ⴜ' => 'Ⴜ',
  61699. '�' => 'Ⴝ',
  61700. 'ⴞ' => 'Ⴞ',
  61701. 'â´Ÿ' => 'á‚¿',
  61702. 'ⴠ' => 'Ⴠ',
  61703. 'ⴡ' => '�',
  61704. 'ⴢ' => 'Ⴢ',
  61705. 'ⴣ' => 'Ⴣ',
  61706. 'ⴤ' => 'Ⴤ',
  61707. 'ⴥ' => 'Ⴥ',
  61708. 'ⴧ' => 'Ⴧ',
  61709. 'ⴭ' => '�',
  61710. '�' => 'Ꙁ',
  61711. 'ꙃ' => 'Ꙃ',
  61712. 'ꙅ' => 'Ꙅ',
  61713. 'ꙇ' => 'Ꙇ',
  61714. 'ꙉ' => 'Ꙉ',
  61715. 'ꙋ' => 'Ꙋ',
  61716. '�' => 'Ꙍ',
  61717. '�' => 'Ꙏ',
  61718. 'ꙑ' => '�',
  61719. 'ꙓ' => 'Ꙓ',
  61720. 'ꙕ' => 'Ꙕ',
  61721. 'ê™—' => 'ê™–',
  61722. 'ꙙ' => 'Ꙙ',
  61723. 'ꙛ' => 'Ꙛ',
  61724. '�' => 'Ꙝ',
  61725. 'ꙟ' => 'Ꙟ',
  61726. 'ꙡ' => 'Ꙡ',
  61727. 'ꙣ' => 'Ꙣ',
  61728. 'ꙥ' => 'Ꙥ',
  61729. 'ꙧ' => 'Ꙧ',
  61730. 'ꙩ' => 'Ꙩ',
  61731. 'ꙫ' => 'Ꙫ',
  61732. 'ꙭ' => 'Ꙭ',
  61733. '�' => 'Ꚁ',
  61734. 'ꚃ' => 'Ꚃ',
  61735. 'êš…' => 'êš„',
  61736. 'ꚇ' => 'Ꚇ',
  61737. 'ꚉ' => 'Ꚉ',
  61738. 'ꚋ' => 'Ꚋ',
  61739. '�' => 'Ꚍ',
  61740. '�' => 'Ꚏ',
  61741. 'ꚑ' => '�',
  61742. 'êš“' => 'êš’',
  61743. 'êš•' => 'êš”',
  61744. 'êš—' => 'êš–',
  61745. 'ꚙ' => 'Ꚙ',
  61746. 'êš›' => 'êšš',
  61747. 'ꜣ' => 'Ꜣ',
  61748. 'ꜥ' => 'Ꜥ',
  61749. 'ꜧ' => 'Ꜧ',
  61750. 'ꜩ' => 'Ꜩ',
  61751. 'ꜫ' => 'Ꜫ',
  61752. 'ꜭ' => 'Ꜭ',
  61753. 'ꜯ' => 'Ꜯ',
  61754. 'ꜳ' => 'Ꜳ',
  61755. 'ꜵ' => 'Ꜵ',
  61756. 'ꜷ' => 'Ꜷ',
  61757. 'ꜹ' => 'Ꜹ',
  61758. 'ꜻ' => 'Ꜻ',
  61759. 'ꜽ' => 'Ꜽ',
  61760. 'ꜿ' => 'Ꜿ',
  61761. '�' => '�',
  61762. '�' => '�',
  61763. '�' => '�',
  61764. '�' => '�',
  61765. '�' => '�',
  61766. '�' => '�',
  61767. '�' => '�',
  61768. '�' => '�',
  61769. '�' => '�',
  61770. '�' => '�',
  61771. '�' => '�',
  61772. '�' => '�',
  61773. '�' => '�',
  61774. '�' => '�',
  61775. '�' => '�',
  61776. '�' => '�',
  61777. '�' => '�',
  61778. '�' => '�',
  61779. '�' => '�',
  61780. '�' => '�',
  61781. '�' => '�',
  61782. '�' => '�',
  61783. '�' => '�',
  61784. '�' => '�',
  61785. '�' => '�',
  61786. '�' => '�',
  61787. '�' => '�',
  61788. '�' => 'Ꞁ',
  61789. 'ꞃ' => 'Ꞃ',
  61790. 'êž…' => 'êž„',
  61791. 'ꞇ' => 'Ꞇ',
  61792. 'ꞌ' => 'Ꞌ',
  61793. 'ꞑ' => '�',
  61794. 'êž“' => 'êž’',
  61795. 'ꞔ' => 'Ꞔ',
  61796. 'êž—' => 'êž–',
  61797. 'ꞙ' => 'Ꞙ',
  61798. 'êž›' => 'êžš',
  61799. '�' => 'Ꞝ',
  61800. 'ꞟ' => 'Ꞟ',
  61801. 'êž¡' => 'êž ',
  61802. 'ꞣ' => 'Ꞣ',
  61803. 'ꞥ' => 'Ꞥ',
  61804. 'ꞧ' => 'Ꞧ',
  61805. 'ꞩ' => 'Ꞩ',
  61806. 'êžµ' => 'êž´',
  61807. 'êž·' => 'êž¶',
  61808. 'ꞹ' => 'Ꞹ',
  61809. 'ꞻ' => 'Ꞻ',
  61810. 'êž½' => 'êž¼',
  61811. 'êž¿' => 'êž¾',
  61812. 'ꟃ' => 'Ꟃ',
  61813. 'ꟈ' => 'Ꟈ',
  61814. 'ꟊ' => 'Ꟊ',
  61815. 'ꟶ' => 'Ꟶ',
  61816. 'ê­“' => 'êž³',
  61817. 'ꭰ' => 'Ꭰ',
  61818. 'ꭱ' => 'Ꭱ',
  61819. 'ꭲ' => 'Ꭲ',
  61820. 'ꭳ' => 'Ꭳ',
  61821. 'ꭴ' => 'Ꭴ',
  61822. 'ꭵ' => 'Ꭵ',
  61823. 'ꭶ' => 'Ꭶ',
  61824. 'ꭷ' => 'Ꭷ',
  61825. 'ꭸ' => 'Ꭸ',
  61826. 'ꭹ' => 'Ꭹ',
  61827. 'ꭺ' => 'Ꭺ',
  61828. 'ꭻ' => 'Ꭻ',
  61829. 'ꭼ' => 'Ꭼ',
  61830. 'ꭽ' => 'Ꭽ',
  61831. 'ꭾ' => 'Ꭾ',
  61832. 'ꭿ' => 'Ꭿ',
  61833. 'ꮀ' => 'Ꮀ',
  61834. '�' => 'Ꮁ',
  61835. 'ꮂ' => 'Ꮂ',
  61836. 'ꮃ' => 'Ꮃ',
  61837. 'ꮄ' => 'Ꮄ',
  61838. 'ꮅ' => 'Ꮅ',
  61839. 'ꮆ' => 'Ꮆ',
  61840. 'ꮇ' => 'Ꮇ',
  61841. 'ꮈ' => 'Ꮈ',
  61842. 'ꮉ' => 'Ꮉ',
  61843. 'ꮊ' => 'Ꮊ',
  61844. 'ꮋ' => 'Ꮋ',
  61845. 'ꮌ' => 'Ꮌ',
  61846. '�' => 'Ꮍ',
  61847. 'ꮎ' => 'Ꮎ',
  61848. '�' => 'Ꮏ',
  61849. '�' => '�',
  61850. 'ꮑ' => '�',
  61851. 'ꮒ' => '�',
  61852. 'ꮓ' => '�',
  61853. 'ꮔ' => '�',
  61854. 'ꮕ' => '�',
  61855. 'ꮖ' => '�',
  61856. 'ꮗ' => '�',
  61857. 'ꮘ' => '�',
  61858. 'ꮙ' => '�',
  61859. 'ꮚ' => '�',
  61860. 'ꮛ' => '�',
  61861. 'ꮜ' => '�',
  61862. '�' => '�',
  61863. 'ꮞ' => '�',
  61864. 'ꮟ' => '�',
  61865. 'ꮠ' => '�',
  61866. 'ꮡ' => '�',
  61867. 'ꮢ' => '�',
  61868. 'ꮣ' => '�',
  61869. 'ꮤ' => '�',
  61870. 'ꮥ' => '�',
  61871. 'ꮦ' => '�',
  61872. 'ꮧ' => '�',
  61873. 'ꮨ' => '�',
  61874. 'ꮩ' => '�',
  61875. 'ꮪ' => '�',
  61876. 'ꮫ' => '�',
  61877. 'ꮬ' => '�',
  61878. 'ꮭ' => '�',
  61879. 'ꮮ' => '�',
  61880. 'ꮯ' => '�',
  61881. 'ꮰ' => '�',
  61882. 'ꮱ' => '�',
  61883. 'ꮲ' => '�',
  61884. 'ꮳ' => '�',
  61885. 'ꮴ' => '�',
  61886. 'ꮵ' => '�',
  61887. 'ꮶ' => '�',
  61888. 'ꮷ' => '�',
  61889. 'ꮸ' => '�',
  61890. 'ꮹ' => '�',
  61891. 'ꮺ' => '�',
  61892. 'ꮻ' => '�',
  61893. 'ꮼ' => '�',
  61894. 'ꮽ' => '�',
  61895. 'ꮾ' => '�',
  61896. 'ꮿ' => '�',
  61897. '�' => 'A',
  61898. 'b' => 'B',
  61899. 'c' => 'C',
  61900. 'd' => 'D',
  61901. 'ï½…' => 'ï¼¥',
  61902. 'f' => 'F',
  61903. 'g' => 'G',
  61904. 'h' => 'H',
  61905. 'i' => 'I',
  61906. 'j' => 'J',
  61907. 'k' => 'K',
  61908. 'l' => 'L',
  61909. '�' => 'M',
  61910. 'n' => 'N',
  61911. '�' => 'O',
  61912. '�' => 'P',
  61913. 'q' => 'Q',
  61914. 'ï½’' => 'ï¼²',
  61915. 's' => 'S',
  61916. 'ï½”' => 'ï¼´',
  61917. 'u' => 'U',
  61918. 'ï½–' => 'ï¼¶',
  61919. 'ï½—' => 'ï¼·',
  61920. 'x' => 'X',
  61921. 'ï½™' => 'ï¼¹',
  61922. 'z' => 'Z',
  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. <?php
  62150. use Symfony\Polyfill\Mbstring as p;
  62151. if (!function_exists('mb_convert_encoding')) {
  62152. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  62153. }
  62154. if (!function_exists('mb_decode_mimeheader')) {
  62155. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  62156. }
  62157. if (!function_exists('mb_encode_mimeheader')) {
  62158. 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); }
  62159. }
  62160. if (!function_exists('mb_decode_numericentity')) {
  62161. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  62162. }
  62163. if (!function_exists('mb_encode_numericentity')) {
  62164. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  62165. }
  62166. if (!function_exists('mb_convert_case')) {
  62167. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  62168. }
  62169. if (!function_exists('mb_internal_encoding')) {
  62170. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  62171. }
  62172. if (!function_exists('mb_language')) {
  62173. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  62174. }
  62175. if (!function_exists('mb_list_encodings')) {
  62176. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  62177. }
  62178. if (!function_exists('mb_encoding_aliases')) {
  62179. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  62180. }
  62181. if (!function_exists('mb_check_encoding')) {
  62182. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  62183. }
  62184. if (!function_exists('mb_detect_encoding')) {
  62185. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  62186. }
  62187. if (!function_exists('mb_detect_order')) {
  62188. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  62189. }
  62190. if (!function_exists('mb_parse_str')) {
  62191. function mb_parse_str($string, &$result = array()) { parse_str($string, $result); }
  62192. }
  62193. if (!function_exists('mb_strlen')) {
  62194. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  62195. }
  62196. if (!function_exists('mb_strpos')) {
  62197. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  62198. }
  62199. if (!function_exists('mb_strtolower')) {
  62200. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  62201. }
  62202. if (!function_exists('mb_strtoupper')) {
  62203. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  62204. }
  62205. if (!function_exists('mb_substitute_character')) {
  62206. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  62207. }
  62208. if (!function_exists('mb_substr')) {
  62209. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  62210. }
  62211. if (!function_exists('mb_stripos')) {
  62212. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  62213. }
  62214. if (!function_exists('mb_stristr')) {
  62215. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  62216. }
  62217. if (!function_exists('mb_strrchr')) {
  62218. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  62219. }
  62220. if (!function_exists('mb_strrichr')) {
  62221. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  62222. }
  62223. if (!function_exists('mb_strripos')) {
  62224. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  62225. }
  62226. if (!function_exists('mb_strrpos')) {
  62227. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  62228. }
  62229. if (!function_exists('mb_strstr')) {
  62230. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  62231. }
  62232. if (!function_exists('mb_get_info')) {
  62233. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  62234. }
  62235. if (!function_exists('mb_http_output')) {
  62236. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  62237. }
  62238. if (!function_exists('mb_strwidth')) {
  62239. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  62240. }
  62241. if (!function_exists('mb_substr_count')) {
  62242. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  62243. }
  62244. if (!function_exists('mb_output_handler')) {
  62245. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  62246. }
  62247. if (!function_exists('mb_http_input')) {
  62248. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  62249. }
  62250. if (PHP_VERSION_ID >= 80000) {
  62251. require_once __DIR__.'/Resources/mb_convert_variables.php8';
  62252. } elseif (!function_exists('mb_convert_variables')) {
  62253. 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); }
  62254. }
  62255. if (!function_exists('mb_ord')) {
  62256. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  62257. }
  62258. if (!function_exists('mb_chr')) {
  62259. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  62260. }
  62261. if (!function_exists('mb_scrub')) {
  62262. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  62263. }
  62264. if (!function_exists('mb_str_split')) {
  62265. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  62266. }
  62267. if (extension_loaded('mbstring')) {
  62268. return;
  62269. }
  62270. if (!defined('MB_CASE_UPPER')) {
  62271. define('MB_CASE_UPPER', 0);
  62272. }
  62273. if (!defined('MB_CASE_LOWER')) {
  62274. define('MB_CASE_LOWER', 1);
  62275. }
  62276. if (!defined('MB_CASE_TITLE')) {
  62277. define('MB_CASE_TITLE', 2);
  62278. }
  62279. <?php
  62280. namespace Symfony\Component\Process\Exception;
  62281. interface ExceptionInterface
  62282. {
  62283. }
  62284. <?php
  62285. namespace Symfony\Component\Process\Exception;
  62286. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  62287. {
  62288. }
  62289. <?php
  62290. namespace Symfony\Component\Process\Exception;
  62291. class LogicException extends \LogicException implements ExceptionInterface
  62292. {
  62293. }
  62294. <?php
  62295. namespace Symfony\Component\Process\Exception;
  62296. use Symfony\Component\Process\Process;
  62297. class ProcessFailedException extends RuntimeException
  62298. {
  62299. private $process;
  62300. public function __construct(Process $process)
  62301. {
  62302. if ($process->isSuccessful()) {
  62303. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  62304. }
  62305. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  62306. $process->getCommandLine(),
  62307. $process->getExitCode(),
  62308. $process->getExitCodeText(),
  62309. $process->getWorkingDirectory()
  62310. );
  62311. if (!$process->isOutputDisabled()) {
  62312. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  62313. $process->getOutput(),
  62314. $process->getErrorOutput()
  62315. );
  62316. }
  62317. parent::__construct($error);
  62318. $this->process = $process;
  62319. }
  62320. public function getProcess()
  62321. {
  62322. return $this->process;
  62323. }
  62324. }
  62325. <?php
  62326. namespace Symfony\Component\Process\Exception;
  62327. use Symfony\Component\Process\Process;
  62328. class ProcessTimedOutException extends RuntimeException
  62329. {
  62330. const TYPE_GENERAL = 1;
  62331. const TYPE_IDLE = 2;
  62332. private $process;
  62333. private $timeoutType;
  62334. public function __construct(Process $process, $timeoutType)
  62335. {
  62336. $this->process = $process;
  62337. $this->timeoutType = $timeoutType;
  62338. parent::__construct(sprintf(
  62339. 'The process "%s" exceeded the timeout of %s seconds.',
  62340. $process->getCommandLine(),
  62341. $this->getExceededTimeout()
  62342. ));
  62343. }
  62344. public function getProcess()
  62345. {
  62346. return $this->process;
  62347. }
  62348. public function isGeneralTimeout()
  62349. {
  62350. return self::TYPE_GENERAL === $this->timeoutType;
  62351. }
  62352. public function isIdleTimeout()
  62353. {
  62354. return self::TYPE_IDLE === $this->timeoutType;
  62355. }
  62356. public function getExceededTimeout()
  62357. {
  62358. switch ($this->timeoutType) {
  62359. case self::TYPE_GENERAL:
  62360. return $this->process->getTimeout();
  62361. case self::TYPE_IDLE:
  62362. return $this->process->getIdleTimeout();
  62363. default:
  62364. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  62365. }
  62366. }
  62367. }
  62368. <?php
  62369. namespace Symfony\Component\Process\Exception;
  62370. class RuntimeException extends \RuntimeException implements ExceptionInterface
  62371. {
  62372. }
  62373. <?php
  62374. namespace Symfony\Component\Process;
  62375. class ExecutableFinder
  62376. {
  62377. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  62378. public function setSuffixes(array $suffixes)
  62379. {
  62380. $this->suffixes = $suffixes;
  62381. }
  62382. public function addSuffix($suffix)
  62383. {
  62384. $this->suffixes[] = $suffix;
  62385. }
  62386. public function find($name, $default = null, array $extraDirs = array())
  62387. {
  62388. if (ini_get('open_basedir')) {
  62389. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  62390. $dirs = array();
  62391. foreach ($searchPath as $path) {
  62392. if (@is_dir($path)) {
  62393. $dirs[] = $path;
  62394. } else {
  62395. if (basename($path) == $name && @is_executable($path)) {
  62396. return $path;
  62397. }
  62398. }
  62399. }
  62400. } else {
  62401. $dirs = array_merge(
  62402. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  62403. $extraDirs
  62404. );
  62405. }
  62406. $suffixes = array('');
  62407. if ('\\' === \DIRECTORY_SEPARATOR) {
  62408. $pathExt = getenv('PATHEXT');
  62409. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  62410. }
  62411. foreach ($suffixes as $suffix) {
  62412. foreach ($dirs as $dir) {
  62413. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  62414. return $file;
  62415. }
  62416. }
  62417. }
  62418. return $default;
  62419. }
  62420. }
  62421. Copyright (c) 2004-2018 Fabien Potencier
  62422. Permission is hereby granted, free of charge, to any person obtaining a copy
  62423. of this software and associated documentation files (the "Software"), to deal
  62424. in the Software without restriction, including without limitation the rights
  62425. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62426. copies of the Software, and to permit persons to whom the Software is furnished
  62427. to do so, subject to the following conditions:
  62428. The above copyright notice and this permission notice shall be included in all
  62429. copies or substantial portions of the Software.
  62430. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62431. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62432. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62433. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62434. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62435. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62436. THE SOFTWARE.
  62437. <?php
  62438. namespace Symfony\Component\Process;
  62439. class PhpExecutableFinder
  62440. {
  62441. private $executableFinder;
  62442. public function __construct()
  62443. {
  62444. $this->executableFinder = new ExecutableFinder();
  62445. }
  62446. public function find($includeArgs = true)
  62447. {
  62448. $args = $this->findArguments();
  62449. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  62450. if (\defined('HHVM_VERSION')) {
  62451. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  62452. }
  62453. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  62454. return PHP_BINARY.$args;
  62455. }
  62456. if ($php = getenv('PHP_PATH')) {
  62457. if (!@is_executable($php)) {
  62458. return false;
  62459. }
  62460. return $php;
  62461. }
  62462. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  62463. if (@is_executable($php)) {
  62464. return $php;
  62465. }
  62466. }
  62467. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  62468. return $php;
  62469. }
  62470. $dirs = array(PHP_BINDIR);
  62471. if ('\\' === \DIRECTORY_SEPARATOR) {
  62472. $dirs[] = 'C:\xampp\php\\';
  62473. }
  62474. return $this->executableFinder->find('php', false, $dirs);
  62475. }
  62476. public function findArguments()
  62477. {
  62478. $arguments = array();
  62479. if (\defined('HHVM_VERSION')) {
  62480. $arguments[] = '--php';
  62481. } elseif ('phpdbg' === \PHP_SAPI) {
  62482. $arguments[] = '-qrr';
  62483. }
  62484. return $arguments;
  62485. }
  62486. }
  62487. <?php
  62488. namespace Symfony\Component\Process;
  62489. use Symfony\Component\Process\Exception\RuntimeException;
  62490. class PhpProcess extends Process
  62491. {
  62492. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  62493. {
  62494. $executableFinder = new PhpExecutableFinder();
  62495. if (false === $php = $executableFinder->find()) {
  62496. $php = null;
  62497. }
  62498. if ('phpdbg' === \PHP_SAPI) {
  62499. $file = tempnam(sys_get_temp_dir(), 'dbg');
  62500. file_put_contents($file, $script);
  62501. register_shutdown_function('unlink', $file);
  62502. $php .= ' '.ProcessUtils::escapeArgument($file);
  62503. $script = null;
  62504. }
  62505. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  62506. $php = 'exec '.$php;
  62507. }
  62508. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  62509. }
  62510. public function setPhpBinary($php)
  62511. {
  62512. $this->setCommandLine($php);
  62513. }
  62514. public function start($callback = null)
  62515. {
  62516. if (null === $this->getCommandLine()) {
  62517. throw new RuntimeException('Unable to find the PHP executable.');
  62518. }
  62519. parent::start($callback);
  62520. }
  62521. }
  62522. <?php
  62523. namespace Symfony\Component\Process\Pipes;
  62524. abstract class AbstractPipes implements PipesInterface
  62525. {
  62526. public $pipes = array();
  62527. private $inputBuffer = '';
  62528. private $input;
  62529. private $blocked = true;
  62530. private $lastError;
  62531. public function __construct($input)
  62532. {
  62533. if (\is_resource($input)) {
  62534. $this->input = $input;
  62535. } elseif (\is_string($input)) {
  62536. $this->inputBuffer = $input;
  62537. } else {
  62538. $this->inputBuffer = (string) $input;
  62539. }
  62540. }
  62541. public function close()
  62542. {
  62543. foreach ($this->pipes as $pipe) {
  62544. fclose($pipe);
  62545. }
  62546. $this->pipes = array();
  62547. }
  62548. protected function hasSystemCallBeenInterrupted()
  62549. {
  62550. $lastError = $this->lastError;
  62551. $this->lastError = null;
  62552. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  62553. }
  62554. protected function unblock()
  62555. {
  62556. if (!$this->blocked) {
  62557. return;
  62558. }
  62559. foreach ($this->pipes as $pipe) {
  62560. stream_set_blocking($pipe, 0);
  62561. }
  62562. if (null !== $this->input) {
  62563. stream_set_blocking($this->input, 0);
  62564. }
  62565. $this->blocked = false;
  62566. }
  62567. protected function write()
  62568. {
  62569. if (!isset($this->pipes[0])) {
  62570. return;
  62571. }
  62572. $input = $this->input;
  62573. $r = $e = array();
  62574. $w = array($this->pipes[0]);
  62575. if (false === @stream_select($r, $w, $e, 0, 0)) {
  62576. return;
  62577. }
  62578. foreach ($w as $stdin) {
  62579. if (isset($this->inputBuffer[0])) {
  62580. $written = fwrite($stdin, $this->inputBuffer);
  62581. $this->inputBuffer = substr($this->inputBuffer, $written);
  62582. if (isset($this->inputBuffer[0])) {
  62583. return array($this->pipes[0]);
  62584. }
  62585. }
  62586. if ($input) {
  62587. for (;;) {
  62588. $data = fread($input, self::CHUNK_SIZE);
  62589. if (!isset($data[0])) {
  62590. break;
  62591. }
  62592. $written = fwrite($stdin, $data);
  62593. $data = substr($data, $written);
  62594. if (isset($data[0])) {
  62595. $this->inputBuffer = $data;
  62596. return array($this->pipes[0]);
  62597. }
  62598. }
  62599. if (feof($input)) {
  62600. $this->input = null;
  62601. }
  62602. }
  62603. }
  62604. if (null === $this->input && !isset($this->inputBuffer[0])) {
  62605. fclose($this->pipes[0]);
  62606. unset($this->pipes[0]);
  62607. } elseif (!$w) {
  62608. return array($this->pipes[0]);
  62609. }
  62610. }
  62611. public function handleError($type, $msg)
  62612. {
  62613. $this->lastError = $msg;
  62614. }
  62615. }
  62616. <?php
  62617. namespace Symfony\Component\Process\Pipes;
  62618. interface PipesInterface
  62619. {
  62620. const CHUNK_SIZE = 16384;
  62621. public function getDescriptors();
  62622. public function getFiles();
  62623. public function readAndWrite($blocking, $close = false);
  62624. public function areOpen();
  62625. public function close();
  62626. }
  62627. <?php
  62628. namespace Symfony\Component\Process\Pipes;
  62629. use Symfony\Component\Process\Process;
  62630. class UnixPipes extends AbstractPipes
  62631. {
  62632. private $ttyMode;
  62633. private $ptyMode;
  62634. private $disableOutput;
  62635. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  62636. {
  62637. $this->ttyMode = (bool) $ttyMode;
  62638. $this->ptyMode = (bool) $ptyMode;
  62639. $this->disableOutput = (bool) $disableOutput;
  62640. parent::__construct($input);
  62641. }
  62642. public function __destruct()
  62643. {
  62644. $this->close();
  62645. }
  62646. public function getDescriptors()
  62647. {
  62648. if ($this->disableOutput) {
  62649. $nullstream = fopen('/dev/null', 'c');
  62650. return array(
  62651. array('pipe', 'r'),
  62652. $nullstream,
  62653. $nullstream,
  62654. );
  62655. }
  62656. if ($this->ttyMode) {
  62657. return array(
  62658. array('file', '/dev/tty', 'r'),
  62659. array('file', '/dev/tty', 'w'),
  62660. array('file', '/dev/tty', 'w'),
  62661. );
  62662. }
  62663. if ($this->ptyMode && Process::isPtySupported()) {
  62664. return array(
  62665. array('pty'),
  62666. array('pty'),
  62667. array('pty'),
  62668. );
  62669. }
  62670. return array(
  62671. array('pipe', 'r'),
  62672. array('pipe', 'w'),
  62673. array('pipe', 'w'),
  62674. );
  62675. }
  62676. public function getFiles()
  62677. {
  62678. return array();
  62679. }
  62680. public function readAndWrite($blocking, $close = false)
  62681. {
  62682. $this->unblock();
  62683. $w = $this->write();
  62684. $read = $e = array();
  62685. $r = $this->pipes;
  62686. unset($r[0]);
  62687. set_error_handler(array($this, 'handleError'));
  62688. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  62689. restore_error_handler();
  62690. if (!$this->hasSystemCallBeenInterrupted()) {
  62691. $this->pipes = array();
  62692. }
  62693. return $read;
  62694. }
  62695. restore_error_handler();
  62696. foreach ($r as $pipe) {
  62697. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  62698. do {
  62699. $data = fread($pipe, self::CHUNK_SIZE);
  62700. $read[$type] .= $data;
  62701. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  62702. if (!isset($read[$type][0])) {
  62703. unset($read[$type]);
  62704. }
  62705. if ($close && feof($pipe)) {
  62706. fclose($pipe);
  62707. unset($this->pipes[$type]);
  62708. }
  62709. }
  62710. return $read;
  62711. }
  62712. public function areOpen()
  62713. {
  62714. return (bool) $this->pipes;
  62715. }
  62716. public static function create(Process $process, $input)
  62717. {
  62718. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  62719. }
  62720. }
  62721. <?php
  62722. namespace Symfony\Component\Process\Pipes;
  62723. use Symfony\Component\Process\Exception\RuntimeException;
  62724. use Symfony\Component\Process\Process;
  62725. class WindowsPipes extends AbstractPipes
  62726. {
  62727. private $files = array();
  62728. private $fileHandles = array();
  62729. private $lockHandles = array();
  62730. private $readBytes = array(
  62731. Process::STDOUT => 0,
  62732. Process::STDERR => 0,
  62733. );
  62734. private $disableOutput;
  62735. public function __construct($disableOutput, $input)
  62736. {
  62737. $this->disableOutput = (bool) $disableOutput;
  62738. if (!$this->disableOutput) {
  62739. $pipes = array(
  62740. Process::STDOUT => Process::OUT,
  62741. Process::STDERR => Process::ERR,
  62742. );
  62743. $tmpDir = sys_get_temp_dir();
  62744. $lastError = 'unknown reason';
  62745. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  62746. for ($i = 0;; ++$i) {
  62747. foreach ($pipes as $pipe => $name) {
  62748. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  62749. if (!$h = fopen($file.'.lock', 'w')) {
  62750. restore_error_handler();
  62751. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  62752. }
  62753. if (!flock($h, LOCK_EX | LOCK_NB)) {
  62754. continue 2;
  62755. }
  62756. if (isset($this->lockHandles[$pipe])) {
  62757. flock($this->lockHandles[$pipe], LOCK_UN);
  62758. fclose($this->lockHandles[$pipe]);
  62759. }
  62760. $this->lockHandles[$pipe] = $h;
  62761. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  62762. flock($this->lockHandles[$pipe], LOCK_UN);
  62763. fclose($this->lockHandles[$pipe]);
  62764. unset($this->lockHandles[$pipe]);
  62765. continue 2;
  62766. }
  62767. $this->fileHandles[$pipe] = $h;
  62768. $this->files[$pipe] = $file;
  62769. }
  62770. break;
  62771. }
  62772. restore_error_handler();
  62773. }
  62774. parent::__construct($input);
  62775. }
  62776. public function __destruct()
  62777. {
  62778. $this->close();
  62779. }
  62780. public function getDescriptors()
  62781. {
  62782. if ($this->disableOutput) {
  62783. $nullstream = fopen('NUL', 'c');
  62784. return array(
  62785. array('pipe', 'r'),
  62786. $nullstream,
  62787. $nullstream,
  62788. );
  62789. }
  62790. return array(
  62791. array('pipe', 'r'),
  62792. array('file', 'NUL', 'w'),
  62793. array('file', 'NUL', 'w'),
  62794. );
  62795. }
  62796. public function getFiles()
  62797. {
  62798. return $this->files;
  62799. }
  62800. public function readAndWrite($blocking, $close = false)
  62801. {
  62802. $this->unblock();
  62803. $w = $this->write();
  62804. $read = $r = $e = array();
  62805. if ($blocking) {
  62806. if ($w) {
  62807. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  62808. } elseif ($this->fileHandles) {
  62809. usleep(Process::TIMEOUT_PRECISION * 1E6);
  62810. }
  62811. }
  62812. foreach ($this->fileHandles as $type => $fileHandle) {
  62813. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  62814. if (isset($data[0])) {
  62815. $this->readBytes[$type] += \strlen($data);
  62816. $read[$type] = $data;
  62817. }
  62818. if ($close) {
  62819. ftruncate($fileHandle, 0);
  62820. fclose($fileHandle);
  62821. flock($this->lockHandles[$type], LOCK_UN);
  62822. fclose($this->lockHandles[$type]);
  62823. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  62824. }
  62825. }
  62826. return $read;
  62827. }
  62828. public function areOpen()
  62829. {
  62830. return $this->pipes && $this->fileHandles;
  62831. }
  62832. public function close()
  62833. {
  62834. parent::close();
  62835. foreach ($this->fileHandles as $type => $handle) {
  62836. ftruncate($handle, 0);
  62837. fclose($handle);
  62838. flock($this->lockHandles[$type], LOCK_UN);
  62839. fclose($this->lockHandles[$type]);
  62840. }
  62841. $this->fileHandles = $this->lockHandles = array();
  62842. }
  62843. public static function create(Process $process, $input)
  62844. {
  62845. return new static($process->isOutputDisabled(), $input);
  62846. }
  62847. }
  62848. <?php
  62849. namespace Symfony\Component\Process;
  62850. use Symfony\Component\Process\Exception\InvalidArgumentException;
  62851. use Symfony\Component\Process\Exception\LogicException;
  62852. use Symfony\Component\Process\Exception\ProcessFailedException;
  62853. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  62854. use Symfony\Component\Process\Exception\RuntimeException;
  62855. use Symfony\Component\Process\Pipes\PipesInterface;
  62856. use Symfony\Component\Process\Pipes\UnixPipes;
  62857. use Symfony\Component\Process\Pipes\WindowsPipes;
  62858. class Process
  62859. {
  62860. const ERR = 'err';
  62861. const OUT = 'out';
  62862. const STATUS_READY = 'ready';
  62863. const STATUS_STARTED = 'started';
  62864. const STATUS_TERMINATED = 'terminated';
  62865. const STDIN = 0;
  62866. const STDOUT = 1;
  62867. const STDERR = 2;
  62868. const TIMEOUT_PRECISION = 0.2;
  62869. private $callback;
  62870. private $commandline;
  62871. private $cwd;
  62872. private $env;
  62873. private $input;
  62874. private $starttime;
  62875. private $lastOutputTime;
  62876. private $timeout;
  62877. private $idleTimeout;
  62878. private $options;
  62879. private $exitcode;
  62880. private $fallbackStatus = array();
  62881. private $processInformation;
  62882. private $outputDisabled = false;
  62883. private $stdout;
  62884. private $stderr;
  62885. private $enhanceWindowsCompatibility = true;
  62886. private $enhanceSigchildCompatibility;
  62887. private $process;
  62888. private $status = self::STATUS_READY;
  62889. private $incrementalOutputOffset = 0;
  62890. private $incrementalErrorOutputOffset = 0;
  62891. private $tty;
  62892. private $pty;
  62893. private $useFileHandles = false;
  62894. private $processPipes;
  62895. private $latestSignal;
  62896. private static $sigchild;
  62897. public static $exitCodes = array(
  62898. 0 => 'OK',
  62899. 1 => 'General error',
  62900. 2 => 'Misuse of shell builtins',
  62901. 126 => 'Invoked command cannot execute',
  62902. 127 => 'Command not found',
  62903. 128 => 'Invalid exit argument',
  62904. 129 => 'Hangup',
  62905. 130 => 'Interrupt',
  62906. 131 => 'Quit and dump core',
  62907. 132 => 'Illegal instruction',
  62908. 133 => 'Trace/breakpoint trap',
  62909. 134 => 'Process aborted',
  62910. 135 => 'Bus error: "access to undefined portion of memory object"',
  62911. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  62912. 137 => 'Kill (terminate immediately)',
  62913. 138 => 'User-defined 1',
  62914. 139 => 'Segmentation violation',
  62915. 140 => 'User-defined 2',
  62916. 141 => 'Write to pipe with no one reading',
  62917. 142 => 'Signal raised by alarm',
  62918. 143 => 'Termination (request to terminate)',
  62919. 145 => 'Child process terminated, stopped (or continued*)',
  62920. 146 => 'Continue if stopped',
  62921. 147 => 'Stop executing temporarily',
  62922. 148 => 'Terminal stop signal',
  62923. 149 => 'Background process attempting to read from tty ("in")',
  62924. 150 => 'Background process attempting to write to tty ("out")',
  62925. 151 => 'Urgent data available on socket',
  62926. 152 => 'CPU time limit exceeded',
  62927. 153 => 'File size limit exceeded',
  62928. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  62929. 155 => 'Profiling timer expired',
  62930. 157 => 'Pollable event',
  62931. 159 => 'Bad syscall',
  62932. );
  62933. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  62934. {
  62935. if (!\function_exists('proc_open')) {
  62936. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  62937. }
  62938. $this->commandline = $commandline;
  62939. $this->cwd = $cwd;
  62940. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  62941. $this->cwd = getcwd();
  62942. }
  62943. if (null !== $env) {
  62944. $this->setEnv($env);
  62945. }
  62946. $this->setInput($input);
  62947. $this->setTimeout($timeout);
  62948. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  62949. $this->pty = false;
  62950. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  62951. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  62952. }
  62953. public function __destruct()
  62954. {
  62955. $this->stop(0);
  62956. }
  62957. public function __clone()
  62958. {
  62959. $this->resetProcessData();
  62960. }
  62961. public function run($callback = null)
  62962. {
  62963. $this->start($callback);
  62964. return $this->wait();
  62965. }
  62966. public function mustRun($callback = null)
  62967. {
  62968. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  62969. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  62970. }
  62971. if (0 !== $this->run($callback)) {
  62972. throw new ProcessFailedException($this);
  62973. }
  62974. return $this;
  62975. }
  62976. public function start($callback = null)
  62977. {
  62978. if ($this->isRunning()) {
  62979. throw new RuntimeException('Process is already running');
  62980. }
  62981. if ($this->outputDisabled && null !== $callback) {
  62982. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  62983. }
  62984. $this->resetProcessData();
  62985. $this->starttime = $this->lastOutputTime = microtime(true);
  62986. $this->callback = $this->buildCallback($callback);
  62987. $descriptors = $this->getDescriptors();
  62988. $commandline = $this->commandline;
  62989. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  62990. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  62991. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  62992. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  62993. }
  62994. $commandline .= '"';
  62995. if (!isset($this->options['bypass_shell'])) {
  62996. $this->options['bypass_shell'] = true;
  62997. }
  62998. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  62999. $descriptors[3] = array('pipe', 'w');
  63000. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  63001. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  63002. $ptsWorkaround = fopen(__FILE__, 'r');
  63003. }
  63004. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  63005. if (!\is_resource($this->process)) {
  63006. throw new RuntimeException('Unable to launch a new process.');
  63007. }
  63008. $this->status = self::STATUS_STARTED;
  63009. if (isset($descriptors[3])) {
  63010. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  63011. }
  63012. if ($this->tty) {
  63013. return;
  63014. }
  63015. $this->updateStatus(false);
  63016. $this->checkTimeout();
  63017. }
  63018. public function restart($callback = null)
  63019. {
  63020. if ($this->isRunning()) {
  63021. throw new RuntimeException('Process is already running');
  63022. }
  63023. $process = clone $this;
  63024. $process->start($callback);
  63025. return $process;
  63026. }
  63027. public function wait($callback = null)
  63028. {
  63029. $this->requireProcessIsStarted(__FUNCTION__);
  63030. $this->updateStatus(false);
  63031. if (null !== $callback) {
  63032. $this->callback = $this->buildCallback($callback);
  63033. }
  63034. do {
  63035. $this->checkTimeout();
  63036. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  63037. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  63038. } while ($running);
  63039. while ($this->isRunning()) {
  63040. usleep(1000);
  63041. }
  63042. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  63043. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  63044. }
  63045. return $this->exitcode;
  63046. }
  63047. public function getPid()
  63048. {
  63049. return $this->isRunning() ? $this->processInformation['pid'] : null;
  63050. }
  63051. public function signal($signal)
  63052. {
  63053. $this->doSignal($signal, true);
  63054. return $this;
  63055. }
  63056. public function disableOutput()
  63057. {
  63058. if ($this->isRunning()) {
  63059. throw new RuntimeException('Disabling output while the process is running is not possible.');
  63060. }
  63061. if (null !== $this->idleTimeout) {
  63062. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  63063. }
  63064. $this->outputDisabled = true;
  63065. return $this;
  63066. }
  63067. public function enableOutput()
  63068. {
  63069. if ($this->isRunning()) {
  63070. throw new RuntimeException('Enabling output while the process is running is not possible.');
  63071. }
  63072. $this->outputDisabled = false;
  63073. return $this;
  63074. }
  63075. public function isOutputDisabled()
  63076. {
  63077. return $this->outputDisabled;
  63078. }
  63079. public function getOutput()
  63080. {
  63081. $this->readPipesForOutput(__FUNCTION__);
  63082. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  63083. return '';
  63084. }
  63085. return $ret;
  63086. }
  63087. public function getIncrementalOutput()
  63088. {
  63089. $this->readPipesForOutput(__FUNCTION__);
  63090. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  63091. $this->incrementalOutputOffset = ftell($this->stdout);
  63092. if (false === $latest) {
  63093. return '';
  63094. }
  63095. return $latest;
  63096. }
  63097. public function clearOutput()
  63098. {
  63099. ftruncate($this->stdout, 0);
  63100. fseek($this->stdout, 0);
  63101. $this->incrementalOutputOffset = 0;
  63102. return $this;
  63103. }
  63104. public function getErrorOutput()
  63105. {
  63106. $this->readPipesForOutput(__FUNCTION__);
  63107. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  63108. return '';
  63109. }
  63110. return $ret;
  63111. }
  63112. public function getIncrementalErrorOutput()
  63113. {
  63114. $this->readPipesForOutput(__FUNCTION__);
  63115. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  63116. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  63117. if (false === $latest) {
  63118. return '';
  63119. }
  63120. return $latest;
  63121. }
  63122. public function clearErrorOutput()
  63123. {
  63124. ftruncate($this->stderr, 0);
  63125. fseek($this->stderr, 0);
  63126. $this->incrementalErrorOutputOffset = 0;
  63127. return $this;
  63128. }
  63129. public function getExitCode()
  63130. {
  63131. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63132. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  63133. }
  63134. $this->updateStatus(false);
  63135. return $this->exitcode;
  63136. }
  63137. public function getExitCodeText()
  63138. {
  63139. if (null === $exitcode = $this->getExitCode()) {
  63140. return;
  63141. }
  63142. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  63143. }
  63144. public function isSuccessful()
  63145. {
  63146. return 0 === $this->getExitCode();
  63147. }
  63148. public function hasBeenSignaled()
  63149. {
  63150. $this->requireProcessIsTerminated(__FUNCTION__);
  63151. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63152. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63153. }
  63154. return $this->processInformation['signaled'];
  63155. }
  63156. public function getTermSignal()
  63157. {
  63158. $this->requireProcessIsTerminated(__FUNCTION__);
  63159. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  63160. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63161. }
  63162. return $this->processInformation['termsig'];
  63163. }
  63164. public function hasBeenStopped()
  63165. {
  63166. $this->requireProcessIsTerminated(__FUNCTION__);
  63167. return $this->processInformation['stopped'];
  63168. }
  63169. public function getStopSignal()
  63170. {
  63171. $this->requireProcessIsTerminated(__FUNCTION__);
  63172. return $this->processInformation['stopsig'];
  63173. }
  63174. public function isRunning()
  63175. {
  63176. if (self::STATUS_STARTED !== $this->status) {
  63177. return false;
  63178. }
  63179. $this->updateStatus(false);
  63180. return $this->processInformation['running'];
  63181. }
  63182. public function isStarted()
  63183. {
  63184. return self::STATUS_READY != $this->status;
  63185. }
  63186. public function isTerminated()
  63187. {
  63188. $this->updateStatus(false);
  63189. return self::STATUS_TERMINATED == $this->status;
  63190. }
  63191. public function getStatus()
  63192. {
  63193. $this->updateStatus(false);
  63194. return $this->status;
  63195. }
  63196. public function stop($timeout = 10, $signal = null)
  63197. {
  63198. $timeoutMicro = microtime(true) + $timeout;
  63199. if ($this->isRunning()) {
  63200. $this->doSignal(15, false);
  63201. do {
  63202. usleep(1000);
  63203. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  63204. if ($this->isRunning()) {
  63205. $this->doSignal($signal ?: 9, false);
  63206. }
  63207. }
  63208. if ($this->isRunning()) {
  63209. if (isset($this->fallbackStatus['pid'])) {
  63210. unset($this->fallbackStatus['pid']);
  63211. return $this->stop(0, $signal);
  63212. }
  63213. $this->close();
  63214. }
  63215. return $this->exitcode;
  63216. }
  63217. public function addOutput($line)
  63218. {
  63219. $this->lastOutputTime = microtime(true);
  63220. fseek($this->stdout, 0, SEEK_END);
  63221. fwrite($this->stdout, $line);
  63222. fseek($this->stdout, $this->incrementalOutputOffset);
  63223. }
  63224. public function addErrorOutput($line)
  63225. {
  63226. $this->lastOutputTime = microtime(true);
  63227. fseek($this->stderr, 0, SEEK_END);
  63228. fwrite($this->stderr, $line);
  63229. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  63230. }
  63231. public function getCommandLine()
  63232. {
  63233. return $this->commandline;
  63234. }
  63235. public function setCommandLine($commandline)
  63236. {
  63237. $this->commandline = $commandline;
  63238. return $this;
  63239. }
  63240. public function getTimeout()
  63241. {
  63242. return $this->timeout;
  63243. }
  63244. public function getIdleTimeout()
  63245. {
  63246. return $this->idleTimeout;
  63247. }
  63248. public function setTimeout($timeout)
  63249. {
  63250. $this->timeout = $this->validateTimeout($timeout);
  63251. return $this;
  63252. }
  63253. public function setIdleTimeout($timeout)
  63254. {
  63255. if (null !== $timeout && $this->outputDisabled) {
  63256. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  63257. }
  63258. $this->idleTimeout = $this->validateTimeout($timeout);
  63259. return $this;
  63260. }
  63261. public function setTty($tty)
  63262. {
  63263. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  63264. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  63265. }
  63266. if ($tty) {
  63267. static $isTtySupported;
  63268. if (null === $isTtySupported) {
  63269. $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);
  63270. }
  63271. if (!$isTtySupported) {
  63272. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  63273. }
  63274. }
  63275. $this->tty = (bool) $tty;
  63276. return $this;
  63277. }
  63278. public function isTty()
  63279. {
  63280. return $this->tty;
  63281. }
  63282. public function setPty($bool)
  63283. {
  63284. $this->pty = (bool) $bool;
  63285. return $this;
  63286. }
  63287. public function isPty()
  63288. {
  63289. return $this->pty;
  63290. }
  63291. public function getWorkingDirectory()
  63292. {
  63293. if (null === $this->cwd) {
  63294. return getcwd() ?: null;
  63295. }
  63296. return $this->cwd;
  63297. }
  63298. public function setWorkingDirectory($cwd)
  63299. {
  63300. $this->cwd = $cwd;
  63301. return $this;
  63302. }
  63303. public function getEnv()
  63304. {
  63305. return $this->env;
  63306. }
  63307. public function setEnv(array $env)
  63308. {
  63309. $env = array_filter($env, function ($value) {
  63310. return !\is_array($value);
  63311. });
  63312. $this->env = array();
  63313. foreach ($env as $key => $value) {
  63314. $this->env[$key] = (string) $value;
  63315. }
  63316. return $this;
  63317. }
  63318. public function getStdin()
  63319. {
  63320. @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);
  63321. return $this->getInput();
  63322. }
  63323. public function getInput()
  63324. {
  63325. return $this->input;
  63326. }
  63327. public function setStdin($stdin)
  63328. {
  63329. @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);
  63330. return $this->setInput($stdin);
  63331. }
  63332. public function setInput($input)
  63333. {
  63334. if ($this->isRunning()) {
  63335. throw new LogicException('Input can not be set while the process is running.');
  63336. }
  63337. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  63338. return $this;
  63339. }
  63340. public function getOptions()
  63341. {
  63342. return $this->options;
  63343. }
  63344. public function setOptions(array $options)
  63345. {
  63346. $this->options = $options;
  63347. return $this;
  63348. }
  63349. public function getEnhanceWindowsCompatibility()
  63350. {
  63351. return $this->enhanceWindowsCompatibility;
  63352. }
  63353. public function setEnhanceWindowsCompatibility($enhance)
  63354. {
  63355. $this->enhanceWindowsCompatibility = (bool) $enhance;
  63356. return $this;
  63357. }
  63358. public function getEnhanceSigchildCompatibility()
  63359. {
  63360. return $this->enhanceSigchildCompatibility;
  63361. }
  63362. public function setEnhanceSigchildCompatibility($enhance)
  63363. {
  63364. $this->enhanceSigchildCompatibility = (bool) $enhance;
  63365. return $this;
  63366. }
  63367. public function checkTimeout()
  63368. {
  63369. if (self::STATUS_STARTED !== $this->status) {
  63370. return;
  63371. }
  63372. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  63373. $this->stop(0);
  63374. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  63375. }
  63376. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  63377. $this->stop(0);
  63378. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  63379. }
  63380. }
  63381. public static function isPtySupported()
  63382. {
  63383. static $result;
  63384. if (null !== $result) {
  63385. return $result;
  63386. }
  63387. if ('\\' === \DIRECTORY_SEPARATOR) {
  63388. return $result = false;
  63389. }
  63390. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  63391. }
  63392. private function getDescriptors()
  63393. {
  63394. if ('\\' === \DIRECTORY_SEPARATOR) {
  63395. $this->processPipes = WindowsPipes::create($this, $this->input);
  63396. } else {
  63397. $this->processPipes = UnixPipes::create($this, $this->input);
  63398. }
  63399. return $this->processPipes->getDescriptors();
  63400. }
  63401. protected function buildCallback($callback)
  63402. {
  63403. $that = $this;
  63404. $out = self::OUT;
  63405. $callback = function ($type, $data) use ($that, $callback, $out) {
  63406. if ($out == $type) {
  63407. $that->addOutput($data);
  63408. } else {
  63409. $that->addErrorOutput($data);
  63410. }
  63411. if (null !== $callback) {
  63412. \call_user_func($callback, $type, $data);
  63413. }
  63414. };
  63415. return $callback;
  63416. }
  63417. protected function updateStatus($blocking)
  63418. {
  63419. if (self::STATUS_STARTED !== $this->status) {
  63420. return;
  63421. }
  63422. $this->processInformation = proc_get_status($this->process);
  63423. $running = $this->processInformation['running'];
  63424. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  63425. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63426. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  63427. }
  63428. if (!$running) {
  63429. $this->close();
  63430. }
  63431. }
  63432. protected function isSigchildEnabled()
  63433. {
  63434. if (null !== self::$sigchild) {
  63435. return self::$sigchild;
  63436. }
  63437. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  63438. return self::$sigchild = false;
  63439. }
  63440. ob_start();
  63441. phpinfo(INFO_GENERAL);
  63442. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  63443. }
  63444. private function readPipesForOutput($caller)
  63445. {
  63446. if ($this->outputDisabled) {
  63447. throw new LogicException('Output has been disabled.');
  63448. }
  63449. $this->requireProcessIsStarted($caller);
  63450. $this->updateStatus(false);
  63451. }
  63452. private function validateTimeout($timeout)
  63453. {
  63454. $timeout = (float) $timeout;
  63455. if (0.0 === $timeout) {
  63456. $timeout = null;
  63457. } elseif ($timeout < 0) {
  63458. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  63459. }
  63460. return $timeout;
  63461. }
  63462. private function readPipes($blocking, $close)
  63463. {
  63464. $result = $this->processPipes->readAndWrite($blocking, $close);
  63465. $callback = $this->callback;
  63466. foreach ($result as $type => $data) {
  63467. if (3 !== $type) {
  63468. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  63469. } elseif (!isset($this->fallbackStatus['signaled'])) {
  63470. $this->fallbackStatus['exitcode'] = (int) $data;
  63471. }
  63472. }
  63473. }
  63474. private function close()
  63475. {
  63476. $this->processPipes->close();
  63477. if (\is_resource($this->process)) {
  63478. proc_close($this->process);
  63479. }
  63480. $this->exitcode = $this->processInformation['exitcode'];
  63481. $this->status = self::STATUS_TERMINATED;
  63482. if (-1 === $this->exitcode) {
  63483. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  63484. $this->exitcode = 128 + $this->processInformation['termsig'];
  63485. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63486. $this->processInformation['signaled'] = true;
  63487. $this->processInformation['termsig'] = -1;
  63488. }
  63489. }
  63490. $this->callback = null;
  63491. return $this->exitcode;
  63492. }
  63493. private function resetProcessData()
  63494. {
  63495. $this->starttime = null;
  63496. $this->callback = null;
  63497. $this->exitcode = null;
  63498. $this->fallbackStatus = array();
  63499. $this->processInformation = null;
  63500. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  63501. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  63502. $this->process = null;
  63503. $this->latestSignal = null;
  63504. $this->status = self::STATUS_READY;
  63505. $this->incrementalOutputOffset = 0;
  63506. $this->incrementalErrorOutputOffset = 0;
  63507. }
  63508. private function doSignal($signal, $throwException)
  63509. {
  63510. if (null === $pid = $this->getPid()) {
  63511. if ($throwException) {
  63512. throw new LogicException('Can not send signal on a non running process.');
  63513. }
  63514. return false;
  63515. }
  63516. if ('\\' === \DIRECTORY_SEPARATOR) {
  63517. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  63518. if ($exitCode && $this->isRunning()) {
  63519. if ($throwException) {
  63520. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  63521. }
  63522. return false;
  63523. }
  63524. } else {
  63525. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  63526. $ok = @proc_terminate($this->process, $signal);
  63527. } elseif (\function_exists('posix_kill')) {
  63528. $ok = @posix_kill($pid, $signal);
  63529. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  63530. $ok = false === fgets($pipes[2]);
  63531. }
  63532. if (!$ok) {
  63533. if ($throwException) {
  63534. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  63535. }
  63536. return false;
  63537. }
  63538. }
  63539. $this->latestSignal = (int) $signal;
  63540. $this->fallbackStatus['signaled'] = true;
  63541. $this->fallbackStatus['exitcode'] = -1;
  63542. $this->fallbackStatus['termsig'] = $this->latestSignal;
  63543. return true;
  63544. }
  63545. private function requireProcessIsStarted($functionName)
  63546. {
  63547. if (!$this->isStarted()) {
  63548. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  63549. }
  63550. }
  63551. private function requireProcessIsTerminated($functionName)
  63552. {
  63553. if (!$this->isTerminated()) {
  63554. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  63555. }
  63556. }
  63557. }
  63558. <?php
  63559. namespace Symfony\Component\Process;
  63560. use Symfony\Component\Process\Exception\InvalidArgumentException;
  63561. use Symfony\Component\Process\Exception\LogicException;
  63562. class ProcessBuilder
  63563. {
  63564. private $arguments;
  63565. private $cwd;
  63566. private $env = array();
  63567. private $input;
  63568. private $timeout = 60;
  63569. private $options = array();
  63570. private $inheritEnv = true;
  63571. private $prefix = array();
  63572. private $outputDisabled = false;
  63573. public function __construct(array $arguments = array())
  63574. {
  63575. $this->arguments = $arguments;
  63576. }
  63577. public static function create(array $arguments = array())
  63578. {
  63579. return new static($arguments);
  63580. }
  63581. public function add($argument)
  63582. {
  63583. $this->arguments[] = $argument;
  63584. return $this;
  63585. }
  63586. public function setPrefix($prefix)
  63587. {
  63588. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  63589. return $this;
  63590. }
  63591. public function setArguments(array $arguments)
  63592. {
  63593. $this->arguments = $arguments;
  63594. return $this;
  63595. }
  63596. public function setWorkingDirectory($cwd)
  63597. {
  63598. $this->cwd = $cwd;
  63599. return $this;
  63600. }
  63601. public function inheritEnvironmentVariables($inheritEnv = true)
  63602. {
  63603. $this->inheritEnv = $inheritEnv;
  63604. return $this;
  63605. }
  63606. public function setEnv($name, $value)
  63607. {
  63608. $this->env[$name] = $value;
  63609. return $this;
  63610. }
  63611. public function addEnvironmentVariables(array $variables)
  63612. {
  63613. $this->env = array_replace($this->env, $variables);
  63614. return $this;
  63615. }
  63616. public function setInput($input)
  63617. {
  63618. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  63619. return $this;
  63620. }
  63621. public function setTimeout($timeout)
  63622. {
  63623. if (null === $timeout) {
  63624. $this->timeout = null;
  63625. return $this;
  63626. }
  63627. $timeout = (float) $timeout;
  63628. if ($timeout < 0) {
  63629. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  63630. }
  63631. $this->timeout = $timeout;
  63632. return $this;
  63633. }
  63634. public function setOption($name, $value)
  63635. {
  63636. $this->options[$name] = $value;
  63637. return $this;
  63638. }
  63639. public function disableOutput()
  63640. {
  63641. $this->outputDisabled = true;
  63642. return $this;
  63643. }
  63644. public function enableOutput()
  63645. {
  63646. $this->outputDisabled = false;
  63647. return $this;
  63648. }
  63649. public function getProcess()
  63650. {
  63651. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  63652. throw new LogicException('You must add() command arguments before calling getProcess().');
  63653. }
  63654. $options = $this->options;
  63655. $arguments = array_merge($this->prefix, $this->arguments);
  63656. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  63657. if ($this->inheritEnv) {
  63658. $env = array_replace($_ENV, $_SERVER, $this->env);
  63659. } else {
  63660. $env = $this->env;
  63661. }
  63662. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  63663. if ($this->outputDisabled) {
  63664. $process->disableOutput();
  63665. }
  63666. return $process;
  63667. }
  63668. }
  63669. <?php
  63670. namespace Symfony\Component\Process;
  63671. use Symfony\Component\Process\Exception\InvalidArgumentException;
  63672. class ProcessUtils
  63673. {
  63674. private function __construct()
  63675. {
  63676. }
  63677. public static function escapeArgument($argument)
  63678. {
  63679. if ('\\' === \DIRECTORY_SEPARATOR) {
  63680. if ('' === $argument) {
  63681. return escapeshellarg($argument);
  63682. }
  63683. $escapedArgument = '';
  63684. $quote = false;
  63685. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  63686. if ('"' === $part) {
  63687. $escapedArgument .= '\\"';
  63688. } elseif (self::isSurroundedBy($part, '%')) {
  63689. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  63690. } else {
  63691. if ('\\' === substr($part, -1)) {
  63692. $part .= '\\';
  63693. }
  63694. $quote = true;
  63695. $escapedArgument .= $part;
  63696. }
  63697. }
  63698. if ($quote) {
  63699. $escapedArgument = '"'.$escapedArgument.'"';
  63700. }
  63701. return $escapedArgument;
  63702. }
  63703. return "'".str_replace("'", "'\\''", $argument)."'";
  63704. }
  63705. public static function validateInput($caller, $input)
  63706. {
  63707. if (null !== $input) {
  63708. if (\is_resource($input)) {
  63709. return $input;
  63710. }
  63711. if (\is_string($input)) {
  63712. return $input;
  63713. }
  63714. if (is_scalar($input)) {
  63715. return (string) $input;
  63716. }
  63717. if (\is_object($input) && method_exists($input, '__toString')) {
  63718. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  63719. return (string) $input;
  63720. }
  63721. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  63722. }
  63723. return $input;
  63724. }
  63725. private static function isSurroundedBy($arg, $char)
  63726. {
  63727. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  63728. }
  63729. }
  63730. <?php
  63731. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  63732. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  63733. }
  63734. setlocale(LC_ALL, 'C');
  63735. require __DIR__.'/../src/bootstrap.php';
  63736. use Composer\Console\Application;
  63737. use Composer\XdebugHandler\XdebugHandler;
  63738. error_reporting(-1);
  63739. // Restart without Xdebug
  63740. $xdebug = new XdebugHandler('Composer', '--ansi');
  63741. $xdebug->check();
  63742. unset($xdebug);
  63743. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  63744. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  63745. exit(1);
  63746. }
  63747. if (function_exists('ini_set')) {
  63748. @ini_set('display_errors', 1);
  63749. // Set user defined memory limit
  63750. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  63751. @ini_set('memory_limit', $memoryLimit);
  63752. } else {
  63753. $memoryInBytes = function ($value) {
  63754. $unit = strtolower(substr($value, -1, 1));
  63755. $value = (int) $value;
  63756. switch($unit) {
  63757. case 'g':
  63758. $value *= 1024;
  63759. // no break (cumulative multiplier)
  63760. case 'm':
  63761. $value *= 1024;
  63762. // no break (cumulative multiplier)
  63763. case 'k':
  63764. $value *= 1024;
  63765. }
  63766. return $value;
  63767. };
  63768. $memoryLimit = trim(ini_get('memory_limit'));
  63769. // Increase memory_limit if it is lower than 1.5GB
  63770. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  63771. @ini_set('memory_limit', '1536M');
  63772. }
  63773. unset($memoryInBytes);
  63774. }
  63775. unset($memoryLimit);
  63776. }
  63777. putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
  63778. // run the command application
  63779. $application = new Application();
  63780. $application->run();
  63781. Copyright (c) Nils Adermann, Jordi Boggiano
  63782. Permission is hereby granted, free of charge, to any person obtaining a copy
  63783. of this software and associated documentation files (the "Software"), to deal
  63784. in the Software without restriction, including without limitation the rights
  63785. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63786. copies of the Software, and to permit persons to whom the Software is furnished
  63787. to do so, subject to the following conditions:
  63788. The above copyright notice and this permission notice shall be included in all
  63789. copies or substantial portions of the Software.
  63790. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63791. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63792. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63793. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63794. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63795. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63796. THE SOFTWARE.
  63797. jð²m�ÈÚš¥¿Í/7 {‘rçù���GBMB